/* gdb.c - gdb remote stub module */ /* * Copyright (C) 2003 Free Software Foundation, Inc. * Copyright (C) 2006 Lubomir Kundrak * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include #include #include #include #include #include #include #include #include #include #include VAS_EBOOT_MOD_LICENSE ("GPLv3+"); static VasEBoot_err_t VasEBoot_cmd_gdbstub (struct VasEBoot_command *cmd __attribute__ ((unused)), int argc, char **args) { struct VasEBoot_serial_port *port; if (argc < 1) return VasEBoot_error (VAS_EBOOT_ERR_BAD_ARGUMENT, "port required"); port = VasEBoot_serial_find (args[0]); if (!port) return VasEBoot_errno; VasEBoot_gdb_port = port; /* TRANSLATORS: at this position VAS_EBOOT waits for the user to do an action in remote debugger, namely to tell it to establish connection. */ VasEBoot_puts_ (N_("Now connect the remote debugger, please.")); VasEBoot_gdb_breakpoint (); return 0; } static VasEBoot_err_t VasEBoot_cmd_gdbstop (struct VasEBoot_command *cmd __attribute__ ((unused)), int argc __attribute__ ((unused)), char **args __attribute__ ((unused))) { VasEBoot_gdb_port = NULL; return 0; } static VasEBoot_err_t VasEBoot_cmd_gdb_break (struct VasEBoot_command *cmd __attribute__ ((unused)), int argc __attribute__ ((unused)), char **args __attribute__ ((unused))) { if (!VasEBoot_gdb_port) return VasEBoot_error (VAS_EBOOT_ERR_BAD_ARGUMENT, "No GDB stub is running"); VasEBoot_gdb_breakpoint (); return 0; } static VasEBoot_command_t cmd, cmd_stop, cmd_break; VAS_EBOOT_MOD_INIT (gdb) { VasEBoot_gdb_idtinit (); cmd = VasEBoot_register_command_lockdown ("gdbstub", VasEBoot_cmd_gdbstub, N_("PORT"), /* * TRANSLATORS: GDB stub is a small part of * GDB functionality running on local host * which allows remote debugger to * connect to it. */ N_("Start GDB stub on given port")); cmd_break = VasEBoot_register_command_lockdown ("gdbstub_break", VasEBoot_cmd_gdb_break, /* * TRANSLATORS: this refers to triggering * a breakpoint so that the user will land * into GDB. */ 0, N_("Break into GDB")); cmd_stop = VasEBoot_register_command_lockdown ("gdbstub_stop", VasEBoot_cmd_gdbstop, 0, N_("Stop GDB stub")); } VAS_EBOOT_MOD_FINI (gdb) { VasEBoot_unregister_command (cmd); VasEBoot_unregister_command (cmd_break); VasEBoot_unregister_command (cmd_stop); VasEBoot_gdb_idtrestore (); }