[GDB] Remote debugging over UDP

This commit implements GDB over UDP.  Using UDP is more complex than
serial and has required some restructuring.

The GDB stub is now built using one or both of GDBSERIAL and GDBUDP
config.h options.

To enter the debugger, execute the gPXE shell command:
gdbstub <transport> [<options>...]

Where <transport> is "serial" or "udp".  For "udp", the name of a
configured network device is required:
gdbstub udp net0

The GDB stub listens on UDP port 43770 by default.
This commit is contained in:
Stefan Hajnoczi
2008-06-11 12:12:46 +01:00
committed by Michael Brown
parent 9ec3ff95f0
commit 6e670b5f38
8 changed files with 501 additions and 50 deletions

View File

@@ -0,0 +1,64 @@
#ifndef _GPXE_GDBSTUB_H
#define _GPXE_GDBSTUB_H
/** @file
*
* GDB remote debugging
*
*/
#include <stdint.h>
#include <gpxe/tables.h>
/**
* A transport mechanism for the GDB protocol
*
*/
struct gdb_transport {
/** Transport name */
const char *name;
/**
* Set up the transport given a list of arguments
*
* @v argc Number of arguments
* @v argv Argument list
* @ret Return status code
*
* Note that arguments start at argv[0].
*/
int ( * init ) ( int argc, char **argv );
/**
* Perform a blocking read
*
* @v buf Buffer
* @v len Size of buffer
* @ret Number of bytes read into buffer
*/
size_t ( * recv ) ( char *buf, size_t len );
/**
* Write, may block
*
* @v buf Buffer
* @v len Size of buffer
*/
void ( * send ) ( const char *buf, size_t len );
};
#define __gdb_transport __table ( struct gdb_transport, gdb_transports, 01 )
/**
* Look up GDB transport by name
*
* @v name Name of transport
* @ret GDB transport or NULL
*/
extern struct gdb_transport *find_gdb_transport ( const char *name );
/**
* Break into the debugger using the given transport
*
* @v trans GDB transport
*/
extern void gdbstub_start ( struct gdb_transport *trans );
#endif /* _GPXE_GDBSTUB_H */