GDB 不显示函数名

GDB doesn#39;t show function names(GDB 不显示函数名)

本文介绍了GDB 不显示函数名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 gdbserver 从嵌入式设备进行调试:

I am debugging from an embedded device using gdbserver:

./gdbserver HOST:5000 /home/test_app

在我的PC中,我是这样执行gdb的:

In my PC, I execute gdb in this way:

arm-none-linux-gnueabi-gdb test_app

应用程序执行后,我收到要调试的 Segfault,但无法知道是哪一行产生的:

Once the application is executing, I receive the Segfault I want to debug, but it's impossible to know what line produced it:

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 715]
0x31303030 in ?? ()
(gdb) bt
#0  0x31303030 in ?? ()
#1  0x0000dff8 in ?? ()
#2  0x0000dff8 in ?? ()
Backtrace stopped: previous frame identical to this frame (corrupt stack?)

(我必须说我对 GDB 完全陌生)

(I must say I'm totally new to GDB)

推荐答案

好的,如果缺少调试符号,通常会发生这种情况......只是为了确保运行以下命令

Ok this usually happens if debug symbols are missing... just to make sure run following commands

file <your_executable>

您将获得有关您的二进制文件的信息,例如格式、arch 等.信息的最后一部分描述了二进制文件是否被剥离.为了在 GDB 中调试,不应该剥离二进制文件.

you will get info on your binary like format, arch etc.. last part of the info describes if the binary is stripped or not. For debugging in GDB the binary should not have been stripped.

nm --debug-sym <your_executable> | grep debug

如果您有一些如下所示的有效打印,则表示存在调试符号.

If you have some valid prints as below it means debug symbols are present.

00000000 N .debug_abbrev
00000000 N .debug_aranges
00000000 N .debug_frame
00000000 N .debug_info
00000000 N .debug_line
00000000 N .debug_loc
00000000 N .debug_pubnames
00000000 N .debug_str

当你调用 GDB 时,你应该有以下几行

Further when you invoke GDB you should have follwing line

Reading symbols from <your_executable>...done.

此时您应该可以使用 list 命令列出来源.

At this point you should be able to list sources with list command.

确保 gdb 和 gdbserver 具有相同的 versioninig.

Make sure both gdb and gdbserver have same versioninig.

arm-none-linux-gnueabi-gdb --version
./gdbserver --version

如果以上所有情况都是正确的,并且您仍然没有得到回溯,那么您的堆栈出现了问题.尝试在您的代码/新添加的代码上运行一些静态分析、valgrind.

If all the above are true, and you still don't get backtrace, there is something bad going on with your stack. Try running some static analysis, valgrind on your code / newly added code.

这篇关于GDB 不显示函数名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:GDB 不显示函数名