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
Unknown Object (File)
Wed, Jul 3, 4:44 PM
Unknown Object (File)
Wed, Jul 3, 4:53 AM
Unknown Object (File)
Wed, Jul 3, 4:44 AM
Unknown Object (File)
Mon, Jul 1, 5:21 PM
Unknown Object (File)
May 10 2024, 4:08 AM
Unknown Object (File)
Apr 17 2024, 10:26 AM
Unknown Object (File)
Mar 14 2024, 7:23 AM
Unknown Object (File)
Mar 14 2024, 7:23 AM
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.