当前位置: 技术问答>linux和unix
【请教】关于gdb的基本用法
来源: 互联网 发布时间:2015-07-06
本文导语: 我用有一个test.c文件, 已经gcc -o ts test.c 然后 gdb ts,显示如下: GNU 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 a...
我用有一个test.c文件,
已经gcc -o ts test.c
然后 gdb ts,显示如下:
GNU 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 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"...
然后我键入:list,
却提示:
(gdb) list
1 init.c: 没有那个文件或目录
in init.c
请问是怎么回事?
已经gcc -o ts test.c
然后 gdb ts,显示如下:
GNU 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 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"...
然后我键入:list,
却提示:
(gdb) list
1 init.c: 没有那个文件或目录
in init.c
请问是怎么回事?
|
用gdb之前,编译时需要:gcc -g -o ts test.c
|
-o是指编译选项为将要产生的可执行文件制定一个文件名
-g是把调试信息加入到可执行的文件里
-g是把调试信息加入到可执行的文件里