diff options
author | Conrad Meyer <cem@FreeBSD.org> | 2019-10-17 22:37:25 +0000 |
---|---|---|
committer | Conrad Meyer <cem@FreeBSD.org> | 2019-10-17 22:37:25 +0000 |
commit | 6310546dba1093b8999afddcb04bff6f509b5114 (patch) | |
tree | 3f0854f4a2ee3ba6bca7389402f9656523831dfd /sys/gdb/gdb_packet.c | |
parent | a211ca52cd8de55708139678afafc7afcd4eedea (diff) | |
download | src-6310546dba1093b8999afddcb04bff6f509b5114.tar.gz src-6310546dba1093b8999afddcb04bff6f509b5114.zip |
gdb(4): Implement support for NoAckMode
When the underlying debugport transport is reliable, GDB's additional
checksums and acknowledgements are redundant. NoAckMode eliminates the
the acks and allows us to skip checking RX checksums. The GDB packet
framing does not change, so unfortunately (valid) checksums are still
included as message trailers.
The gdb(4) stub in FreeBSD advertises support for the feature in response to
the client's 'qSupported' request IFF the current debugport has the
gdb_dbfeatures flag GDB_DBGP_FEAT_RELIABLE set. Currently, only netgdb(4)
supports this feature.
If the remote GDB client supports the feature and does not have it disabled
via a GDB configuration knob, it may instruct our gdb(4) stub to enter
NoAckMode. Unless and until it issues that command, we must continue to
transmit acks as usual (and for now, we continue to wait until we receive
them as well, even if we know the debugport is on a reliable transport).
In the kernel sources, the sense of the flag representing the state of the
feature is reversed from that of the GDB command. (I.e., it is
'gdb_ackmode', not 'gdb_noackmode.') This is to avoid confusing double-
negative conditions.
For reference, see:
* https://sourceware.org/gdb/onlinedocs/gdb/Packet-Acknowledgment.html
* https://sourceware.org/gdb/onlinedocs/gdb/General-Query-Packets.html#QStartNoAckMode
Reviewed by: jhb, markj (both earlier version)
Differential Revision: https://reviews.freebsd.org/D21761
Notes
Notes:
svn path=/head/; revision=353702
Diffstat (limited to 'sys/gdb/gdb_packet.c')
-rw-r--r-- | sys/gdb/gdb_packet.c | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/sys/gdb/gdb_packet.c b/sys/gdb/gdb_packet.c index e740b2c9442e..9a85184eb49a 100644 --- a/sys/gdb/gdb_packet.c +++ b/sys/gdb/gdb_packet.c @@ -134,18 +134,28 @@ gdb_rx_begin(void) /* Bail out on a buffer overflow. */ if (c != '#') { - gdb_cur->gdb_putc('-'); + gdb_nack(); return (ENOSPC); } + /* + * In Not-AckMode, we can assume reliable transport and neither + * need to verify checksums nor send Ack/Nack. + */ + if (!gdb_ackmode) + break; + c = gdb_getc(); cksum -= (C2N(c) << 4) & 0xf0; c = gdb_getc(); cksum -= C2N(c) & 0x0f; - gdb_cur->gdb_putc((cksum == 0) ? '+' : '-'); - if (cksum != 0) + if (cksum == 0) { + gdb_ack(); + } else { + gdb_nack(); printf("GDB: packet `%s' has invalid checksum\n", gdb_rxbuf); + } } while (cksum != 0); gdb_rxp = gdb_rxbuf; @@ -336,6 +346,14 @@ gdb_tx_end(void) gdb_cur->gdb_putc(N2C(c)); getack: + /* + * In NoAckMode, it is assumed that the underlying transport is + * reliable and thus neither conservant sends acknowledgements; + * there is nothing to wait for here. + */ + if (!gdb_ackmode) + break; + c = gdb_getc(); } while (c != '+'); |