Uh oh!
There was an error while loading. Please reload this page.
implement reverse execution for gdb - #1037
Conversation
Andrew Wang (WardenGnaw)
left a comment
There was a problem hiding this comment.
Trass3r (@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
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Trass3r (Trass3r)
commented
Aug 27, 2020
The problem is we need to advertise the capability before the target is even launched. |
Andrew Wang (WardenGnaw)
commented
Aug 27, 2020
There is a |
Trass3r (Trass3r)
commented
Aug 27, 2020
Drafted something. |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
6482b1b to
6b2d9f1CompareDone, it's a lot cleaner now. |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
6b2d9f1 to
0b877e0CompareTrass3r (Trass3r)
commented
Sep 5, 2020
Done. |
0b877e0 to
a0c9fb8CompareAndrew Wang (WardenGnaw)
commented
Sep 16, 2020
Trass3r (@Trass3r) For the launch scenario, do you have |
Trass3r (Trass3r)
commented
Sep 16, 2020
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. |
Andrew Wang (WardenGnaw)
commented
Sep 16, 2020
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? |
Trass3r (Trass3r)
commented
Sep 16, 2020
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) |
Trass3r (Trass3r)
commented
Sep 16, 2020
I see, makes sense. |
Pierre Payen (pirpyn)
commented
Sep 16, 2020
Hello, I'm using also UndoDB which record from the beginning, but with gdb I only record specific portion of code. |
Trass3r (@Trass3r) Ignore my suggestion above about capturing commands for users in Associated stop string: |
Gregg Miskelly (gregg-miskelly)
commented
Sep 16, 2020
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. |
8c09cd2 to
d84213dCompareTrass3r (Trass3r)
commented
Jun 15, 2022
Gregg Miskelly (@gregg-miskelly) Could you also approve the workflow here? I don't know why it suddenly asks for this again for every PR. |
Uh oh!
There was an error while loading. Please reload this page.
Gregg Miskelly (gregg-miskelly)
commented
Jun 15, 2022
Uh oh!
There was an error while loading. Please reload this page.
Gregg Miskelly (gregg-miskelly)
commented
Jun 15, 2022
It looks like someone did this for you already right? Or did I miss something? |
Trass3r (Trass3r)
commented
Jun 16, 2022
Gregg Miskelly (@gregg-miskelly) Looks like your review unlocked it. Now that I pushed the next commit it's |
Andrew Wang (WardenGnaw)
commented
Jun 16, 2022
Sorry, that was me. I had a moment during my break to poke the "Approve button". I just approved it again. |
Gregg Miskelly (gregg-miskelly)
commented
Jun 16, 2022
Trass3r (@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.
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.
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.
Ok. Btw the events are RecordStartedEvent and RecordStoppedEvent for gdb. And we check it after starting up to support rr.
Uh oh!
There was an error while loading. Please reload this page.
Trass3r (Trass3r)
commented
Jun 17, 2022
Btw, for testing: intmain()
{
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 |
Trass3r (Trass3r)
commented
Jun 17, 2022
Any ideas for improving the UX when reaching the boundaries of the recorded data: |
Gregg Miskelly (gregg-miskelly)
commented
Jun 17, 2022
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 |
Trass3r (Trass3r)
commented
Sep 17, 2022
Gregg Miskelly (@gregg-miskelly) but I guess that issue can be captured in a ticket and fixed separately?! |
Trass3r (Trass3r)
commented
Jan 18, 2023
Finally fixed. |
Dusan Slijepcevic (dslijepcevic)
commented
Apr 18, 2023
Hi, is there any update on this issue? Thanks |
Trass3r (Trass3r)
commented
Apr 4, 2024
Nope it got stuck in review hell. |
I would like support for reverse debugging for my project, do you have a fork I could test? My project is a GDB stub that attaches to a HDL simulator written in SystemVerilog. On the level of the GDB remote serial protocol, this capability is exposed by responding with I got as far a checking whether I get the expected response when asking with I will also investigate another path, but it is ARM specific, so not really a good fit for my project which is centered around RISC-V but may support other CPU architectures with some generalization effort.
I already have a setup with QEMU ARM running a Zephyr OS application, I can use for testing. |


fixesmicrosoft/vscode-cpptools#2130
See microsoft/vscode-cpptools#2130 (comment)