* gdb usage help!
@ 2001-04-11 4:05 Vishal Kulshrestha
2001-04-11 6:52 ` Keith Seitz
0 siblings, 1 reply; 2+ messages in thread
From: Vishal Kulshrestha @ 2001-04-11 4:05 UTC (permalink / raw)
To: gdb
Hi,
Is there a way of letting gdb print all the source code lines as
it executes! Some kind of a script like:
#############
break main
run
while 1
step
end
############
Regards,
Vishal.
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: gdb usage help!
2001-04-11 4:05 gdb usage help! Vishal Kulshrestha
@ 2001-04-11 6:52 ` Keith Seitz
0 siblings, 0 replies; 2+ messages in thread
From: Keith Seitz @ 2001-04-11 6:52 UTC (permalink / raw)
To: Vishal Kulshrestha; +Cc: gdb
On Wed, 11 Apr 2001, Vishal Kulshrestha wrote:
> Is there a way of letting gdb print all the source code lines as
> it executes!
Well, yes and no. You could step/next forever until the program exits or
you get a signal/exception. You would need to be careful about stepping
into shared libraries and system calls, etc, but it could be done with a
simple (overly simple?) gdb script:
$ cat test.c
#include <stdio.h>
int
main (int argc, char *argv[])
{
int i;
for (i = 0; i < 10; i++)
{
printf ("i = %d\n", i);
}
exit (0);
}
$ gdb -nw -q test
(gdb) b main
Breakpoint 1 at 0x8048492: file test.c, line 8.
(gdb) r
Starting program: /home/keiths/test
Breakpoint 1, main (argc=1, argv=0xbffffab4) at test.c:8
8 for (i = 0; i < 10; i++)
(gdb) while 1
>next
>f
>end
10 printf ("i = %d\n", i);
#0 main (argc=1, argv=0xbffffab4) at test.c:10
10 printf ("i = %d\n", i);
i = 0
8 for (i = 0; i < 10; i++)
#0 main (argc=1, argv=0xbffffab4) at test.c:8
8 for (i = 0; i < 10; i++)
10 printf ("i = %d\n", i);
#0 main (argc=1, argv=0xbffffab4) at test.c:10
10 printf ("i = %d\n", i);
i = 1
8 for (i = 0; i < 10; i++)
#0 main (argc=1, argv=0xbffffab4) at test.c:8
8 for (i = 0; i < 10; i++)
10 printf ("i = %d\n", i);
#0 main (argc=1, argv=0xbffffab4) at test.c:10
10 printf ("i = %d\n", i);
i = 2
8 for (i = 0; i < 10; i++)
#0 main (argc=1, argv=0xbffffab4) at test.c:8
8 for (i = 0; i < 10; i++)
10 printf ("i = %d\n", i);
#0 main (argc=1, argv=0xbffffab4) at test.c:10
10 printf ("i = %d\n", i);
i = 3
8 for (i = 0; i < 10; i++)
#0 main (argc=1, argv=0xbffffab4) at test.c:8
8 for (i = 0; i < 10; i++)
10 printf ("i = %d\n", i);
#0 main (argc=1, argv=0xbffffab4) at test.c:10
10 printf ("i = %d\n", i);
i = 4
8 for (i = 0; i < 10; i++)
#0 main (argc=1, argv=0xbffffab4) at test.c:8
8 for (i = 0; i < 10; i++)
10 printf ("i = %d\n", i);
---Type <return> to continue, or q <return> to quit---
and so on.
Keith
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2001-04-11 6:52 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-04-11 4:05 gdb usage help! Vishal Kulshrestha
2001-04-11 6:52 ` Keith Seitz
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox