Eclipse远程调试ARM-Linux库

3

我正在运行:

  • Eclipse 3.8.1 (Build id: deb构建)。
  • 在虚拟机中运行Ubuntu 16.04 LTS,在目标Raspberry Pi 3上运行UbuntuMATE 16.04 LTS。
  • 本地使用gdb-multiarch (在.gdbinit中将体系结构设置为arm),在目标设备上使用gdbserver。

交叉编译和远程部署成功。但是,在远程目标上运行时似乎存在一些库问题。下面是来自 gdb-multiarch的输出(已删除多余文本):

GNU gdb (Ubuntu 7.11-0ubuntu1) 7.11 版权所有 (C) 2016 自由软件基金会 GPLv3 +: GNU GPL版本3或更高版本http://gnu.org/licenses/gpl.html这个GDB被配置为"x86_64-linux-gnu"。


程序停止了。 0x76fd7a40在??()中来自/home/fred/raspberrypi/rootfs/lib/arm-linux-gnueabihf/ld-2.23.so。

执行在main处停止。但是,它似乎不是由于断点而停止的。停止似乎是由于某些可能是未解决符号的库问题(或者更严重的问题)导致的??

我在.gdbinit文件中设置了set sysroot,以指示共享库的位置。StepIn、StepOut图标在Eclipse中被高亮显示,如果按下暂停按钮,可以读取ARM寄存器并查看正在使用哪个核心运行进程(带有进程ID)!

在进一步的恢复和暂停操作之后,发生分段错误

程序停止。0x76fe2e92在??()中来自/home/fred/raspberrypi/rootfs/lib/arm-linux-gnueabihf/ld-2.23.so。

程序收到信号SIGSEGV,分段错误。0x76fd905e在??()中来自/home/fred/raspberrypi/rootfs/lib/arm-linux-gnueabihf/ld-2.23.so。

程序以信号SIGSEGV,分段错误终止。该程序不再存在。

有什么想法吗?(我对Linux非常新,请多关照。)

感谢您的问题,这已经导致了以下更深入的探索:

在Eclipse中,我选择了Debug Configuration,然后选择了我设置的远程配置来启动GDB。

这段代码非常简单,包括一个流操作符输出一些文本以及一个循环,但是它从来没有被执行。我认为我刚刚成功地从命令行中复制了这个问题。顺便说一下,我先启动了目标程序。(为了清晰起见,多余的文本已经被删除。)

gdb-multiarch Hello_Raspberry_Pi

Reading symbols from Hello_Raspberry_Pi...done.
The target architecture is assumed to be arm
(gdb) target remote ubuntumate-pi
(gdb) target remote 192.168.0.12:2345
Remote debugging using 192.168.0.12:2345
warning: Unable to find dynamic linker breakpoint function.
GDB will be unable to debug shared library initialisers
and track explicitly loaded dynamic code.
0x76fd7a40 in ?? ()
(gdb) set architecture arm
The target architecture is assumed to be arm
(gdb) set sysroot /home/fred/raspberrypi/rootfs/lib/arm-linux-gnueabihf
warning: Unable to find dynamic linker breakpoint function.
GDB will be unable to debug shared library initialisers
and track explicitly loaded dynamic code.
(gdb)

目标端表现符合预期:
fred@UbuntuMATE-Pi:~/Hello_Raspberry_Pi$ gdbserver 192.168.0.7:2345 Hello_Raspberry_Pi
Process Hello_Raspberry_Pi created; pid = 17363
Listening on port 2345
Remote debugging from host 192.168.0.7

也许 无法找到动态链接器断点函数 是个重要的线索?

看起来我错误地定义了共享库。当我删除这个设置时,出现了更接近预期行为的情况。如下所示,但是我仍然想要删除一个警告:

For help, type "help".
Type "apropos word" to search for commands related to "word".
warning: Unable to find dynamic linker breakpoint function.
GDB will be unable to debug shared library initialisers
and track explicitly loaded dynamic code.
0x76fd7a40 in ?? ()

Breakpoint 2, main () at ../src/Hello_Raspberry_Pi.cpp:18
18            cout << "I'm in the While loop and the value of variable i is: " << i << endl;

Breakpoint 1, main () at ../src/Hello_Raspberry_Pi.cpp:20
20            usleep(1000000); //wait for 1 seconds

所以现在Eclipse可以在主函数处设置断点并允许单步调试了 - 终于实现了!

你是如何启动gdb的?它加载了什么/你想要调试什么?你能够从命令行重新运行gdb吗?在没有gdb的情况下运行应用程序有什么效果? - dbrank0
这个论坛帖子可能会有用:https://www.eclipse.org/forums/index.php/t/634692/ - dbrank0
@dbrank0,感谢你提供这样激发思考的意见。 - eklektek
相关链接:https://dev59.com/Um855IYBdhLWcg3w_5qm#45608937 - Ciro Santilli OurBigBook.com
1个回答

2

我也遇到过类似的问题,从 ld.so 得到分段错误。执行以下步骤来解决它。

  1. 在 sysroot 和目标中安装 libc6-dbg 包。
  2. 在 sysroot 和目标中创建一个名为 /lib/.debug 的文件夹。
  3. 将 /usr/lib/debug/lib/arm-linux-gnueabihf/ld-2.23.so 复制到 sysroot 和目标的 /lib/.debug 中。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接