C语言 为什么我会在 GDB 中收到消息“单步执行直到退出...没有行号信息”?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2170246/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-02 04:20:17  来源:igfitidea点击:

Why am I getting the message "Single-stepping until exit . . . which has no line number information" in GDB?

cgccgdb

提问by Steven Oxley

I've compiled my C program using gcc 4.4.1using the flag -g, but when I try to step through one of my functions in gdb version 7.0, I get the message:

我已经使用 flag使用gcc 4.4.1编译了我的 C 程序-g,但是当我尝试单步执行gdb 版本 7.0 中的一个函数时,我收到消息:

"Single stepping until exit from function _DictionaryTree_getNodeList, 
which has no line number information."

Can someone tell me why this is happening?

有人能告诉我为什么会这样吗?

采纳答案by Arthur Kalliokoski

Just guessing, but is _DictionaryTree_getNodeList in another file that wasn't compiled with -g?

只是猜测,但 _DictionaryTree_getNodeList 是否在另一个未使用 -g 编译的文件中?

回答by Arild

I had the same problem but in my case adding -gto the compiler wasn't enough so I used -ggdbas suggested by Manav.

我遇到了同样的问题,但在我的情况下,添加-g到编译器还不够,所以我-ggdb按照 Manav 的建议使用。

回答by hoc_age

In my case, the problem was version skew between gccand gdb.

就我而言,问题是gcc和之间的版本偏差gdb

After landing here from search and none of these answers fit my situation, I figured out that (because of aliases / symlinks / Makefile/ environment variables) I was accidentally using a newer GCC (4.8.x) and an older GDB (7.2). Stepping up to a newer version of GDB (7.8) fixed the problem.For some reason, using a newer GCC and older GDB didn't work.

从搜索登陆这里后,这些答案都不适合我的情况,我发现(由于别名/符号链接Makefile//环境变量)我不小心使用了较新的 GCC (4.8.x) 和较旧的 GDB (7.2)。升级到更新版本的 GDB (7.8) 解决了这个问题。出于某种原因,使用较新的 GCC 和较旧的 GDB 不起作用。

回答by user3916997

I had this error message too but the source of my problem was different. If anyone is still having any problems, make sure you have #include <stdio.h>in your file, with the the appropriate brackets around stdio.h(the text message would not show up if I had it around stdio.h).

我也有这个错误信息,但我的问题的根源是不同的。如果有人仍然有任何问题,请确保您#include <stdio.h>的文件中有适当的括号stdio.h(如果我有它,则不会显示文本消息stdio.h)。

回答by Hans

I had this issue because I was debugging a shared library without pointing LD_LIBRARY_PATH to correct location with debug endstates.

我遇到这个问题是因为我在调试共享库时没有将 LD_LIBRARY_PATH 指向带有调试结束状态的正确位置。

you can use

您可以使用

export LD_LIBRARY_PATH=<location of the debug build of the .so file>:$LD_LIBRARY_PATH

Hopefully this is helpful to someone

希望这对某人有帮助

回答by richar8086

I had the same trouble despite I was already compiling with -g2. Changing it to -g3did the trick.

尽管我已经用-g2. 改变它就行-g3了。

回答by ravi.zombie

I had the same issue, when I compiled a file using -g option and without -g option. For one of the file, the gdb showed line number without any issues(even when it was compiled without -g option).. And for the other file, I had to explicitly mention -g flag...

当我使用 -g 选项而不使用 -g 选项编译文件时,我遇到了同样的问题。对于其中一个文件,gdb 显示的行号没有任何问题(即使它是在没有 -g 选项的情况下编译的)。而对于另一个文件,我不得不明确提到 -g 标志......

Any ideas as to whether the source file could be loaded at run time in GDB with cross referencing would be good solution... by mapping the lines to the addresses :D.

关于是否可以在运行时通过交叉引用在 GDB 中加载源文件的任何想法都是很好的解决方案......通过将行映射到地址:D。