2 * Copyright (C) 2008 Stefan Hajnoczi <stefanha@gmail.com>.
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation; either version 2 of the
7 * License, or any later version.
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 #include <gpxe/command.h>
22 #include <gpxe/gdbstub.h>
31 * "gdbstub" command syntax message
33 * @v argv Argument list
35 static void gdbstub_syntax ( char **argv
) {
37 " %s <transport> [<options>...]\n"
39 "Start remote debugging using one of the following transports:\n"
40 " serial use serial port (if compiled in)\n"
41 " udp <interface> use UDP over network interface (if compiled in)\n",
46 * The "gdbstub" command
48 * @v argc Argument count
49 * @v argv Argument list
52 static int gdbstub_exec ( int argc
, char **argv
) {
53 static struct option longopts
[] = {
54 { "help", 0, NULL
, 'h' },
57 const char *trans_name
;
58 struct gdb_transport
*trans
;
62 while ( ( c
= getopt_long ( argc
, argv
, "h", longopts
, NULL
) ) >= 0 ){
65 /* Display help text */
67 /* Unrecognised/invalid option */
68 gdbstub_syntax ( argv
);
73 /* At least one argument */
74 if ( optind
== argc
) {
75 gdbstub_syntax ( argv
);
79 trans_name
= argv
[optind
++];
81 /* Initialise transport */
82 trans
= find_gdb_transport ( trans_name
);
84 printf ( "%s: no such transport (is it compiled in?)\n", trans_name
);
89 if ( trans
->init ( argc
- optind
, &argv
[optind
] ) != 0 ) {
95 gdbstub_start ( trans
);
99 /** GDB stub commands */
100 struct command gdbstub_commands
[] __command
= {
103 .exec
= gdbstub_exec
,