问题描述
我想开始使用gdbserver进行远程调试,所以我用一个简单的测试程序在我的本地机器上测试了它的功能,该测试程序生成如下所示的段错误:
segfault.c - 编译为名为test的elf
#define NULL((void *)0)
int main()
{
int value = *((int *)NULL);
返回值;
}
现在当我运行时:
#gdb test
然而,如果我使用gdb服务器来调试它: (gdb)run $ c $
开始程序:/ home / awaibel / digiworkspace /测试/调试/测试
编程接收到的信号SIGSEGV,分段错误。 $()b $ b 0x080483bf in main()at ../segfault.c:4
4 int value = *((int *)NULL);
#gdbserver:65535 test
#gdb test
$ p $(gdb)target remote 127.0.0.1:65535
(gdb)continue
它给了我调试信息:
编程接收到的信号SIGSEGV,分段故障。
0x080483bf在?? ()
它似乎给出了段错误的相同函数地址,但名称和行号是在使用远程调试器进行调试时省略。是否有可能让远程调试器显示这些信息,如果是这样,如何?
我想我应该补充一点,该程序是使用GCC编译使用-g debug flag
感谢markys的评论,我能够找出问题所在。由于gdb客户端是解析符号而不是服务器,我必须确保客户端知道可执行文件副本的完整路径。由于'test'不在用于运行gdbtest的命令提示符的当前目录中,因此它没有要使用的符号的副本。将二进制文件添加到运行客户端的终端的PATH解决了问题。
$ b
总结:
- 客户端:
gdb可执行路径
(gdb)>目标远程ip-of-the-remote-device:port
I wanted to start using gdbserver for remote debugging and so I tested-out its functionality on my local machine with a simple test program that generates a segfault shown below:
segfault.c -- compiles to elf named "test"
#define NULL ((void*)0)
int main()
{
int value = *((int*)NULL);
return value;
}
Now when I run:
#gdb test
(gdb)run
I get:
Starting program: /home/awaibel/digiworkspace/test/Debug/test
Program received signal SIGSEGV, Segmentation fault.
0x080483bf in main () at ../segfault.c:4
4 int value = *((int*)NULL);
however if I debug it with gdb server like so:
#gdbserver :65535 test
#gdb test
(gdb)target remote 127.0.0.1:65535
(gdb)continue
it gives me the debug info:
Program received signal SIGSEGV, Segmentation fault.
0x080483bf in ?? ()
it seems to give the same function address for the segfault, but the name and line number is omitted when debugging with the remote debugger. is it possible to have the remote debugger display this information, and if so, how?
I guess I should add that the program was compiled with GCC using the "-g" debug flag
Thanks to markys' comments I was able to figure out the problem. Since the gdb client is what parses the symbols and not the server, I had to make sure the client knew the full path to a copy of the executable. Since 'test' was not in the current directory for the command prompt that was used to run gdbtest it did not have a copy of the symbols to use. adding the the binary to PATH for the terminal running the client solved the problem. Thanks.
Summarizing:
- server side:
- client side:
gdb "path-to-executable"(gdb)> target remote "ip-of-the-remote-device:port"
这篇关于缺少gdbserver中的符号名称,但没有使用gdb的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!