Ubuntu GDB无法看到源文件

Ubuntu GDB无法看到源文件,ubuntu,gdb,Ubuntu,Gdb,在调试代码时,我试图通过GDB在代码中放入break语句,但由于某些原因,GDB看不到源文件,尽管它在那里。我是第一次使用GDB,所以我不知道这是不是正确的方法。以下是终端信息: ~$ cd ~/projects/bison/sandbox/2D-RZ_rodlet_10pellets ~/projects/bison/sandbox/2D-RZ_rodlet_10pellets$ gdb ../../bison-dbg GNU gdb (Ubuntu 7.7.1-0ubuntu5~14.04.

在调试代码时,我试图通过GDB在代码中放入break语句,但由于某些原因,GDB看不到源文件,尽管它在那里。我是第一次使用GDB,所以我不知道这是不是正确的方法。以下是终端信息:

~$ cd ~/projects/bison/sandbox/2D-RZ_rodlet_10pellets
~/projects/bison/sandbox/2D-RZ_rodlet_10pellets$ gdb ../../bison-dbg
GNU gdb (Ubuntu 7.7.1-0ubuntu5~14.04.2) 7.7.1
Copyright (C) 2014 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from ../../bison-dbg...done.
(gdb) break ~/projects/bison/src/materials/NewMaterial.C:166
No source file named ~/projects/bison/src/materials/NewMaterial.C.
Make breakpoint pending on future shared library load? (y or [n])
  • 不要使用带有
    ~
    字符的文件名。GDB不会将它们扩展到您的家庭位置
  • 确保使用
    -g
    标志编译代码
  • 如果文件名不含糊,请尝试仅使用该文件名,以便:

    break NewMaterial.C:166
    
  • 如果不明确,请尝试将其与“编译根”相关的路径一起使用(例如,项目根,就像传递给编译器一样)

  • 作为最后手段-使用完整路径(但字面意思是:完整路径,没有
    ~
    字符)

  • 尝试从根提供完整路径。gdb无法找到该文件。完整路径在这里可能会有所帮助。是否使用调试选项编译?提供了完整路径,但不起作用;给出相同的错误消息。是的,我在调试模式下编译:
    METHOD=dbg make
    但是这是在gdb之外完成的。你能在这里共享完整的路径吗。路径从根开始?要获得调试模式,请使用-g选项编译代码。
    break NewMaterial.C:166