Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RFC/WIP] GDB support for replay diversions #2877

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

Bob131
Copy link
Contributor

@Bob131 Bob131 commented May 29, 2021

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 send vReplayDiversion:1 to request a switch to a diversion session, and vReplayDiversion: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 on continue) but could have commands like replay-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).

  • Expose seeking/checkpoints/bookmarks: GDB has bits of support for these (seeking and bookmarks likely just need remote protocol extensions, and the core is checkpoint-aware). This would eliminate the need for about half of GdbCommand.cc, allow (eventual?) removal of some of the GDB macros and hopefully bring a more consistent interface.
  • info replay: Replace elapsed-time, when, when-ticks and when-tid with an info replay subcommand. Strictly speaking, this doesn't need support from GDB, but it would be a good complement to GDB's info record subcommand and GDB support would make it an interface consistent with other (hypothetical) GDB targets.

Updates the test harness to use $REPLAY_ARGS as additional arguments
to 'rr replay'.
This commit adds support for the vReplayDiversion extension to the GDB
remote protocol. This protocol extension moves control over diversion
sessions to GDB, allowing it to explicitly model diversion state when
considering things like UI heuristics or scheduling decisions,
expose such state to end users and scripts, or make various aspects
user-configurable.

The benefit to rr in the future will be a smoothing out of several UI
wrinkles and (perhaps eventually) the removal of some of the hackier,
more ad-hoc parts of the rr/GDB interface. Some of these benefits will
be had in the immediate-term; however, this will also come with some
regressions until GDB all of the logic needed for feature-parity.

(An instance of this is apparent in the number of test cases no longer
passing due to this commit; GDB having control over diversion
entrance/exit means rr commands can no longer trigger a diversion exit
themselves. A future commit will have these commands present an error
to the user instead of corrupting state, but this may well still
present a regression to some users.)
If the client GDB supports the vReplayDiversion protocol extension
then diversion sessions are controlled explicitly by the client;
allowing rr commands to end a diversion session under GDB's nose will
corrupt the implicit shared state.

This commit modifies the command handler to instead present an error
message to the user if a command wanted to end a GDB-requested
diversion.
@rocallahan
Copy link
Collaborator

vReplayDiversion seems like a good idea, if the GDB developers are receptive. We will need GDB commands to explicitly enter and exit diversions, at least for our tests.

let me know if you'd prefer separate issue(s).

Those sound good too but yes, please make them separate issues.

@GitMensch
Copy link
Contributor

I've not yet submitted my proposal to the GDB mailing list

@Bob131 Was there a proposal sent to gdb-patches@sourceware.org? I did not found any mention of vReplayDiversion there yet, but also think your approach is a good idea.

@Bob131
Copy link
Contributor Author

Bob131 commented Mar 16, 2022 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants