gpt4 book ai didi

c - gdb:无法重新编译可执行文件:(未找到调试符号)

转载 作者:太空宇宙 更新时间:2023-11-04 08:12:43 25 4
gpt4 key购买 nike

我只能访问 C 可执行文件(没有源代码/.c 代码),我需要使用 gdb 来调试它。但是我不断收到一条(未找到调试符号)消息。我见过其他类似的问题,但大多数建议重新编译源代码(我不能这样做,因为我没有)或建议以下修复(见下文),这些对我没有用。

gdb test
Reading symbols from /usr/bin/test...(no debugging symbols found)...done.
(gdb) b main
Function "main" not defined.
Make breakpoint pending on future shared library load? (y or [n]) n
(gdb) b 2
No symbol table is loaded. Use the "file" command.
(gdb) file test
Reading symbols from /usr/bin/test...(no debugging symbols found)...done.
(gdb) exec-file test
(gdb) file test
Reading symbols from /usr/bin/test...(no debugging symbols found)...done.
(gdb) b 2
No symbol table is loaded. Use the "file" command.

作为旁注,我不能在 main 处中断(很奇怪,因为我可以保证这是一个 C 可执行文件)。

我刚开始使用 gdb,非常迷茫,非常感谢任何帮助。非常感谢!

编辑:

按照@Jean-François Fabre 的建议,我已将可执行文件名称更改为 foobar,但仍然遇到同样的问题。上面的输出已更新:

gdb foobar
Reading symbols from /usr/bin/foobar...(no debugging symbols found)...done.
(gdb) b main
Function "main" not defined.
Make breakpoint pending on future shared library load? (y or [n]) n
(gdb) b 2
No symbol table is loaded. Use the "file" command.
(gdb) file foobar
Reading symbols from /usr/bin/foobar...(no debugging symbols found)...done.
(gdb) exec-file foobar
(gdb) file foobar
Reading symbols from /usr/bin/foobar...(no debugging symbols found)...done.
(gdb) b 2
No symbol table is loaded. Use the "file" command.

最佳答案

But I keep getting a (no debugging symbols found) message.

此消息表示您的可执行文件没有调试信息。

I cannot break at main (strange because I can guarantee this is a C executable).

这可能意味着您的可执行文件已被完全剥离(其符号表已被删除;符号表有助于调试但在运行时完全不需要)。

I need to use gdb to debug it.

这很好:您仍然可以调试此可执行文件,但只能在汇编级别进行调试。如果没有符号表,您将只能在单个指令地址上设置断点,而不能在任何函数上设置。

如果您的可执行文件是动态链接的,您仍然应该能够在外部函数上设置断点,例如 printfmalloc(如果您的可执行文件调用它们)。

关于c - gdb:无法重新编译可执行文件:(未找到调试符号),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38163803/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com