如何在具有GDB GUI前端的PC上为ARM gdbserver执行PC上的远程gdb会话? [英] How do I perform a remote gdb session on a PC for ARM gdbserver WITH GDB GUI frontend?
问题描述
我在x86_64工作站上使用Ubuntu 16.04,并且正在用C ++交叉编译一个小型演示程序,并将其部署到运行ARM体系结构的嵌入式linux目标( environment-setup-cortexa9hf-neon-poky-linux-gnueabi
, arm-poky-linux-gnueabi-g ++
).
I am using Ubuntu 16.04 on x86_64 workstation, and I'm cross-compiling a small demo program in C++, and deploying it to an embedded linux target running ARM architecture (environment-setup-cortexa9hf-neon-poky-linux-gnueabi
, arm-poky-linux-gnueabi-g++
).
我能够成功做到这一点,这使我可以在命令行上进行调试会话:
I am able to successfully do this which gives me a debug session on commandline:
目标:
rpm -ivh gdbserver-7.10.1-r0.cortexa9hf_neon.rpm
gdbserver :9091 ${APPNAME}
主机:
sudo apt-get install gdb-multiarch
gdb-multiarch $APPNAME
target remote 192.168.0.212:9091
...我现在可以在命令行上使用gdb-multiarch了!
... I can now use gdb-multiarch on commandline!
但是从这里开始...我真的很想能够使用许多 gdb
前端工具之一来提供GUI来设置断点并逐步执行代码(类似于 gdbgui
,或使用 vscode
并配置调试器).是否有任何专门支持 gdb-multiarch
的 gdb
前端工具?
However from here... I really want to be able to use one of the many gdb
frontend tools to provide a GUI to set breakpoints and step through the code (akin to gdbgui
, or using vscode
and configuring for a debugger). Are there any gdb
frontend tools that specifically support gdb-multiarch
?
我尝试使用的任何工具,我相信无论它使用什么基础gdb可执行文件,都会由于体系结构不匹配而出现此错误:
Any tool I try, I believe no matter what it uses base gdb executable and gives this error because of mismatched architecture:
target remote 192.168.0.212:9091
Remote debugging using 192.168.0.212:9091
warning: Architecture rejected target-supplied description
Remote 'g' packet reply is too long: 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000070fdff7e00000000c0fafc76100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
更新1-
我可以使用 ddd
工具使它正常工作:
I can kinda sorta get this to work using ddd
tool:
ddd --eval-command ="target remote $ MY_TARGET_IP:9091" --debugger gdb-multiarch
但是!这是古老的越野车,我现在无法在已加载的.so中设置断点.
However! This is ancient and buggy, and I can't set breakpoints in loaded .so's right now with this.
我尝试了 gdbgui
及其选项来指定调试器,但目前也无法正常工作.我在此处提交了功能请求报告:
I tried gdbgui
with its options to specify debugger, but that's not currently working either. I filed a feature request report here:
https://github.com/cs01/gdbgui/issues/237
推荐答案
我找到了使用 gdbgui
的方法,但是这需要我根据我的特定远程目标体系结构从源代码重建gdb.我如何使其工作的详细信息在这里:
I found a way using gdbgui
, but it required me to rebuild gdb from source code against my specific remote target architecture. Details of how I got it to work are here:
https://github.com/cs01/gdbgui/issues/237
以上链接断开时的重要位:TLDR解决方案:
Important bits in case the above link breaks: TLDR Solution:
我试图从ubuntu apt repos依赖于预构建gdb-multiarch,但没有用.当我决定下载gdb并在配置arm-linux-gnuabi目标架构时从源代码重建时.
I was trying to rely on a prebuild gdb-multiarch from ubuntu apt repos, which didn't work. When I decided to download gdb and rebuild from source while configuring for arm-linux-gnuabi target arch.
构建方法:
下载了最新的gdb源代码
downloaded latest gdb source code
将其解压缩,进入文件夹,并按如下所示进行构建:
unzip it, go into folder, and build it like this:
./configure --host=x86_64-pc-linux-gnu --build=x86_64-pc-linux-gnu --target=arm-linux-gnuabi && make -j8 && sudo make install
重要的是要注意,对于我的特定远程gdb服务器,它在ARM上运行,因此我必须在configure中说 target = arm-linux-gnuabi
.GDB正在为我的PC x86架构构建,但是它知道在调试时将目标识别为ARM!
Important to note that for my particular remote gdb server it's running on ARM so i had to say target=arm-linux-gnuabi
in configure. GDB is building for my PC x86 arch, but it knows when debugging to recognize the target as ARM!
现在,默认情况下将 arm-linux-gnuabi-gdb
安装到/usr/local/bin
...,但是您可以提供 prefix =< path>
到您要在上面的 ./configure
脚本中安装的位置.
Now, arm-linux-gnuabi-gdb
is installed by default to /usr/local/bin
... but you can instead provide prefix=<path>
to where you want it to install in ./configure
script above.
使用此功能,我可以构建名为 arm-linux-gnuabi-gdb
的gdb的辅助副本,可以像这样将其馈送到 gdbgui
:
Using this, I was able to build a secondary copy of gdb called arm-linux-gnuabi-gdb
which i could feed to gdbgui
like this:
gdbgui -g arm-linux-gnuabi-gdb
从那里,我可以给gdb命令连接到我的远程gdbserver.我必须事先设置断点.我的 gdb
命令就像这样来设置一些断点:
From there, I can give gdb commands to connect to my remote gdbserver. I'm having to set breakpoints beforehand. My gdb
commands are like this to set a few breakpoints:
set breakpoint pending on
break my_object.cpp:<line number for breakpoint>
b example_function_name
target remote <remote arm machine IP>:<gdbserver port>
c
效果很好!这比在远程目标上的命令行上运行gdb更好.
Works great! This is leaps and bounds better than running gdb on commandline on my remote target.
这篇关于如何在具有GDB GUI前端的PC上为ARM gdbserver执行PC上的远程gdb会话?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!