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., 51 Franklin Street, Fifth Floor, Boston, MA
20 FILE_LICENCE ( GPL2_OR_LATER );
26 #include <ipxe/command.h>
27 #include <ipxe/parseopt.h>
28 #include <ipxe/gdbstub.h>
37 * Parse GDB transport name
40 * @ret trans GDB transport
41 * @ret rc Return status code
43 static int parse_gdb_transport ( const char *text,
44 struct gdb_transport **trans ) {
47 assert ( text != NULL );
50 *trans = find_gdb_transport ( text );
52 printf ( "\"%s\": no such transport (is it compiled in?)\n",
60 /** "gdbstub" options */
61 struct gdbstub_options {};
63 /** "gdbstub" option list */
64 static struct option_descriptor gdbstub_opts[] = {};
66 /** "gdbstub" command descriptor */
67 static struct command_descriptor gdbstub_cmd =
68 COMMAND_DESC ( struct gdbstub_options, gdbstub_opts, 1, MAX_ARGUMENTS,
69 "<transport> [<options>...]" );
72 * The "gdbstub" command
74 * @v argc Argument count
75 * @v argv Argument list
76 * @ret rc Return status code
78 static int gdbstub_exec ( int argc, char **argv ) {
79 struct gdbstub_options opts;
80 struct gdb_transport *trans;
84 if ( ( rc = parse_options ( argc, argv, &gdbstub_cmd, &opts ) ) != 0 )
87 /* Parse transport name */
88 if ( ( rc = parse_gdb_transport ( argv[optind++], &trans ) ) != 0 )
91 /* Initialise transport */
93 if ( ( rc = trans->init ( argc - optind,
94 &argv[optind] ) ) != 0 ) {
100 gdbstub_start ( trans );
105 /** GDB stub commands */
106 struct command gdbstub_commands[] __command = {
109 .exec = gdbstub_exec,