Reputation: 21
I am quite new to the area of compilers. I'm using gcc and I want to get execution history of a program for a particular run i.e. only those statements which are actually executed in the last run.
Is it possible with gdb? I couldn't get relevant options in gdb which could output executed statements. Or is there any other way of obtaining execution history?
Regards, Nikhil.
Upvotes: 2
Views: 1234
Reputation: 97948
You can use set history save
command to start recording history. This can be written into the ~/.gdbinit
file. Look at the docs for more information.
Upvotes: 0
Reputation: 5347
Process Record May be what you're looking for. The link has a quick tutorial and an overview of the functionality.
From the linked wiki page:
Compile this program with -g, and load it into gdb, then do the following:
(gdb) break main (gdb) run (gdb) record
This will turn on process recording, which will now record all subsequent instructions executed by the program being debugged.
Note that you can start process recording at any point (not just at main). You may choose to start it later, or even earlier. The only restriction is that your program has to be running (so you have to type "run" before "record"). If you want to start recording from the very first instruction of your program, you can do it like this:
(gdb) break _start (gdb) run (gdb) record
Hope this helps.
Upvotes: 6