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

GDB remote debugging. More...

#include <stdint.h>
#include <ipxe/tables.h>
#include <bits/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 391 of file gdbstub.c.

391  {
392  struct gdb_transport *trans;
393 
395  if ( strcmp ( trans->name, name ) == 0 ) {
396  return trans;
397  }
398  }
399  return NULL;
400 }
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:385
int strcmp(const char *first, const char *second)
Compare strings.
Definition: string.c:173
#define GDB_TRANSPORTS
Definition: gdbstub.h:50
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321
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 402 of file gdbstub.c.

402  {
403  stub.trans = trans;
404  stub.payload = &stub.buf [ 1 ];
405  gdbmach_init();
407 }
static void gdbmach_breakpoint(void)
Definition: gdbmach.h:64
void gdbmach_init(void)
Initialise GDB.
Definition: gdbmach.c:241
char * payload
Definition: gdbstub.c:59
char buf[SIZEOF_PAYLOAD+4]
Definition: gdbstub.c:58
struct gdb_transport * trans
Definition: gdbstub.c:46
static struct gdbstub stub
Definition: gdbstub.c:367

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 371 of file gdbstub.c.

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

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().