[root@LinuxServer thinkpad]# rm -f * dd2dd :q! yyp :set nu:set nonu:3 gcc 2.9.5.3 gnu cc [root@LinuxServer thinkpad]# ./a.out[root@LinuxServer thinkpad]# gcc -o test test.c[root@LinuxServer thinkpad]# gcc -g -o test test.c [root@LinuxServer thinkpad]# gcc -c test.c[root@LinuxServer thinkpad]# lsa.out test test.c test.o -O -O2-g Makefile/makefilemake test: prog.o code.o gcc -o test prog.o code.oprog.o: prog.c prog.h code.h gcc -c prog.c -o prog.ocode.o: code.c code.h gcc -c code.c -o code.oclean: rm -f *.o #make target OBJS=prog.o code.oCC=gcctest: ${ OBJS } ${ CC } -o test ${ OBJS }prog.o: prog.c prog.h code.h ${ CC } -c prog.c -o prog.ocode.o: code.c code.h ${ CC } -c code.c -o code.oclean: rm -f *.o [root@LinuxServer thinkpad]# lstest.c[root@LinuxServer thinkpad]# gcc -g -o test test.c [root@LinuxServer thinkpad]# gdb testGNU gdb Red Hat Linux (5.3post-0.20021129.18rh)Copyright 2003 Free Software Foundation, Inc.GDB is free software, covered by the GNU General Public License, and you arewelcome 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"...(gdb) list1 int main(void)2 {3 printf("Hello World!!\n");4 return 0;5 } [root@LinuxServer thinkpad]# gdb testGNU gdb Red Hat Linux (5.3post-0.20021129.18rh)Copyright 2003 Free Software Foundation, Inc.GDB is free software, covered by the GNU General Public License, and you arewelcome 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"...(gdb) l1 int main(void)2 {3 printf("Hello World!!\n");4 return 0;5 }(gdb) b 3Breakpoint 1 at 0x8048338: file test.c, line 3.(gdb) rStarting program: /home/thinkpad/test Breakpoint 1, main () at test.c:33 printf("Hello World!!\n");(gdb) nHello World!!4 return 0;(gdb) n5 }(gdb) n0x42015574 in __libc_start_main () from /lib/tls/libc.so.6(gdb) nSingle stepping until exit from function __libc_start_main,which has no line number information. Program exited normally.(gdb) watch aNo symbol "a" in current context.(gdb) quit

评论