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)
 
 FILE_SECBOOT (FORBIDDEN)
 
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...
 
 COMMAND (gdbstub, gdbstub_exec)
 GDB stub commands. More...
 

Variables

static struct option_descriptor gdbstub_opts [] = {}
 "gdbstub" option list More...
 
static struct command_descriptor gdbstub_cmd
 "gdbstub" command descriptor More...
 

Detailed Description

GDB stub command.

Definition in file gdbstub_cmd.c.

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )

◆ FILE_SECBOOT()

FILE_SECBOOT ( FORBIDDEN  )

◆ 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 48 of file gdbstub_cmd.c.

49  {
50 
51  /* Sanity check */
52  assert ( text != NULL );
53 
54  /* Find transport */
55  *trans = find_gdb_transport ( text );
56  if ( ! *trans ) {
57  printf ( "\"%s\": no such transport (is it compiled in?)\n",
58  text );
59  return -ENOTSUP;
60  }
61 
62  return 0;
63 }
int printf(const char *fmt,...)
Write a formatted string to the console.
Definition: vsprintf.c:465
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:590
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
#define NULL
NULL pointer (VOID *)
Definition: Base.h:322

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 83 of file gdbstub_cmd.c.

83  {
84  struct gdbstub_options opts;
85  struct gdb_transport *trans;
86  int rc;
87 
88  /* Parse options */
89  if ( ( rc = parse_options ( argc, argv, &gdbstub_cmd, &opts ) ) != 0 )
90  return rc;
91 
92  /* Parse transport name */
93  if ( ( rc = parse_gdb_transport ( argv[optind++], &trans ) ) != 0 )
94  return rc;
95 
96  /* Initialise transport */
97  if ( trans->init ) {
98  if ( ( rc = trans->init ( argc - optind,
99  &argv[optind] ) ) != 0 ) {
100  return rc;
101  }
102  }
103 
104  /* Enter GDB stub */
105  gdbstub_start ( trans );
106 
107  return 0;
108 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
int optind
Current option index.
Definition: getopt.c:52
int parse_options(int argc, char **argv, struct command_descriptor *cmd, void *opts)
Parse command-line options.
Definition: parseopt.c:485
"gdbstub" options
Definition: gdbstub_cmd.c:66
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:33
static struct command_descriptor gdbstub_cmd
"gdbstub" command descriptor
Definition: gdbstub_cmd.c:72
static union @447 opts
"cert<xxx>" option list
static int parse_gdb_transport(const char *text, struct gdb_transport **trans)
Parse GDB transport name.
Definition: gdbstub_cmd.c:48
A transport mechanism for the GDB protocol.
Definition: gdbstub.h:21

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

◆ COMMAND()

COMMAND ( gdbstub  ,
gdbstub_exec   
)

GDB stub commands.

Variable Documentation

◆ gdbstub_opts

struct option_descriptor gdbstub_opts[] = {}
static

"gdbstub" option list

Definition at line 69 of file gdbstub_cmd.c.

◆ gdbstub_cmd

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

"gdbstub" command descriptor

Definition at line 72 of file gdbstub_cmd.c.

Referenced by gdbstub_exec().