This is the mail archive of the
gdb@sources.redhat.com
mailing list for the GDB project.
Re: Non-interactive stepping
- From: Nick Roberts <nick at nick dot uklinux dot net>
- To: ct-nebergall at wiu dot edu
- Cc: gdb at sources dot redhat dot com
- Date: Sun, 2 May 2004 22:27:00 +0100
- Subject: Re: Non-interactive stepping
> I want to do something similar to
> gdb -[Some command line argument] a.out
> a.out: main.c:5 main() May 1 16:18:07 CDT 2004
> a.out: main.c:6 main() May 1 16:18:08 CDT 2004
> a.out: main.c:7 main() May 1 16:18:09 CDT 2004
> a.out: main.c:25 print() May 1 16:18:09 CDT 2004
> a.out: main.c:28 print() May 1 16:18:09 CDT 2004
> a.out: source2.c:10 echo() May 1 16:18:10 CDT 2004
> a.out: source2.c:11 echo() May 1 16:18:10 CDT 2004
> a.out: source2.c:11 echo() May 1 16:18:12 CDT 2004
> a.out: main.c:29 print() May 1 16:18:13 CDT 2004
> a.out: main.c:8 main() May 1 16:18:14 CDT 2004
> etc...
Here's an ugly hack that gives you line information.
Put the following user-defined command in your .gdbinit file:
define mytrace
set height 0
b main
run
while 1
step
end
end
Run gdb with "gdb -ann=1 myprog" and type "mytrace" at the prompt
to get something like:
(gdb) mytrace
Breakpoint 1 at 0x804849f: file myprog.c, line 38.
Breakpoint 1, main () at myprog.c:38
^Z^Z/home/nick/myprog.c:38:389:beg:0x804849f
^Z^Z/home/nick/myprog.c:44:470:beg:0x80484a6
^Z^Z/home/nick/myprog.c:49:585:beg:0x80484ec
^Z^Z/home/nick/myprog.c:50:595:beg:0x80484f5
^Z^Z/home/nick/myprog.c:51:611:beg:0x804850d
^Z^Z/home/nick/myprog.c:52:628:beg:0x8048525
^Z^Z/home/nick/myprog.c:53:637:beg:0x804852c
...
You might want to re-direct any program output.
Nick