Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

gdb reverse stepping - not supported in Linux?

Tags:

linux

gcc

gdb

(gdb) reverse-step
Target child does not support this command.

This is in Linux 2.6.18

Does the kernel not support it? Is there a special gcc arg I need?

 gcc --version
gcc (GCC) 4.1.2 20080704 (Red Hat 4.1.2-52)
like image 598
Edward Strange Avatar asked Oct 22 '22 23:10

Edward Strange


People also ask

How do you reverse step in gdb?

The command would be " reverse-step ", or " reverse-next ". If you run into the error: Target child does not support this command. then try adding target record at the beginning of execution, after starting run . Edit: Since GDB 7.6 target record is deprecated, use target record-full instead.

Can you move backwards in gdb?

If the target environment supports it, gdb can allow you to “rewind” the program by running it backward. A target environment that supports reverse execution should be able to “undo” the changes in machine state that have taken place as the program was executing normally. Variables, registers etc.

What is the difference between Step and Next in gdb?

To execute one line of code, type "step" or "s". If the line to be executed is a function call, gdb will step into that function and start executing its code one line at a time. If you want to execute the entire function with one keypress, type "next" or "n".


1 Answers

I'm no expert, but it appears that maybe you forgot to enable gdb recording.

(gdb) record
(gdb) continue
(gdb) reverse-continue
Continuing.

For example, this worked for me

Breakpoint 1, main (argc=1, argv=0x7ffe673b5638) at ...
7     int lol = 0xbeefface;
(gdb) record
(gdb) continue
Continuing.

Program stopped.
0x00007f710c188746 in __GI__exit ...
(gdb) reverse-continue
Continuing.
...
No more reverse-execution history.
main (argc=1, argv=0x7ffe673b5638) at ...
7     int lol = 0xbeefface;

I was able to reproduce your issue with

Breakpoint 1, main (argc=1, argv=0x7ffeb7945198) at main.c:7
7     int lol = 0xbeefface;
(gdb) b _exit
Breakpoint 2 at 0x7fc62dbb8710: file ...
(gdb) continue
Continuing.

Breakpoint 2, __GI__exit ...
(gdb) reverse-continue
Target native does not support this command.
like image 97
activedecay Avatar answered Oct 26 '22 23:10

activedecay