Code:
m-net% gdb tty2
GNU gdb 6.1.1 [FreeBSD]
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-marcel-freebsd"...
(gdb) list
1 #include <stdio.h>
2
3 int main(void)
4 {
5 static char buf[BUFSIZ];
6 static char *bufp = buf;
7 static int n = 0;
8
9 if(n == 0) {
10 n = read(0,buf, sizeof buf);
(gdb) br 6
Breakpoint 1 at 0x8048514: file tty2.c, line 6.
(gdb) br 9
Note: breakpoint 1 also set at pc 0x8048514.
Breakpoint 2 at 0x8048514: file tty2.c, line 9.
(gdb) run
Starting program: /home/guest/cdalten/tty2
Breakpoint 1, main () at tty2.c:9
9 if(n == 0) {
(gdb) display buf
1: buf = '\0' <repeats 1023 times>
(gdb) step
10 n = read(0,buf, sizeof buf);
1: buf = '\0' <repeats 1023 times>
(gdb) step
c h a d
11 bufp = buf;
1: buf = "c h a d\n", '\0' <repeats 1015 times>
(gdb) step
13 return (--n >= 0) ? (unsigned char) *bufp++ : EOF;
1: buf = "c h a d\n", '\0' <repeats 1015 times>
(gdb) step
14 }
1: buf = "c h a d\n", '\0' <repeats 1015 times>
(gdb) step
0x08048442 in _start ()
1: buf = "c h a d\n", '\0' <repeats 1015 times>
(gdb) step
Single stepping until exit from function _start,
which has no line number information.
Program exited with code 0143.
(gdb) q
Code:
m-net% gdb tty
GNU gdb 6.1.1 [FreeBSD]
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-marcel-freebsd"...
(gdb) list
1 #include <stdio.h>
2
3 int main(void)
4 {
5 char c;
6
7 return(read(0, &c, 1) == 1) ? (unsigned char)c : EOF;
8
9 return 0;
10 }
(gdb) br 7
Breakpoint 1 at 0x8048514: file tty.c, line 7.
(gdb) run
Starting program: /home/guest/cdalten/tty
Breakpoint 1, main () at tty.c:7
7 return(read(0, &c, 1) == 1) ? (unsigned char)c : EOF;
(gdb) display c
1: c = 0 '\0'
(gdb) step
c
10 }
1: c = 99 'c'
(gdb)
0x08048442 in _start ()
(gdb)