打印

请教!gdb的问题

请教!gdb的问题

我刚在linux下学编程,用gdb调试程序的时候,想用list命令列出源代码,但却出现下面的问题:
GNU gdb Red Hat Linux (5.1.90CVS-5)
Copyright 2002 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"...
(gdb) list
1       init.c: No such file or directory.
        in init.c
(gdb)
请问怎样才能用list命令列出源代码啊?多谢!

TOP

问题可能在:
  1、用gcc编译时是否带了-g选项。
  2、gdb filename是否带了filename
以111.c原文件为例:
   gcc -g -o 111 111.c
   gdb 111
进入之后,再试试。

TOP

gcc -ggdb3 -o xxx xxx.c
gdb xxx

gdb:list
萝卜青菜,各有所爱,我就爱Linux! 神话有3种,第一种神话,第二种台湾独立,第三种台湾反攻大陆.

TOP