iPXE
gdbstub.c File Reference

GDB stub for remote debugging. More...

#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <byteswap.h>
#include <ipxe/gdbstub.h>

Go to the source code of this file.

Data Structures

struct  gdbstub

Enumerations

enum  { POSIX_EINVAL = 0x1c , SIZEOF_PAYLOAD = 512 }

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
 FILE_SECBOOT (FORBIDDEN)
static void gdbstub_state_new (struct gdbstub *stub, char ch)
static void gdbstub_state_data (struct gdbstub *stub, char ch)
static void gdbstub_state_cksum1 (struct gdbstub *stub, char ch)
static void gdbstub_state_cksum2 (struct gdbstub *stub, char ch)
static void gdbstub_state_wait_ack (struct gdbstub *stub, char ch)
static uint8_t gdbstub_from_hex_digit (char ch)
static uint8_t gdbstub_to_hex_digit (uint8_t b)
static void gdbstub_from_hex_buf (char *dst, char *src, int lenbytes)
static void gdbstub_to_hex_buf (char *dst, char *src, int lenbytes)
static uint8_t gdbstub_cksum (char *data, int len)
static void gdbstub_tx_packet (struct gdbstub *stub)
static void gdbstub_send_ok (struct gdbstub *stub)
static void gdbstub_send_num_packet (struct gdbstub *stub, char reply, int num)
static int gdbstub_get_packet_args (struct gdbstub *stub, unsigned long *args, int nargs, int *stop_idx)
static void gdbstub_send_errno (struct gdbstub *stub, int errno)
static void gdbstub_report_signal (struct gdbstub *stub)
static void gdbstub_read_regs (struct gdbstub *stub)
static void gdbstub_write_regs (struct gdbstub *stub)
static void gdbstub_read_mem (struct gdbstub *stub)
static void gdbstub_write_mem (struct gdbstub *stub)
static void gdbstub_continue (struct gdbstub *stub, int single_step)
static void gdbstub_breakpoint (struct gdbstub *stub)
static void gdbstub_rx_packet (struct gdbstub *stub)
static void gdbstub_parse (struct gdbstub *stub, char ch)
void gdbstub_handler (int signo, gdbreg_t *regs)
 Interrupt handler.
struct gdb_transportfind_gdb_transport (const char *name)
 Look up GDB transport by name.
void gdbstub_start (struct gdb_transport *trans)
 Break into the debugger using the given transport.

Variables

static struct gdbstub stub

Detailed Description

GDB stub for remote debugging.

Definition in file gdbstub.c.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
POSIX_EINVAL 
SIZEOF_PAYLOAD 

Definition at line 41 of file gdbstub.c.

41 {
42 POSIX_EINVAL = 0x1c, /* used to report bad arguments to GDB */
43 SIZEOF_PAYLOAD = 512, /* buffer size of GDB payload data */
44};
@ SIZEOF_PAYLOAD
Definition gdbstub.c:43
@ POSIX_EINVAL
Definition gdbstub.c:42

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )

◆ FILE_SECBOOT()

FILE_SECBOOT ( FORBIDDEN )

◆ gdbstub_state_new()

void gdbstub_state_new ( struct gdbstub * stub,
char ch )
static

Definition at line 312 of file gdbstub.c.

312 {
313 if ( ch == '$' ) {
314 stub->len = 0;
315 stub->parse = gdbstub_state_data;
316 }
317}
static struct gdbstub stub
Definition gdbstub.c:368
static void gdbstub_state_data(struct gdbstub *stub, char ch)
Definition gdbstub.c:319
uint8_t ch
Definition registers.h:1

References ch, gdbstub_state_data(), and stub.

Referenced by gdbstub_state_cksum2(), and gdbstub_state_wait_ack().

◆ gdbstub_state_data()

void gdbstub_state_data ( struct gdbstub * stub,
char ch )
static

Definition at line 319 of file gdbstub.c.

319 {
320 if ( ch == '#' ) {
321 stub->parse = gdbstub_state_cksum1;
322 } else if ( ch == '$' ) {
323 stub->len = 0; /* retry new packet */
324 } else {
325 /* If the length exceeds our buffer, let the checksum fail */
326 if ( stub->len < SIZEOF_PAYLOAD ) {
327 stub->payload [ stub->len++ ] = ch;
328 }
329 }
330}
static void gdbstub_state_cksum1(struct gdbstub *stub, char ch)
Definition gdbstub.c:332

References ch, gdbstub_state_cksum1(), SIZEOF_PAYLOAD, and stub.

Referenced by gdbstub_state_new().

◆ gdbstub_state_cksum1()

void gdbstub_state_cksum1 ( struct gdbstub * stub,
char ch )
static

Definition at line 332 of file gdbstub.c.

332 {
333 stub->cksum1 = gdbstub_from_hex_digit ( ch ) << 4;
334 stub->parse = gdbstub_state_cksum2;
335}
static void gdbstub_state_cksum2(struct gdbstub *stub, char ch)
Definition gdbstub.c:337
static uint8_t gdbstub_from_hex_digit(char ch)
Definition gdbstub.c:71

References ch, gdbstub_from_hex_digit(), gdbstub_state_cksum2(), and stub.

Referenced by gdbstub_state_data().

◆ gdbstub_state_cksum2()

void gdbstub_state_cksum2 ( struct gdbstub * stub,
char ch )
static

Definition at line 337 of file gdbstub.c.

337 {
338 uint8_t their_cksum;
339 uint8_t our_cksum;
340
341 stub->parse = gdbstub_state_new;
342 their_cksum = stub->cksum1 + gdbstub_from_hex_digit ( ch );
343 our_cksum = gdbstub_cksum ( stub->payload, stub->len );
344 if ( their_cksum == our_cksum ) {
345 stub->trans->send ( "+", 1 );
346 if ( stub->len > 0 ) {
348 }
349 } else {
350 stub->trans->send ( "-", 1 );
351 }
352}
unsigned char uint8_t
Definition stdint.h:10
static void gdbstub_state_new(struct gdbstub *stub, char ch)
Definition gdbstub.c:312
static uint8_t gdbstub_cksum(char *data, int len)
Definition gdbstub.c:137
static void gdbstub_rx_packet(struct gdbstub *stub)
Definition gdbstub.c:274

References ch, gdbstub_cksum(), gdbstub_from_hex_digit(), gdbstub_rx_packet(), gdbstub_state_new(), and stub.

Referenced by gdbstub_state_cksum1().

◆ gdbstub_state_wait_ack()

void gdbstub_state_wait_ack ( struct gdbstub * stub,
char ch )
static

Definition at line 354 of file gdbstub.c.

354 {
355 if ( ch == '+' ) {
356 stub->parse = gdbstub_state_new;
357 } else {
358 /* This retransmit is very aggressive but necessary to keep
359 * in sync with GDB. */
361 }
362}
static void gdbstub_tx_packet(struct gdbstub *stub)
Definition gdbstub.c:145

References ch, gdbstub_state_new(), gdbstub_tx_packet(), and stub.

Referenced by gdbstub_tx_packet().

◆ gdbstub_from_hex_digit()

uint8_t gdbstub_from_hex_digit ( char ch)
static

Definition at line 71 of file gdbstub.c.

71 {
72 return ( isdigit ( ch ) ? ch - '0' : tolower ( ch ) - 'a' + 0xa ) & 0xf;
73}
static int isdigit(int character)
Check if character is a decimal digit.
Definition ctype.h:30
static int tolower(int character)
Convert character to lower case.
Definition ctype.h:109

References ch, isdigit(), and tolower().

Referenced by gdbstub_from_hex_buf(), gdbstub_get_packet_args(), gdbstub_state_cksum1(), and gdbstub_state_cksum2().

◆ gdbstub_to_hex_digit()

uint8_t gdbstub_to_hex_digit ( uint8_t b)
static

Definition at line 75 of file gdbstub.c.

75 {
76 b &= 0xf;
77 return ( b < 0xa ? '0' : 'a' - 0xa ) + b;
78}

Referenced by gdbstub_send_num_packet(), gdbstub_to_hex_buf(), and gdbstub_tx_packet().

◆ gdbstub_from_hex_buf()

void gdbstub_from_hex_buf ( char * dst,
char * src,
int lenbytes )
static

Definition at line 85 of file gdbstub.c.

85 {
86 if ( lenbytes == 2 && ( ( unsigned long ) dst & 0x1 ) == 0 ) {
87 uint16_t i = gdbstub_from_hex_digit ( src [ 2 ] ) << 12 |
88 gdbstub_from_hex_digit ( src [ 3 ] ) << 8 |
89 gdbstub_from_hex_digit ( src [ 0 ] ) << 4 |
91 * ( uint16_t * ) dst = cpu_to_le16 ( i );
92 } else if ( lenbytes == 4 && ( ( unsigned long ) dst & 0x3 ) == 0 ) {
93 uint32_t i = gdbstub_from_hex_digit ( src [ 6 ] ) << 28 |
94 gdbstub_from_hex_digit ( src [ 7 ] ) << 24 |
95 gdbstub_from_hex_digit ( src [ 4 ] ) << 20 |
96 gdbstub_from_hex_digit ( src [ 5 ] ) << 16 |
97 gdbstub_from_hex_digit ( src [ 2 ] ) << 12 |
98 gdbstub_from_hex_digit ( src [ 3 ] ) << 8 |
99 gdbstub_from_hex_digit ( src [ 0 ] ) << 4 |
100 gdbstub_from_hex_digit ( src [ 1 ] );
101 * ( uint32_t * ) dst = cpu_to_le32 ( i );
102 } else {
103 while ( lenbytes-- > 0 ) {
104 *dst++ = gdbstub_from_hex_digit ( src [ 0 ] ) << 4 |
105 gdbstub_from_hex_digit ( src [ 1 ] );
106 src += 2;
107 }
108 }
109}
unsigned short uint16_t
Definition stdint.h:11
unsigned int uint32_t
Definition stdint.h:12
static const void * src
Definition string.h:48
#define cpu_to_le32(value)
Definition byteswap.h:108
#define cpu_to_le16(value)
Definition byteswap.h:107

References cpu_to_le16, cpu_to_le32, gdbstub_from_hex_digit(), and src.

Referenced by gdbstub_write_mem(), and gdbstub_write_regs().

◆ gdbstub_to_hex_buf()

void gdbstub_to_hex_buf ( char * dst,
char * src,
int lenbytes )
static

Definition at line 111 of file gdbstub.c.

111 {
112 if ( lenbytes == 2 && ( ( unsigned long ) src & 0x1 ) == 0 ) {
113 uint16_t i = cpu_to_le16 ( * ( uint16_t * ) src );
114 dst [ 0 ] = gdbstub_to_hex_digit ( i >> 4 );
115 dst [ 1 ] = gdbstub_to_hex_digit ( i );
116 dst [ 2 ] = gdbstub_to_hex_digit ( i >> 12 );
117 dst [ 3 ] = gdbstub_to_hex_digit ( i >> 8 );
118 } else if ( lenbytes == 4 && ( ( unsigned long ) src & 0x3 ) == 0 ) {
119 uint32_t i = cpu_to_le32 ( * ( uint32_t * ) src );
120 dst [ 0 ] = gdbstub_to_hex_digit ( i >> 4 );
121 dst [ 1 ] = gdbstub_to_hex_digit ( i );
122 dst [ 2 ] = gdbstub_to_hex_digit ( i >> 12 );
123 dst [ 3 ] = gdbstub_to_hex_digit ( i >> 8 );
124 dst [ 4 ] = gdbstub_to_hex_digit ( i >> 20 );
125 dst [ 5 ] = gdbstub_to_hex_digit ( i >> 16);
126 dst [ 6 ] = gdbstub_to_hex_digit ( i >> 28 );
127 dst [ 7 ] = gdbstub_to_hex_digit ( i >> 24 );
128 } else {
129 while ( lenbytes-- > 0 ) {
130 *dst++ = gdbstub_to_hex_digit ( *src >> 4 );
131 *dst++ = gdbstub_to_hex_digit ( *src );
132 src++;
133 }
134 }
135}
static uint8_t gdbstub_to_hex_digit(uint8_t b)
Definition gdbstub.c:75

References cpu_to_le16, cpu_to_le32, gdbstub_to_hex_digit(), and src.

Referenced by gdbstub_read_mem(), and gdbstub_read_regs().

◆ gdbstub_cksum()

uint8_t gdbstub_cksum ( char * data,
int len )
static

Definition at line 137 of file gdbstub.c.

137 {
138 uint8_t cksum = 0;
139 while ( len-- > 0 ) {
140 cksum += ( uint8_t ) *data++;
141 }
142 return cksum;
143}
ring len
Length.
Definition dwmac.h:226
uint8_t data[48]
Additional event data.
Definition ena.h:11

References data, and len.

Referenced by gdbstub_state_cksum2(), and gdbstub_tx_packet().

◆ gdbstub_tx_packet()

void gdbstub_tx_packet ( struct gdbstub * stub)
static

Definition at line 145 of file gdbstub.c.

145 {
146 uint8_t cksum = gdbstub_cksum ( stub->payload, stub->len );
147 stub->buf [ 0 ] = '$';
148 stub->buf [ stub->len + 1 ] = '#';
149 stub->buf [ stub->len + 2 ] = gdbstub_to_hex_digit ( cksum >> 4 );
150 stub->buf [ stub->len + 3 ] = gdbstub_to_hex_digit ( cksum );
151 stub->trans->send ( stub->buf, stub->len + 4 );
153}
static void gdbstub_state_wait_ack(struct gdbstub *stub, char ch)
Definition gdbstub.c:354

References gdbstub_cksum(), gdbstub_state_wait_ack(), gdbstub_to_hex_digit(), and stub.

Referenced by gdbstub_breakpoint(), gdbstub_read_mem(), gdbstub_read_regs(), gdbstub_rx_packet(), gdbstub_send_num_packet(), gdbstub_send_ok(), and gdbstub_state_wait_ack().

◆ gdbstub_send_ok()

void gdbstub_send_ok ( struct gdbstub * stub)
static

Definition at line 156 of file gdbstub.c.

156 {
157 stub->payload [ 0 ] = 'O';
158 stub->payload [ 1 ] = 'K';
159 stub->len = 2;
161}

References gdbstub_tx_packet(), and stub.

Referenced by gdbstub_breakpoint(), gdbstub_rx_packet(), gdbstub_write_mem(), and gdbstub_write_regs().

◆ gdbstub_send_num_packet()

void gdbstub_send_num_packet ( struct gdbstub * stub,
char reply,
int num )
static

Definition at line 163 of file gdbstub.c.

163 {
164 stub->payload [ 0 ] = reply;
165 stub->payload [ 1 ] = gdbstub_to_hex_digit ( ( char ) num >> 4 );
166 stub->payload [ 2 ] = gdbstub_to_hex_digit ( ( char ) num );
167 stub->len = 3;
169}
uint32_t num
Definition multiboot.h:0

References gdbstub_to_hex_digit(), gdbstub_tx_packet(), num, and stub.

Referenced by gdbstub_report_signal(), and gdbstub_send_errno().

◆ gdbstub_get_packet_args()

int gdbstub_get_packet_args ( struct gdbstub * stub,
unsigned long * args,
int nargs,
int * stop_idx )
static

Definition at line 172 of file gdbstub.c.

172 {
173 int i;
174 char ch = 0;
175 int argc = 0;
176 unsigned long val = 0;
177 for ( i = 1; i < stub->len && argc < nargs; i++ ) {
178 ch = stub->payload [ i ];
179 if ( ch == ':' ) {
180 break;
181 } else if ( ch == ',' ) {
182 args [ argc++ ] = val;
183 val = 0;
184 } else {
185 val = ( val << 4 ) | gdbstub_from_hex_digit ( ch );
186 }
187 }
188 if ( stop_idx ) {
189 *stop_idx = i;
190 }
191 if ( argc < nargs ) {
192 args [ argc++ ] = val;
193 }
194 return ( ( i == stub->len || ch == ':' ) && argc == nargs );
195}
void __asmcall int val
Definition setjmp.h:12

References ch, gdbstub_from_hex_digit(), stub, and val.

Referenced by gdbstub_breakpoint(), gdbstub_continue(), gdbstub_read_mem(), and gdbstub_write_mem().

◆ gdbstub_send_errno()

void gdbstub_send_errno ( struct gdbstub * stub,
int errno )
static

Definition at line 197 of file gdbstub.c.

197 {
199}
int errno
Global "last error" number.
Definition errno.c:21
static void gdbstub_send_num_packet(struct gdbstub *stub, char reply, int num)
Definition gdbstub.c:163

References errno, gdbstub_send_num_packet(), and stub.

Referenced by gdbstub_breakpoint(), gdbstub_read_mem(), gdbstub_write_mem(), and gdbstub_write_regs().

◆ gdbstub_report_signal()

void gdbstub_report_signal ( struct gdbstub * stub)
static

Definition at line 201 of file gdbstub.c.

201 {
202 gdbstub_send_num_packet ( stub, 'S', stub->signo );
203}

References gdbstub_send_num_packet(), and stub.

Referenced by gdbstub_handler(), and gdbstub_rx_packet().

◆ gdbstub_read_regs()

void gdbstub_read_regs ( struct gdbstub * stub)
static

Definition at line 205 of file gdbstub.c.

205 {
206 gdbstub_to_hex_buf ( stub->payload, ( char * ) stub->regs, GDBMACH_SIZEOF_REGS );
207 stub->len = GDBMACH_SIZEOF_REGS * 2;
209}
static void gdbstub_to_hex_buf(char *dst, char *src, int lenbytes)
Definition gdbstub.c:111
#define GDBMACH_SIZEOF_REGS
Definition gdbmach.h:25

References GDBMACH_SIZEOF_REGS, gdbstub_to_hex_buf(), gdbstub_tx_packet(), and stub.

Referenced by gdbstub_rx_packet().

◆ gdbstub_write_regs()

void gdbstub_write_regs ( struct gdbstub * stub)
static

Definition at line 211 of file gdbstub.c.

211 {
212 if ( stub->len != 1 + GDBMACH_SIZEOF_REGS * 2 ) {
214 return;
215 }
216 gdbstub_from_hex_buf ( ( char * ) stub->regs, &stub->payload [ 1 ], GDBMACH_SIZEOF_REGS );
218}
static void gdbstub_send_ok(struct gdbstub *stub)
Definition gdbstub.c:156
static void gdbstub_from_hex_buf(char *dst, char *src, int lenbytes)
Definition gdbstub.c:85
static void gdbstub_send_errno(struct gdbstub *stub, int errno)
Definition gdbstub.c:197

References GDBMACH_SIZEOF_REGS, gdbstub_from_hex_buf(), gdbstub_send_errno(), gdbstub_send_ok(), POSIX_EINVAL, and stub.

Referenced by gdbstub_rx_packet().

◆ gdbstub_read_mem()

void gdbstub_read_mem ( struct gdbstub * stub)
static

Definition at line 220 of file gdbstub.c.

220 {
221 unsigned long args [ 2 ];
222 if ( !gdbstub_get_packet_args ( stub, args, sizeof args / sizeof args [ 0 ], NULL ) ) {
224 return;
225 }
226 args [ 1 ] = ( args [ 1 ] < SIZEOF_PAYLOAD / 2 ) ? args [ 1 ] : SIZEOF_PAYLOAD / 2;
227 gdbstub_to_hex_buf ( stub->payload, ( char * ) args [ 0 ], args [ 1 ] );
228 stub->len = args [ 1 ] * 2;
230}
#define NULL
NULL pointer (VOID *)
Definition Base.h:322
static int gdbstub_get_packet_args(struct gdbstub *stub, unsigned long *args, int nargs, int *stop_idx)
Definition gdbstub.c:172

References gdbstub_get_packet_args(), gdbstub_send_errno(), gdbstub_to_hex_buf(), gdbstub_tx_packet(), NULL, POSIX_EINVAL, SIZEOF_PAYLOAD, and stub.

Referenced by gdbstub_rx_packet().

◆ gdbstub_write_mem()

void gdbstub_write_mem ( struct gdbstub * stub)
static

Definition at line 232 of file gdbstub.c.

232 {
233 unsigned long args [ 2 ];
234 int colon;
235 if ( !gdbstub_get_packet_args ( stub, args, sizeof args / sizeof args [ 0 ], &colon ) ||
236 colon >= stub->len || stub->payload [ colon ] != ':' ||
237 ( stub->len - colon - 1 ) % 2 != 0 ) {
239 return;
240 }
241 gdbstub_from_hex_buf ( ( char * ) args [ 0 ], &stub->payload [ colon + 1 ], ( stub->len - colon - 1 ) / 2 );
243}

References gdbstub_from_hex_buf(), gdbstub_get_packet_args(), gdbstub_send_errno(), gdbstub_send_ok(), POSIX_EINVAL, and stub.

Referenced by gdbstub_rx_packet().

◆ gdbstub_continue()

void gdbstub_continue ( struct gdbstub * stub,
int single_step )
static

Definition at line 245 of file gdbstub.c.

245 {
246 gdbreg_t pc;
247 if ( stub->len > 1 && gdbstub_get_packet_args ( stub, &pc, 1, NULL ) ) {
248 gdbmach_set_pc ( stub->regs, pc );
249 }
250 gdbmach_set_single_step ( stub->regs, single_step );
251 stub->exit_handler = 1;
252 /* Reply will be sent when we hit the next breakpoint or interrupt */
253}
unsigned long gdbreg_t
Definition gdbmach.h:17
static void gdbmach_set_pc(gdbreg_t *regs, gdbreg_t pc)
Definition gdbmach.h:57
static void gdbmach_set_single_step(gdbreg_t *regs, int step)
Definition gdbmach.h:61

References gdbmach_set_pc(), gdbmach_set_single_step(), gdbstub_get_packet_args(), NULL, and stub.

Referenced by gdbstub_rx_packet().

◆ gdbstub_breakpoint()

void gdbstub_breakpoint ( struct gdbstub * stub)
static

Definition at line 255 of file gdbstub.c.

255 {
256 unsigned long args [ 3 ];
257 int enable = stub->payload [ 0 ] == 'Z' ? 1 : 0;
258 int rc;
259
260 if ( !gdbstub_get_packet_args ( stub, args, sizeof args / sizeof args [ 0 ], NULL ) ) {
262 return;
263 }
264 if ( ( rc = gdbmach_set_breakpoint ( args [ 0 ], args [ 1 ],
265 args [ 2 ], enable ) ) != 0 ) {
266 /* Not supported */
267 stub->len = 0;
269 return;
270 }
272}
struct arbelprm_rc_send_wqe rc
Definition arbel.h:3
int gdbmach_set_breakpoint(int type, unsigned long addr, size_t len, int enable)
Set hardware breakpoint.
Definition gdbmach.c:134

References gdbmach_set_breakpoint(), gdbstub_get_packet_args(), gdbstub_send_errno(), gdbstub_send_ok(), gdbstub_tx_packet(), NULL, POSIX_EINVAL, rc, and stub.

Referenced by gdbstub_rx_packet().

◆ gdbstub_rx_packet()

void gdbstub_rx_packet ( struct gdbstub * stub)
static

Definition at line 274 of file gdbstub.c.

274 {
275 switch ( stub->payload [ 0 ] ) {
276 case '?':
278 break;
279 case 'g':
281 break;
282 case 'G':
284 break;
285 case 'm':
287 break;
288 case 'M':
290 break;
291 case 'c': /* Continue */
292 case 'k': /* Kill */
293 case 's': /* Step */
294 case 'D': /* Detach */
295 gdbstub_continue ( stub, stub->payload [ 0 ] == 's' );
296 if ( stub->payload [ 0 ] == 'D' ) {
298 }
299 break;
300 case 'Z': /* Insert breakpoint */
301 case 'z': /* Remove breakpoint */
303 break;
304 default:
305 stub->len = 0;
307 break;
308 }
309}
static void gdbstub_breakpoint(struct gdbstub *stub)
Definition gdbstub.c:255
static void gdbstub_continue(struct gdbstub *stub, int single_step)
Definition gdbstub.c:245
static void gdbstub_read_mem(struct gdbstub *stub)
Definition gdbstub.c:220
static void gdbstub_read_regs(struct gdbstub *stub)
Definition gdbstub.c:205
static void gdbstub_write_regs(struct gdbstub *stub)
Definition gdbstub.c:211
static void gdbstub_write_mem(struct gdbstub *stub)
Definition gdbstub.c:232
static void gdbstub_report_signal(struct gdbstub *stub)
Definition gdbstub.c:201

References gdbstub_breakpoint(), gdbstub_continue(), gdbstub_read_mem(), gdbstub_read_regs(), gdbstub_report_signal(), gdbstub_send_ok(), gdbstub_tx_packet(), gdbstub_write_mem(), gdbstub_write_regs(), and stub.

Referenced by gdbstub_state_cksum2().

◆ gdbstub_parse()

void gdbstub_parse ( struct gdbstub * stub,
char ch )
static

Definition at line 364 of file gdbstub.c.

364 {
365 stub->parse ( stub, ch );
366}

References ch, and stub.

Referenced by gdbstub_handler().

◆ gdbstub_handler()

void gdbstub_handler ( int signo,
gdbreg_t * regs )

Interrupt handler.

@signo POSIX signal number @regs CPU register snapshot

Definition at line 372 of file gdbstub.c.

372 {
373 char packet [ SIZEOF_PAYLOAD + 4 ];
374 size_t len, i;
375
376 /* A transport must be set up */
377 if ( !stub.trans ) {
378 return;
379 }
380
381 stub.signo = signo;
382 stub.regs = regs;
383 stub.exit_handler = 0;
385 while ( !stub.exit_handler && ( len = stub.trans->recv ( packet, sizeof ( packet ) ) ) > 0 ) {
386 for ( i = 0; i < len; i++ ) {
387 gdbstub_parse ( &stub, packet [ i ] );
388 }
389 }
390}
static void gdbstub_parse(struct gdbstub *stub, char ch)
Definition gdbstub.c:364
struct i386_regs regs
Definition registers.h:1

References gdbstub_parse(), gdbstub_report_signal(), len, regs, gdbstub::signo, SIZEOF_PAYLOAD, and stub.

Referenced by gdbmach_handler().

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

392 {
393 struct gdb_transport *trans;
394
396 if ( strcmp ( trans->name, name ) == 0 ) {
397 return trans;
398 }
399 }
400 return NULL;
401}
const char * name
Definition ath9k_hw.c:1986
#define GDB_TRANSPORTS
Definition gdbstub.h:51
int strcmp(const char *first, const char *second)
Compare strings.
Definition string.c:174
A transport mechanism for the GDB protocol.
Definition gdbstub.h:21
const char * name
Transport name.
Definition gdbstub.h:23
#define for_each_table_entry(pointer, table)
Iterate through all entries within a linker table.
Definition tables.h:386

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

403 {
404 stub.trans = trans;
405 stub.payload = &stub.buf [ 1 ];
406 gdbmach_init();
408}
static void gdbmach_breakpoint(void)
Definition gdbmach.h:66
void gdbmach_init(void)
Initialise GDB.
Definition gdbmach.c:242

References gdbmach_breakpoint(), gdbmach_init(), and stub.

Referenced by gdbstub_exec().

Variable Documentation

◆ stub