iPXE
Data Structures | Functions | Variables
gdbstub_cmd.c File Reference

GDB stub command. More...

#include <stdio.h>
#include <errno.h>
#include <assert.h>
#include <getopt.h>
#include <ipxe/command.h>
#include <ipxe/parseopt.h>
#include <ipxe/gdbstub.h>

Go to the source code of this file.

Data Structures

struct  gdbstub_options
 "gdbstub" options More...
 

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
 
static int parse_gdb_transport (const char *text, struct gdb_transport **trans)
 Parse GDB transport name. More...
 
static int gdbstub_exec (int argc, char **argv)
 The "gdbstub" command. More...
 

Variables

static struct option_descriptor gdbstub_opts [] = {}
 "gdbstub" option list More...
 
static struct command_descriptor gdbstub_cmd
 "gdbstub" command descriptor More...
 
struct command gdbstub_commands [] __command
 GDB stub commands. More...
 

Detailed Description

GDB stub command.

Definition in file gdbstub_cmd.c.

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )

◆ parse_gdb_transport()

static int parse_gdb_transport ( const char *  text,
struct gdb_transport **  trans 
)
static

Parse GDB transport name.

Parameters
textText
Return values
transGDB transport
rcReturn status code

Definition at line 47 of file gdbstub_cmd.c.

48  {
49 
50  /* Sanity check */
51  assert ( text != NULL );
52 
53  /* Find transport */
54  *trans = find_gdb_transport ( text );
55  if ( ! *trans ) {
56  printf ( "\"%s\": no such transport (is it compiled in?)\n",
57  text );
58  return -ENOTSUP;
59  }
60 
61  return 0;
62 }
int printf(const char *fmt,...)
Write a formatted string to the console.
Definition: vsprintf.c:464
struct gdb_transport * find_gdb_transport(const char *name)
Look up GDB transport by name.
Definition: gdbstub.c:392
#define ENOTSUP
Operation not supported.
Definition: errno.h:589
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362

References assert(), ENOTSUP, find_gdb_transport(), NULL, and printf().

Referenced by gdbstub_exec().

◆ gdbstub_exec()

static int gdbstub_exec ( int  argc,
char **  argv 
)
static

The "gdbstub" command.

Parameters
argcArgument count
argvArgument list
Return values
rcReturn status code

Definition at line 82 of file gdbstub_cmd.c.

82  {
83  struct gdbstub_options opts;
84  struct gdb_transport *trans;
85  int rc;
86 
87  /* Parse options */
88  if ( ( rc = parse_options ( argc, argv, &gdbstub_cmd, &opts ) ) != 0 )
89  return rc;
90 
91  /* Parse transport name */
92  if ( ( rc = parse_gdb_transport ( argv[optind++], &trans ) ) != 0 )
93  return rc;
94 
95  /* Initialise transport */
96  if ( trans->init ) {
97  if ( ( rc = trans->init ( argc - optind,
98  &argv[optind] ) ) != 0 ) {
99  return rc;
100  }
101  }
102 
103  /* Enter GDB stub */
104  gdbstub_start ( trans );
105 
106  return 0;
107 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
int optind
Current option index.
Definition: getopt.c:51
int parse_options(int argc, char **argv, struct command_descriptor *cmd, void *opts)
Parse command-line options.
Definition: parseopt.c:447
"gdbstub" options
Definition: gdbstub_cmd.c:65
static union @423 opts
"cert<xxx>" option list
void gdbstub_start(struct gdb_transport *trans)
Break into the debugger using the given transport.
Definition: gdbstub.c:403
int(* init)(int argc, char **argv)
Set up the transport given a list of arguments.
Definition: gdbstub.h:32
static struct command_descriptor gdbstub_cmd
"gdbstub" command descriptor
Definition: gdbstub_cmd.c:71
static int parse_gdb_transport(const char *text, struct gdb_transport **trans)
Parse GDB transport name.
Definition: gdbstub_cmd.c:47
A transport mechanism for the GDB protocol.
Definition: gdbstub.h:20

References gdbstub_cmd, gdbstub_start(), gdb_transport::init, optind, opts, parse_gdb_transport(), parse_options(), and rc.

Variable Documentation

◆ gdbstub_opts

struct option_descriptor gdbstub_opts[] = {}
static

"gdbstub" option list

Definition at line 68 of file gdbstub_cmd.c.

◆ gdbstub_cmd

struct command_descriptor gdbstub_cmd
static
Initial value:
=
"<transport> [<options>...]" )
"gdbstub" options
Definition: gdbstub_cmd.c:65
#define MAX_ARGUMENTS
No maximum number of arguments.
Definition: parseopt.h:96
static struct option_descriptor gdbstub_opts[]
"gdbstub" option list
Definition: gdbstub_cmd.c:68
#define COMMAND_DESC(_struct, _options, _min_args, _max_args, _usage)
Construct command descriptor.
Definition: parseopt.h:107

"gdbstub" command descriptor

Definition at line 71 of file gdbstub_cmd.c.

Referenced by gdbstub_exec().

◆ __command

struct command gdbstub_commands [] __command
Initial value:
= {
{
.name = "gdbstub",
.exec = gdbstub_exec,
},
}
static int gdbstub_exec(int argc, char **argv)
The "gdbstub" command.
Definition: gdbstub_cmd.c:82

GDB stub commands.

Definition at line 110 of file gdbstub_cmd.c.