summaryrefslogtreecommitdiffstats
path: root/src/include/ipxe/gdbstub.h
blob: 31960674731542f5f118cbd4386e672bd500641c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#ifndef _IPXE_GDBSTUB_H
#define _IPXE_GDBSTUB_H

/** @file
 *
 * GDB remote debugging
 *
 */

FILE_LICENCE ( GPL2_OR_LATER );

#include <stdint.h>
#include <ipxe/tables.h>
#include <gdbmach.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_TRANSPORTS __table ( struct gdb_transport, "gdb_transports" )

#define __gdb_transport __table_entry ( 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 );

/**
 * Interrupt handler
 *
 * @signo POSIX signal number
 * @regs CPU register snapshot
 **/
extern void gdbstub_handler ( int signo, gdbreg_t *regs );

#endif /* _IPXE_GDBSTUB_H */