[RFC/WIP] GDB support for replay diversions #2877
Draft
+113
−23
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I've been thinking about some of the awkwardness that currently exists around diversions: scheduling issues touched on in #2840, hidden state confusing GDB (e.g. #2867) and users (e.g. #1968) and the hacks and heuristics involved in trying to determine when diversion sessions should be set up/torn down. These problems aren't intractable, but it seems like they'll continue to crop up until GDB gains explicit support for a notion similar to that of rr's diversion session.
This patchset implements a (yet to be) proposed extension to the GDB remote protocol that would move control over diversion state out of rr and into GDB. The protocol introduces a new protocol feature and packet:
vReplayDiversion
. GDB can sendvReplayDiversion:1
to request a switch to a diversion session, andvReplayDiversion:0
to end a diversion session. rr may additionally notify GDB of a premature diversion session exit by sending an inferior-exit stop packet. The GDB-side implementation mimics rr's logic (vReplayDiversion:1
on inferior call,vReplayDiversion:0
oncontinue
) but could have commands likereplay-diversion {enter,exit}
in the future.I've not yet submitted my proposal to the GDB mailing list; it seemed like a good idea to solicit feedback from the rr developers first, to make sure the approach is considered appropriate on the rr side. Given that I don't know if any such proposal will be accepted for GDB or how much any accepted proposal may differ from above, I've submitted this as a draft PR for the time being.
Potential future directions
I'm also interested in feedback on the following ideas. I understand a discussion on these may be out of scope for this PR; let me know if you'd prefer separate issue(s).
GdbCommand.cc
, allow (eventual?) removal of some of the GDB macros and hopefully bring a more consistent interface.info replay
: Replaceelapsed-time
,when
,when-ticks
andwhen-tid
with aninfo replay
subcommand. Strictly speaking, this doesn't need support from GDB, but it would be a good complement to GDB'sinfo record
subcommand and GDB support would make it an interface consistent with other (hypothetical) GDB targets.