$ man man
$ man -k directory
$ man -k directory | grep list
$ man -k directory | less
$ mkdir -p cs3s609/tutorial1 $ cd cs3s609/tutorial1
$ emacs tiny.c
#include <stdio.h> main() { int i; for (i=1; i<=12; i++) { printf(‘‘%d x 8 = %d\n'', i, i*8); } }
$ gcc -g tiny.c
$ ./a.out
$ gdb a.out GNU gdb 6.4.90-debian Copyright (C) 2006 Free Software Foundation, Inc. GDB is free software, etc (gdb) break main Breakpoint 1 at 0x8048365: file tiny.c, line 7. (gdb) run
Breakpoint 1, main () at tiny.c:7 7 for (i=1; i<=12; i++) { (gdb) next 8 printf(‘‘%d x 8 = %d\n'', i, i*8); (gdb) next 1 x 8 = 8 7 for (i=1; i<=12; i++) { (gdb) next 8 printf(‘‘%d x 8 = %d\n'', i, i*8); (gdb) print i $1 = 2 (gdb) next 2 x 8 = 16 7 for (i=1; i<=12; i++) { (gdb) quit The program is running. Exit anyway? (y or n) y
#include <stdio.h> int mult (int i) { return i*9; } main() { int i; for (i=1; i<=12; i++) { printf(‘‘%d x 8 = %d\n'', i, mult(i)); } }
$ gcc -g tiny.c
$ ./a.out 1 x 8 = 9 2 x 8 = 18 3 x 8 = 27 4 x 8 = 36 5 x 8 = 45 6 x 8 = 54 7 x 8 = 63 8 x 8 = 72 9 x 8 = 81 10 x 8 = 90 11 x 8 = 99 12 x 8 = 108
$ gdb a.out GNU gdb 6.4.90-debian Copyright (C) 2006 Free Software Foundation, Inc. GDB is free software, etc (gdb) break main Breakpoint 1 at 0x8048365: file tiny.c, line 7. (gdb) run
(gdb) run Starting program: a.out Breakpoint 1, main () at tiny2.c:12 12 for (i=1; i<=12; i++) { (gdb) step 13 printf(‘‘%d x 8 = %d\n'', i, mult(i)); (gdb) step mult (i=1) at tiny2.c:5 5 return i*9; (gdb) fin Run till exit from #0 mult (i=1) at tiny2.c:5 0x08048388 in main () at tiny2.c:13 13 printf(‘‘%d x 8 = %d\n'', i, mult(i)); Value returned is $1 = 9
(gdb) step 1 x 8 = 9 12 for (i=1; i<=12; i++) { (gdb) step 13 printf(‘‘%d x 8 = %d\n'', i, mult(i)); (gdb) step mult (i=2) at tiny2.c:5 5 return i*9;
(gdb) print i $1 = 2 (gdb) up #1 0x08048388 in main () at tiny2.c:13 13 printf(‘‘%d x 8 = %d\n'', i, mult(i)); (gdb) print i $2 = 2 (gdb) down #0 mult (i=2) at tiny2.c:5 5 return i*9;
# # this file is the gdb start up script and # you can place any gdb commands in here # break main run
$ emacs
This document was produced using groff-1.22.