iPXE
gdbstub.h
Go to the documentation of this file.
00001 #ifndef _IPXE_GDBSTUB_H
00002 #define _IPXE_GDBSTUB_H
00003 
00004 /** @file
00005  *
00006  * GDB remote debugging
00007  *
00008  */
00009 
00010 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
00011 
00012 #include <stdint.h>
00013 #include <ipxe/tables.h>
00014 #include <gdbmach.h>
00015 
00016 /**
00017  * A transport mechanism for the GDB protocol
00018  *
00019  */
00020 struct gdb_transport {
00021         /** Transport name */
00022         const char *name;
00023         /**
00024          * Set up the transport given a list of arguments
00025          *
00026          * @v argc Number of arguments
00027          * @v argv Argument list
00028          * @ret Return status code
00029          *
00030          * Note that arguments start at argv[0].
00031          */
00032         int ( * init ) ( int argc, char **argv );
00033         /**
00034          * Perform a blocking read
00035          *
00036          * @v buf Buffer
00037          * @v len Size of buffer
00038          * @ret Number of bytes read into buffer
00039          */
00040         size_t ( * recv ) ( char *buf, size_t len );
00041         /**
00042          * Write, may block
00043          *
00044          * @v buf Buffer
00045          * @v len Size of buffer
00046          */
00047         void ( * send ) ( const char *buf, size_t len );
00048 };
00049 
00050 #define GDB_TRANSPORTS __table ( struct gdb_transport, "gdb_transports" )
00051 
00052 #define __gdb_transport __table_entry ( GDB_TRANSPORTS, 01 )
00053 
00054 /**
00055  * Look up GDB transport by name
00056  *
00057  * @v name Name of transport
00058  * @ret GDB transport or NULL
00059  */
00060 extern struct gdb_transport *find_gdb_transport ( const char *name );
00061 
00062 /**
00063  * Break into the debugger using the given transport
00064  *
00065  * @v trans GDB transport
00066  */
00067 extern void gdbstub_start ( struct gdb_transport *trans );
00068 
00069 /**
00070  * Interrupt handler
00071  *
00072  * @signo POSIX signal number
00073  * @regs CPU register snapshot
00074  **/
00075 extern void gdbstub_handler ( int signo, gdbreg_t *regs );
00076 
00077 #endif /* _IPXE_GDBSTUB_H */