Page MenuHomePhabricator

gdb-remote: Fix checksum verification for messages with escape chars
ClosedPublic

Authored by labath on Mar 27 2018, 5:48 AM.

Details

Summary

We've had a mismatch in the checksum computation between the sender and
receiver. The sender computed the payload checksum using the wire
encoding of the packet, while the receiver did this after expanding
un-escaping and expanding run-length-encoded sequences. This resulted in
communication breakdown if packets using these feature were sent in the
ack mode.

Normally, this did not cause any issues since the only packet we send in
the ack-mode is the QStartNoAckMode packet, but I ran into this when
debugging the lldb-server tests which (for better or worse) don't use
this mode.

According to the gdb-remote documentation "The two-digit checksum is computed as
the modulo 256 sum of all characters between the leading ‘$’ and the
trailing ‘#’", it seems that our sender is doing the right thing here.
Therefore, I fix the receiver the match the sender behavior and add a
test.

With this bug fixed, we can see that lldb-server is sending a stop-reply
after receiving the "k" in the same way as debugserver does (but we
weren't detecting this because at that point the connection was dead
already). I fix that expectation as well.

Diff Detail

Repository
rL LLVM

Event Timeline

labath created this revision.Mar 27 2018, 5:48 AM
clayborg accepted this revision.Mar 27 2018, 9:34 AM
This revision is now accepted and ready to land.Mar 27 2018, 9:34 AM
This revision was automatically updated to reflect the committed changes.