GDB record
Recent versions of GDB have the ability to record traces of program executions. The trace is created as the program runs and allows reverse debugging operations.
GDB record tracks all changes from each machine instruction executed. This means that lots of data is log and the process can run very slowly. It also means that the debugger needs to know the side-effects of each instruction. Some complex instructions are not supported (like SIMD instructions).
More details on GDB record:
Use
To record execution, debug your program.
gdb ./a.out
Begin execution:
start
You may now begin recording:
record
All execution from this point on will be recorded and can be replayed with the reverse debugging commands.
Troubleshooting
GDB record can be difficult to work with, since the instruction set it supports is limited. While this improves with each version of GDB, you can try restricting the instruction set targeted by the compiler. Most compilers have options or command line arguments to turn of processor feature support.
gcc -g -mno-avx -mno-avx2 test.c #disable AVX
Sometimes, the loader or standard libraries use unsupported instructions. This can be difficult to resolve, but you can try statically linking, or resolving links at startup. For example:
export LD_BIND_NOW=1 #might be setevn LD_BIND_NOW=1 for your machine
gdb -g test.c
You can also try compiling in 32bit mode:
gcc -g -m32 test.c
Try it out
Try using GDB record on the simpletree demo. You can add bugs by removing malloc
s, adding incorrect free
s, or removing initializations.