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
19
* You can also choose to distribute this program under the terms of
20
* the Unmodified Binary Distribution Licence (as given in the file
21
* COPYING.UBDL), provided that you have satisfied its requirements.
24
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
30
#include <ipxe/command.h>
31
#include <ipxe/parseopt.h>
32
#include <ipxe/gdbstub.h>
41
* Parse GDB transport name
44
* @ret trans GDB transport
45
* @ret rc Return status code
47
static int parse_gdb_transport ( const char *text,
48
struct gdb_transport **trans ) {
51
assert ( text != NULL );
54
*trans = find_gdb_transport ( text );
56
printf ( "\"%s\": no such transport (is it compiled in?)\n",
64
/** "gdbstub" options */
65
struct gdbstub_options {};
67
/** "gdbstub" option list */
68
static struct option_descriptor gdbstub_opts[] = {};
70
/** "gdbstub" command descriptor */
71
static struct command_descriptor gdbstub_cmd =
72
COMMAND_DESC ( struct gdbstub_options, gdbstub_opts, 1, MAX_ARGUMENTS,
73
"<transport> [<options>...]" );
76
* The "gdbstub" command
78
* @v argc Argument count
79
* @v argv Argument list
80
* @ret rc Return status code
82
static int gdbstub_exec ( int argc, char **argv ) {
83
struct gdbstub_options opts;
84
struct gdb_transport *trans;
88
if ( ( rc = parse_options ( argc, argv, &gdbstub_cmd, &opts ) ) != 0 )
91
/* Parse transport name */
92
if ( ( rc = parse_gdb_transport ( argv[optind++], &trans ) ) != 0 )
95
/* Initialise transport */
97
if ( ( rc = trans->init ( argc - optind,
98
&argv[optind] ) ) != 0 ) {
104
gdbstub_start ( trans );
109
/** GDB stub commands */
110
struct command gdbstub_commands[] __command = {
113
.exec = gdbstub_exec,