Code:
$ gcc -g test.c -o test
$ gdb test
GNU gdb Red Hat Linux (6.3.0.0-1.122rh)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "i386-redhat-linux-gnu"...Using host libthread_db library "/lib/libthread_db.so.1".
(gdb) l
1 #include <stdio.h>
2
3 int main(void) {
4 int i;
5 i = 10;
6 fprintf (stderr, "test\n");
7 return 0;
8 }
(gdb) b 5
Breakpoint 1 at 0x80483b5: file test.c, line 5.
(gdb) r
Starting program: /home/Alexander/test
Reading symbols from shared object read from target memory...done.
Loaded system supplied DSO at 0x70b000
Breakpoint 1, main () at test.c:5
5 i = 10;
(gdb) s
6 fprintf (stderr, "test\n");
(gdb) s
test
7 return 0;
(gdb) print i
$1 = 10
(gdb) q
The program is running. Exit anyway? (y or n) y