diff options
author | phk <phk@FreeBSD.org> | 2006-05-26 11:52:20 +0000 |
---|---|---|
committer | phk <phk@FreeBSD.org> | 2006-05-26 11:52:20 +0000 |
commit | b877360bf761c7a9488d8f04207990316e499df0 (patch) | |
tree | 059d958761b5497751a982d8621e79eb95d28614 /sys/gdb/gdb_packet.c | |
parent | 9d2a9f23a5649170b5d45c9f8a5ccc7997234ff9 (diff) | |
download | FreeBSD-src-b877360bf761c7a9488d8f04207990316e499df0.zip FreeBSD-src-b877360bf761c7a9488d8f04207990316e499df0.tar.gz |
Wrap our drivers gdb_getc() function so that if it returns -1 we
try again. This way it matches the console behaviour and allows us
to share more code.
Diffstat (limited to 'sys/gdb/gdb_packet.c')
-rw-r--r-- | sys/gdb/gdb_packet.c | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/sys/gdb/gdb_packet.c b/sys/gdb/gdb_packet.c index a4bbe24..753c9b7 100644 --- a/sys/gdb/gdb_packet.c +++ b/sys/gdb/gdb_packet.c @@ -48,6 +48,21 @@ char *gdb_txp = NULL; /* Used in inline functions. */ #define N2C(n) (((n) < 10) ? (n) + '0' : (n) + 'a' - 10) /* + * Get a single character + */ + +static int +gdb_getc(void) +{ + int c; + + do + c = gdb_cur->gdb_getc(); + while (c == -1); + return (c); +} + +/* * Functions to receive and extract from a packet. */ @@ -62,14 +77,14 @@ gdb_rx_begin(void) * Wait for the start character, ignore all others. * XXX needs a timeout. */ - while ((c = gdb_cur->gdb_getc()) != '$') + while ((c = gdb_getc()) != '$') ; /* Read until a # or end of buffer is found. */ cksum = 0; gdb_rxsz = 0; while (gdb_rxsz < sizeof(gdb_rxbuf) - 1) { - c = gdb_cur->gdb_getc(); + c = gdb_getc(); if (c == '#') break; gdb_rxbuf[gdb_rxsz++] = c; @@ -84,9 +99,9 @@ gdb_rx_begin(void) return (ENOSPC); } - c = gdb_cur->gdb_getc(); + c = gdb_getc(); cksum -= (C2N(c) << 4) & 0xf0; - c = gdb_cur->gdb_getc(); + c = gdb_getc(); cksum -= C2N(c) & 0x0f; gdb_cur->gdb_putc((cksum == 0) ? '+' : '-'); if (cksum != 0) @@ -245,7 +260,7 @@ gdb_tx_end(void) c = cksum & 0x0f; gdb_cur->gdb_putc(N2C(c)); - c = gdb_cur->gdb_getc(); + c = gdb_getc(); } while (c != '+'); return (0); |