Programm Execution Tracing with GDB

27.09.2007 at 13:03

Ok found another problem in tinycc, the __attribute__ handling code gets confused by parentheses, sent a fix to tinycc-devel.

The next issue I faced is a bit more complex, there seams to be a bug with nested struct/union initialization.

While debugging this I looked for a way to get an exact trace of the lines which are executed. So I ended up writing this little shell script, which makes gdb looping over every program step by sending the appropriate command to its stdin.


gdb --args $* <<EOF
    break main
    while 1

Don't know how useful this will be because the amount of generated data is quite large. Anyway the GNU GDB Online Documentation is a good place to search for information about gdb commands (what a surprise ;).


Comments (3)

hrmm, nice but

18.10.2007 by srm (mpeg-rentner[at]gmx[dot]at)

hi there; i386-marcel-freebsd (6.1.1) Hangup detected on fd 0 error detected on stdin However, if I run the commands directly in gdb it works(tm)

strange - works here

29.10.2007 by Marc Andre Tanner (mat[at]brain-dump[dot]org)

Strange works here under Debian GNU/Linux, anyway if you find a better way to do it just send me a mail. Thanks, Marc

cant get it working

18.07.2008 by ideasman42 (ideasman42[at]gmail[dot]com)

Hi, after working this out myself, I found your post. But I couldnt get what you had working in linux, was some glitch with gdb... not sure exactly. Anyhow, heres how I managed to do the same thing with gdb