Home | History | Annotate | Download | only in gpxe
      1 #ifndef _GPXE_GDBSTUB_H
      2 #define _GPXE_GDBSTUB_H
      3 
      4 /** @file
      5  *
      6  * GDB remote debugging
      7  *
      8  */
      9 
     10 FILE_LICENCE ( GPL2_OR_LATER );
     11 
     12 #include <stdint.h>
     13 #include <gpxe/tables.h>
     14 #include <gdbmach.h>
     15 
     16 /**
     17  * A transport mechanism for the GDB protocol
     18  *
     19  */
     20 struct gdb_transport {
     21 	/** Transport name */
     22 	const char *name;
     23 	/**
     24 	 * Set up the transport given a list of arguments
     25 	 *
     26 	 * @v argc Number of arguments
     27 	 * @v argv Argument list
     28 	 * @ret Return status code
     29 	 *
     30 	 * Note that arguments start at argv[0].
     31 	 */
     32 	int ( * init ) ( int argc, char **argv );
     33 	/**
     34 	 * Perform a blocking read
     35 	 *
     36 	 * @v buf Buffer
     37 	 * @v len Size of buffer
     38 	 * @ret Number of bytes read into buffer
     39 	 */
     40 	size_t ( * recv ) ( char *buf, size_t len );
     41 	/**
     42 	 * Write, may block
     43 	 *
     44 	 * @v buf Buffer
     45 	 * @v len Size of buffer
     46 	 */
     47 	void ( * send ) ( const char *buf, size_t len );
     48 };
     49 
     50 #define GDB_TRANSPORTS __table ( struct gdb_transport, "gdb_transports" )
     51 
     52 #define __gdb_transport __table_entry ( GDB_TRANSPORTS, 01 )
     53 
     54 /**
     55  * Look up GDB transport by name
     56  *
     57  * @v name Name of transport
     58  * @ret GDB transport or NULL
     59  */
     60 extern struct gdb_transport *find_gdb_transport ( const char *name );
     61 
     62 /**
     63  * Break into the debugger using the given transport
     64  *
     65  * @v trans GDB transport
     66  */
     67 extern void gdbstub_start ( struct gdb_transport *trans );
     68 
     69 /**
     70  * Interrupt handler
     71  *
     72  * @signo POSIX signal number
     73  * @regs CPU register snapshot
     74  **/
     75 extern void gdbstub_handler ( int signo, gdbreg_t *regs );
     76 
     77 #endif /* _GPXE_GDBSTUB_H */
     78