automated trace output with gdb

Michael Snyder
Wed Oct 29 17:17:00 GMT 2008

Edward Peschko wrote:
> All,
> Solaris' dbx had the ability to record runs of programs - ie: you
> could say 'trace step' and you could then see - printed out - all the
> lines of code execute as the debugger executed them..
> Does gdb have something similar? I see the concept of tracepoints, but
> that's not exactly what I had in mind.. I just want a running
> commentary of the code as it runs, without having to press 'n' and/or
> 's' all the time.. Could this be implemented in terms of tracepoints?

First of all, I don't think tracepoints are related.

What you ask is not a built-in feature of gdb, but
I often do something like it by writing a short gdb
script.  For a not-very-general example, I'll do
something like:

   set $foo = 100
   while $foo--

You could make $foo a parameter, or you could define some
more useful condition for stopping.  You could also use
"while 1" if you wanted it to run forever.

More information about the Gdb mailing list