1 /* gdb.c - gdb remote stub module */
3 * Copyright (C) 2003 Free Software Foundation, Inc.
4 * Copyright (C) 2006 Lubomir Kundrak
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 3 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 #include <grub/types.h>
22 #include <grub/misc.h>
26 #include <grub/normal.h>
27 #include <grub/term.h>
28 #include <grub/cpu/gdb.h>
30 #include <grub/serial.h>
31 #include <grub/i18n.h>
33 GRUB_MOD_LICENSE ("GPLv3+");
36 grub_cmd_gdbstub (struct grub_command
*cmd
__attribute__ ((unused
)),
37 int argc
, char **args
)
39 struct grub_serial_port
*port
;
41 return grub_error (GRUB_ERR_BAD_ARGUMENT
, "port required");
42 port
= grub_serial_find (args
[0]);
46 /* TRANSLATORS: at this position GRUB waits for the user to do an action
47 in remote debugger, namely to tell it to establish connection. */
48 grub_puts_ (N_("Now connect the remote debugger, please."));
49 grub_gdb_breakpoint ();
54 grub_cmd_gdbstop (struct grub_command
*cmd
__attribute__ ((unused
)),
55 int argc
__attribute__ ((unused
)),
56 char **args
__attribute__ ((unused
)))
63 grub_cmd_gdb_break (struct grub_command
*cmd
__attribute__ ((unused
)),
64 int argc
__attribute__ ((unused
)),
65 char **args
__attribute__ ((unused
)))
68 return grub_error (GRUB_ERR_BAD_ARGUMENT
, "No GDB stub is running");
69 grub_gdb_breakpoint ();
73 static grub_command_t cmd
, cmd_stop
, cmd_break
;
78 cmd
= grub_register_command ("gdbstub", grub_cmd_gdbstub
,
80 /* TRANSLATORS: GDB stub is a small part of
81 GDB functionality running on local host
82 which allows remote debugger to
84 N_("Start GDB stub on given port"));
85 cmd_break
= grub_register_command ("gdbstub_break", grub_cmd_gdb_break
,
86 /* TRANSLATORS: this refers to triggering
87 a breakpoint so that the user will land
89 0, N_("Break into GDB"));
90 cmd_stop
= grub_register_command ("gdbstub_stop", grub_cmd_gdbstop
,
91 0, N_("Stop GDB stub"));
96 grub_unregister_command (cmd
);
97 grub_unregister_command (cmd_stop
);
98 grub_gdb_idtrestore ();