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

问题描述

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

I am debugging from an embedded device using gdbserver:

./gdbserver HOST:5000 /home/test_app

在我的电脑中,我以这种方式执行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等信息。最后部分的信息描述if二进制是否被剥离。对于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具有相同的版本号。

Make sure both gdb and gdbserver have same versioninig.

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


b $ b

如果上面所有的都是真的,你仍然没有得到backtrace,你的堆栈有一些不好的事情。尝试运行一些静态分析,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不显示函数名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-21 12:16