iPXE
Data Structures | Macros | Functions
gdbstub.h File Reference

GDB remote debugging. More...

#include <stdint.h>
#include <ipxe/tables.h>
#include <gdbmach.h>

Go to the source code of this file.

Data Structures

struct  gdb_transport
 A transport mechanism for the GDB protocol. More...
 

Macros

#define GDB_TRANSPORTS   __table ( struct gdb_transport, "gdb_transports" )
 
#define __gdb_transport   __table_entry ( GDB_TRANSPORTS, 01 )
 

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
 
struct gdb_transportfind_gdb_transport (const char *name)
 Look up GDB transport by name. More...
 
void gdbstub_start (struct gdb_transport *trans)
 Break into the debugger using the given transport. More...
 
void gdbstub_handler (int signo, gdbreg_t *regs)
 Interrupt handler. More...
 

Detailed Description

GDB remote debugging.

Definition in file gdbstub.h.

Macro Definition Documentation

◆ GDB_TRANSPORTS

#define GDB_TRANSPORTS   __table ( struct gdb_transport, "gdb_transports" )

Definition at line 50 of file gdbstub.h.

◆ __gdb_transport

struct gdb_transport udp_gdb_transport __gdb_transport   __table_entry ( GDB_TRANSPORTS, 01 )

Definition at line 52 of file gdbstub.h.

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )

◆ find_gdb_transport()

struct gdb_transport* find_gdb_transport ( const char *  name)

Look up GDB transport by name.

Parameters
nameName of transport
Return values
GDBtransport or NULL

Definition at line 392 of file gdbstub.c.

392  {
393  struct gdb_transport *trans;
394 
396  if ( strcmp ( trans->name, name ) == 0 ) {
397  return trans;
398  }
399  }
400  return NULL;
401 }
const char * name
Definition: ath9k_hw.c:1984
const char * name
Transport name.
Definition: gdbstub.h:22
#define for_each_table_entry(pointer, table)
Iterate through all entries within a linker table.
Definition: tables.h:358
int strcmp(const char *first, const char *second)
Compare strings.
Definition: string.c:157
#define GDB_TRANSPORTS
Definition: gdbstub.h:50
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362
A transport mechanism for the GDB protocol.
Definition: gdbstub.h:20

References for_each_table_entry, GDB_TRANSPORTS, gdb_transport::name, name, NULL, and strcmp().

Referenced by parse_gdb_transport().

◆ gdbstub_start()

void gdbstub_start ( struct gdb_transport trans)

Break into the debugger using the given transport.

Parameters
transGDB transport

Definition at line 403 of file gdbstub.c.

403  {
404  stub.trans = trans;
405  stub.payload = &stub.buf [ 1 ];
406  gdbmach_init();
408 }
static void gdbmach_breakpoint(void)
Definition: gdbmach.h:64
void gdbmach_init(void)
Initialise GDB.
Definition: gdbmach.c:242
char * payload
Definition: gdbstub.c:60
char buf[SIZEOF_PAYLOAD+4]
Definition: gdbstub.c:59
struct gdb_transport * trans
Definition: gdbstub.c:47
static struct gdbstub stub
Definition: gdbstub.c:368

References gdbstub::buf, gdbmach_breakpoint(), gdbmach_init(), gdbstub::payload, stub, and gdbstub::trans.

Referenced by gdbstub_exec().

◆ gdbstub_handler()

void gdbstub_handler ( int  signo,
gdbreg_t regs 
)

Interrupt handler.

@signo POSIX signal number @regs CPU register snapshot

Definition at line 372 of file gdbstub.c.

372  {
373  char packet [ SIZEOF_PAYLOAD + 4 ];
374  size_t len, i;
375 
376  /* A transport must be set up */
377  if ( !stub.trans ) {
378  return;
379  }
380 
381  stub.signo = signo;
382  stub.regs = regs;
383  stub.exit_handler = 0;
385  while ( !stub.exit_handler && ( len = stub.trans->recv ( packet, sizeof ( packet ) ) ) > 0 ) {
386  for ( i = 0; i < len; i++ ) {
387  gdbstub_parse ( &stub, packet [ i ] );
388  }
389  }
390 }
static void gdbstub_report_signal(struct gdbstub *stub)
Definition: gdbstub.c:201
int signo
Definition: gdbstub.c:50
int exit_handler
Definition: gdbstub.c:48
struct gdb_transport * trans
Definition: gdbstub.c:47
static struct gdbstub stub
Definition: gdbstub.c:368
gdbreg_t * regs
Definition: gdbstub.c:51
struct i386_regs regs
Definition: registers.h:15
static void gdbstub_parse(struct gdbstub *stub, char ch)
Definition: gdbstub.c:364
uint32_t len
Length.
Definition: ena.h:14
size_t(* recv)(char *buf, size_t len)
Perform a blocking read.
Definition: gdbstub.h:40

References gdbstub::exit_handler, gdbstub_parse(), gdbstub_report_signal(), len, gdb_transport::recv, gdbstub::regs, regs, gdbstub::signo, SIZEOF_PAYLOAD, stub, and gdbstub::trans.

Referenced by gdbmach_handler().