Page MenuHomeFreeBSD

gdb(4): Don't escape GDB special characters at application layer
ClosedPublic

Authored by cem on Sep 30 2020, 12:11 AM.
Tags
None
Referenced Files
F103442362: D26599.id77664.diff
Mon, Nov 25, 2:16 AM
Unknown Object (File)
Mon, Nov 11, 10:37 PM
Unknown Object (File)
Wed, Oct 30, 8:49 AM
Unknown Object (File)
Sep 20 2024, 9:03 AM
Unknown Object (File)
Sep 19 2024, 9:09 PM
Unknown Object (File)
Sep 18 2024, 3:39 PM
Unknown Object (File)
Sep 18 2024, 4:42 AM
Unknown Object (File)
Sep 17 2024, 10:44 PM
Subscribers

Details

Summary

In r351368, we introduced this XML- and GDB-encoded data. The protocol
'offset' should reflex the logical XML data offset, but unfortunately we
counted the GDB escapes as well.

In fact, we cannot safely do GDB character escaping at this layer at
all, because we don't know what will be flushed in a packet. It is
bogus to send only the first character of a two-character escape
sequence.

This patch "corrects" the problem by squashing these characters in the
transmitted XML document. It would be nice to transmit the characters
faithfully, but that is a more complicated change. Thread names are a
nice convenience feature for the GDB client, but one can always inspect
td_name or p_comm directly to find the true name.

Reported by: Ka Ho Ng <khng300 AT gmail.com>

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

cem requested review of this revision.Sep 30 2020, 12:11 AM

Tested. So far it runs well on my setup.

This revision is now accepted and ready to land.Sep 30 2020, 2:22 AM

Seems fine, especially as we already squash other characters instead of
escaping them.

It feels like we should be able to handle this in qXfer_drain by doing
the gdb escape there and then just not draining the whole qxfer buffer
if we run out of space in the tx buffer. However, I haven't looked
around enough to know whether that'd actually work.

There's definitely some way to make it work, it just adds complexity and IIRC may require limiting our typical (no escaped characters) packet size to half of our advertised max packet size (in case the entire packet needs escaping). Or fragmenting any packets that go over into a normal packet and a tiny extra packet (this seems worse than just using half advertised packet size).

Seems reasonable to me.