C++ gdb:(未找到调试符号)

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/18190577/
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-08-27 21:47:16  来源:igfitidea点击:

gdb: (no debugging symbols found)

c++ubuntugdbg++

提问by psyc0der

I have a file called test. Even after compiling it with -g, when I run it in gdb, it says no debugging symbols found. I have also tried using -ggdb but it too was off no use. Please help.

我有一个名为 test.txt 的文件。即使在使用 -g 编译它之后,当我在 gdb 中运行它时,它也说没有找到调试符号。我也尝试过使用 -ggdb 但它也没有用。请帮忙。

Output for : gdb test

This GDB was configured as "x86_64-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /usr/bin/test...(no debugging symbols found)...done.

采纳答案by trojanfoe

The issue is that you are attempting to debug the wrong program.

问题是您正在尝试调试错误的程序。

Your program is called testand yet you are debugging /usr/bin/test(a system program that will almost certainly be shipped without symbols; even if it did contain symbols, they wouldn't relate to your source code).

您的程序已被调用test,但您正在调试/usr/bin/test(几乎肯定会在没有符号的情况下交付系统程序;即使它确实包含符号,它们也不会与您的源代码相关)。

gdbwill search $PATHto find the executable. From here:

gdb将搜索$PATH以找到可执行文件。从这里

exec-file [ filename ] Specify that the program to be run (but not the symbol table) is found in filename. gdb searches the environment variable PATH if necessary to locate your program. Omitting filename means to discard information on the executable file.

exec-file [ filename ] 指定要运行的程序(但不是符号表)在文件名中找到。如有必要,gdb 会搜索环境变量 PATH 以定位您的程序。省略文件名意味着丢弃有关可执行文件的信息。

Try using the command:

尝试使用以下命令:

$ gdb ./test

回答by pankaj kushwaha

Remove a.outand then try again. It worked for me as I was also getting the same error.

删除a.out然后重试。它对我有用,因为我也遇到了同样的错误。

rm a.out
gcc -g your_code.c

回答by Mali

Check that the executable is not stripped, you can see that with file /usr/bin/test

检查可执行文件没有被剥离,你可以看到 file /usr/bin/test