This is the mail archive of the mailing list for the GDB project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: step through entire file, saving each line to file?

On 22/02/07, Dexter Riley <> wrote:

hello! I'd like to step through an entire program, and dump each executed line fo file. I can do gdb myprogram > tee savefile (gdb)display/i $pc (gdb)start (gdb)si

and it displays the currently executed line.  I'd like the equivalent of
typing si multiple times; trying
(gdb) si 1000
apparently steps through 1000 lines and shows me THAT line.

Is there some nifty si or shell trick to do this?  Sorry for the newbie
question, but any help would be greatly appreciated.

You should be able to write a GDB command file to do it. I think this should work:

myprogram > tee savefile
display/i $pc

# Loop while the program hasn't finished
while($_exitcode == (void *)0)

Although I haven't tested that, but if it is not that it is something
close. You can read up on command files in the manual, but basically,
write a file with the above in, then run GDB with the -x option.

eg: gdb myprogram -x myscript

Hopefully that will work. Appologies if I'm wrong, it's been a long
day of memory leak fixing  :(


Thanks very much,
View this message in context:
Sent from the gdb - General mailing list archive at

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]