-
Notifications
You must be signed in to change notification settings - Fork 218
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
implement reverse execution for gdb #1037
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Trass3r Thank you for making this contribution!
We will want to check if gdb
can do reverse commands. You will need to execute -list-target-features
and check for reverse.
This will be done in src/MICore/CommandFactories/MICommandFactory.cs
as an abstract method, and for cldbg/lldb it will be
return Task.FromResult(new Results(ResultClass.None));
and for gdb it will be:
Results results = await _debugger.CmdAsync("-list-target-features", ResultClass.done);
return results;
You will want to use the results to see if we have reverse
. This will be used for IDebugReversibleEngineProgram160.CanReverse
The problem is we need to advertise the capability before the target is even launched. |
There is a |
Drafted something. |
6482b1b
to
6b2d9f1
Compare
Done, it's a lot cleaner now. |
6b2d9f1
to
0b877e0
Compare
Done. |
0b877e0
to
a0c9fb8
Compare
@Trass3r For the launch scenario, do you have |
No. Even in gdb itself there are different methods to record and then there's the next level rr tool which is what I use. |
Do we need to worry that someone would enable reverse execution in the middle of debugging? We only check and enable Reverse functionality in Launch/Attach. Is there a set of commands we can capture to resend the capabilities? |
That's a good question, is it possible with the gdb way? |
I've never used RR, but its good to know that it works in that scenario.
See suggestion in #1037 (comment) |
I see, makes sense. |
Hello, I'm using also UndoDB which record from the beginning, but with gdb I only record specific portion of code. |
@Trass3r Ignore my suggestion above about capturing commands for users in Associated stop string:
|
FYI from https://sourceware.org/gdb/onlinedocs/gdb/GDB_002fMI-Async-Records.html:
Execution log recording was either started or stopped on an inferior. The id is the GDB identifier of the thread group corresponding to the affected inferior. The method field indicates the method used to record execution. If the method in use supports multiple recording formats, format will be present and contain the currently used format. See Process Record and Replay, for existing method and format values. |
Something like this (see commit). The question is how to proceed from there. |
…enever the process is stopped
8c09cd2
to
d84213d
Compare
@gregg-miskelly Could you also approve the workflow here? I don't know why it suddenly asks for this again for every PR. |
It looks like someone did this for you already right? Or did I miss something? |
@gregg-miskelly Looks like your review unlocked it. Now that I pushed the next commit it's |
Sorry, that was me. I had a moment during my break to poke the "Approve button". I just approved it again. |
@Trass3r I see that your PR still has some TODO comments. Would you consider this ready for a full review? Or are you still working on it.? |
private async Task UpdateTargetFeatures() | ||
{ | ||
TargetFeatures = await MICommandFactory.GetTargetFeatures(); | ||
// TODO: notify OpenDebugAD7 to run AD7DebugSession.UpdateCapabilities |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't know how. Just an idea to make things more asynchronous rather than checking reversibility on every stop event.
But yeah, no major further development planned. Just want to get these old PRs merged.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it. In that case I would probably suggest changing the comment to something like:
// NOTE: Currently OpenDebugAD7 polls to decide if we can reverse execute. It might make sense to push an event. If we ever create such an event, probably makes sense to use it here also.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok. Btw the events are RecordStartedEvent and RecordStoppedEvent for gdb
. And we check it after starting up to support rr
.
Btw, for testing: int main()
{
int i = 0;
++i;
++i;
return i;
} $ gdb --batch -ex 'b main' -ex r -ex n -ex 'p i' -ex 'record full' -ex n -ex 'p i' -ex n -ex 'p i' -ex n -ex 'p i' -ex 'reverse-next' -ex 'p i' -ex 'reverse-next' -ex 'p i' -ex 'reverse-next' -ex 'p i' test
3 int i = 0;
completed.
+p i
$1 = 17
+record full
+target record-full
+n
4 ++i;
completed.
+p i
$2 = 0
+n
5 ++i;
completed.
+p i
$3 = 1
+n
6 return i;
completed.
+p i
$4 = 2
+reverse-next
+next
5 ++i;
completed.
+p i
$5 = 1
+reverse-next
+next
4 ++i;
completed.
+p i
$6 = 0
+reverse-next
+next
No more reverse-execution history.
main () at /tmp/test.cpp:3
3 int i = 0;
completed.
+p i
$7 = 17 |
Any ideas for improving the UX when reaching the boundaries of the recorded data: |
First, I would suggest trying a quick hack where you patch up the properties in If you can get that to a place you want, then it will give me a better idea in the MIEngine side. |
Well several issues. And VSCode ignores the {"type":"event","event":"stopped","body":{"reason":"exception","description":"Unknown","threadId":25608,"text":"Unknown stopping event","allThreadsStopped":true,"source":{"name":"test.cpp","path":"/tmp/test.cpp","sources":[],"checksums":[]},"line":3,"column":1},"seq":960} I also created a gdb ticket for the missing reason: https://sourceware.org/bugzilla/show_bug.cgi?id=29260 |
@gregg-miskelly but I guess that issue can be captured in a ticket and fixed separately?! |
Finally fixed. |
Hi, is there any update on this issue? Thanks |
Nope it got stuck in review hell. |
fixes microsoft/vscode-cpptools#2130
See microsoft/vscode-cpptools#2130 (comment)