How do I perform a remote gdb session on a PC for ARM gdbserver WITH GDB GUI frontend?

戏子无情 提交于 2021-02-10 13:15:52

问题


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:

Target:

rpm -ivh gdbserver-7.10.1-r0.cortexa9hf_neon.rpm
gdbserver :9091 ${APPNAME}

Host:

sudo apt-get install gdb-multiarch

gdb-multiarch $APPNAME

target remote 192.168.0.212:9091

... I can now use gdb-multiarch on commandline!

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?

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

UPDATE 1 --

I can kinda sorta get this to work using ddd tool:

ddd --eval-command="target remote $MY_TARGET_IP:9091" --debugger gdb-multiarch

However! This is ancient and buggy, and I can't set breakpoints in loaded .so's right now with this.

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


回答1:


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

Important bits in case the above link breaks: TLDR Solution:

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.

Build method:

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

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!

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.

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

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

Works great! This is leaps and bounds better than running gdb on commandline on my remote target.



来源:https://stackoverflow.com/questions/52732183/how-do-i-perform-a-remote-gdb-session-on-a-pc-for-arm-gdbserver-with-gdb-gui-fro

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!