gdb无法看到源文件 [英] gdb cannot see source file

查看:144
本文介绍了gdb无法看到源文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在尝试调试代码时,我试图通过gdb在代码中放置break语句,但由于某些原因gdb没有看到源文件,尽管它在那里。我第一次使用gdb,所以不知道这是否正确。下面是终端消息:

$ $ $ $ $ $ $ $〜 projects / bison / sandbox / 2D-RZ_rodlet_10pellets $ gdb ../../bison-dbg
GNU gdb(Ubuntu 7.7.1-0ubuntu5〜14.04.2)7.7.1
版权所有(C)2014 Free Software Foundation,Inc.
许可证GPLv3 +:GNU GPL版本3或更高版本< http://gnu.org/licenses/gpl.html>
这是免费软件:您可以自由更改和重新分配它。
在法律允许的范围内,不存在任何担保。有关详细信息,请键入显示复制
和显示保修。
这个GDB被配置为x86_64-linux-gnu。
输入显示配置以获取配置详细信息。
有关错误报告的说明,请参阅:
< http://www.gnu.org/software/gdb/bugs/> ;.
在线查找GDB手册和其他文档资源:
< http://www.gnu.org/software/gdb/documentation/> ;.
如需帮助,请输入help。
输入apropos word搜索与word相关的命令...
从../../bison-dbg...done中读取符号。
(gdb)break〜/ projects / bison / src / materials / NewMaterial.C:166
没有源文件名为〜/ projects / bison / src / materials / NewMaterial.C。
在将来的共享库加载时使断点处于待处理状态? (y或[n])

我可以找到源文件:

 〜/ projects / bison / src / materials $ ls | grep New 
NewMaterial.C
NewMaterial.C〜
NewMaterial.x86_64-unknown-linux-gnu.dbg.lo
NewMaterial.x86_64-unknown-linux-gnu.dbg。 lo.d
NewMaterial.x86_64-unknown-linux-gnu.opt.lo
NewMaterial.x86_64-unknown-linux-gnu.opt.lo.d

Gyan

解决方案


  1. 请勿使用字符的文件名。 GDB不会将它们扩展到您的HOME位置。

  2. 确保您的代码使用 -g 标志进行编译。

  3. 尝试仅使用文件名,如果它不是不明确的,那么:

    break NewMaterial.C:166

  4. 如果不明确,尝试将其与编译根目录相关的路径(例如项目根目录,就像它传递给编译器一样)使用。

  5. 作为最后的手段 - 使用完整路径(但实际上:完整路径,没有标志)。


While trying to debug a code I tried to put break statements in the code through gdb, but for some reasons gdb don't see the source file although it's there. I am using gdb for the first time so don't know if that is the right way. Below is the terminal message:

~$ 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])

I can locate the source file as:

~/projects/bison/src/materials$ ls | grep New
NewMaterial.C
NewMaterial.C~
NewMaterial.x86_64-unknown-linux-gnu.dbg.lo
NewMaterial.x86_64-unknown-linux-gnu.dbg.lo.d
NewMaterial.x86_64-unknown-linux-gnu.opt.lo
NewMaterial.x86_64-unknown-linux-gnu.opt.lo.d

Gyan

解决方案

  1. Do not use file names with ~ character. Gdb does not expand them to your HOME location.
  2. Make sure your code get compiled with -g flag.
  3. Try to use only file name, if it's not ambiguous, so:
    break NewMaterial.C:166
  4. If it is ambiguous, try to use it with path related to the "compiling root" (e.g. project root, just as it was passed to the compiler).
  5. As a last resort - use full path (but literally: full path, no ~ signs).

这篇关于gdb无法看到源文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆