I am trying to setup the gdb debugger in eclipse to attach to a remote program. Here is the setup that I am using:
For the development PC (dev), I am using Eclipse Mars on a Windows 7 PC. Eclipse is set to use the GCC/G++ cross compiler and gdb as the remote debugger. I am using Sourcery CodeBench Lite as the development tool in windows.
dev> gdb --version
dev> GNU gdb (Sourcery CodeBench Lite 2014.05-25) 7.7.50.20140217-cvs
The target PC is a RHEL 7, where I use gdbserver so that I can debug my application remotely.
target> gdbserver --version
target> GNU gdbserver (GDB) Red Hat Enterprise Linux 7.6.1-64.el7
Copyright (C) 2013 Free Software Foundation, Inc.
I have two debug configuration in eclipse, one for remote debug and another for attaching to a remote program that is running in target PC. I have no problem debugging my program using the remote debug configuration, however, when I try to attach to the remote program, I get the following error:
Here is how I set up my debugger to attach to a remote application:
I use the following gdbinit script:
handle SIG34 nostop noprint pass
set verbose on
set sysroot
I have also tried using the same GDB versions on both sides and got the same result. At this point, I am open to any suggestion!
Ok, So I think I got it working. The problem seems to be because of the old GDB version that I was using on the target PC. As I mentioned in my question, I was using GDB 7.6.1-64.el7. To update the GDB, I downloaded the latest source code from http://ftp.gnu.org/gnu/gdb/ . Remember to update both gdb and gdbserver. The gdbserver is provided in the download package. Here are the steps that I took after I put gdb archive in target/tmp :
target_pc/tmp> gtar -xvf gdb-7.11.tar.gz
target_pc/tmp> cd gdb-7.11
target_pc/tmp/gdb-7.11> ./configure
target_pc/tmp/gdb-7.11> make
target_pc/tmpgdb-7.11> cd gdb/gdbserver
target_pc/tmpgdb-7.11/gdb/gdbserver> ./configure
target_pc/tmpgdb-7.11/gdb/gdbserver> make
after a successful built you can either use make install or copy the gdb and gdbserver binary and put it to the /usr/bin or /bin directory. Also you need to restart the gdbserver:
/usr/bin/gdbserver --remote-debug --multi :8000
you can add this line to /etc/rc.local so that you start the gdbserver upon the linux boot.
Related
When debugging a c++ app, and hitting a breakpoint, gdb terminates the debug session when I click on a variable to expand its content in the Variables panel.
The displayed message is: <terminated, exit value: 0>gdb (10.1.90.20210103)
Printing the variable from the Debugger Console works correctly.
Debugging was working OK some weeks ago. The major changes that happen recently was a debian upgrade from 10 to 11 (bullseye), and an upgrade of the Eclipse version.
Activating gdb traces following where can I find GDB traces, I could see the commands sent to GDB, but no particular error before GDB stopped.
Any idea of what could cause this issue?
Eclipse Version: 2021-12 (4.22.0), Build id: 20211202-1639 running on linux debian bullseye.
I answer my own question.
After checking related answers, I suspect that the problem is linked to stl pretty printing in Eclipse (which was working fine before). I tried different version of Eclipse and gdb, and finally managed to fix the issue by using a previous version of gdb (8.3 instead of 10.1).
Here is the procedure that I followed (I'm not sure all steps are mandatory).
Reinstalled eclipse from scratch
Deleted the .metadata directory and recreated the eclipse workspace
Downloaded version 8.3 of gdb sources, and compiled it with python support ('./configure --with-python'). Note that libgmp-dev and python2.7-dev debian packages must be installed.
Copied gdb-8.3 somewhere under /usr/local/
Updated eclipse preference settings : C-C++/Debug/GDB and change GDB Debugger to the pach where gdb 8.3 executable was located under /usr/local/.
Checked in Debugger Console that the right gdb version is displayed. If this is not the case, you may have to set gdb using Debug As.../Debug Configurations/Debugger/GDB Debugger
I am trying to build a project for a raspberry pi 4, using windows 10 as the building platform, I have the compiler installed, arm-none-eabi-gcc however every piece of information I've learned about it relates to how to run it on a linux machine, and I don't really want to run a vm just to load the linux environment, so how do I run the compiler on windows 10, Do I run it from Cmd? or is there a different method to do this?
You could check this PreBuilt GNU Toolchain for building natively on Win10.
Otherwise you could also setup a WSL environment in your win10, then you would also be able use any linux toolchains.
You can download the IDE DS-5 Community Edition
https://developer.arm.com/tools-and-software/embedded/legacy-tools/ds-5-development-studio/editions/community-edition
You can download the toolchains:
https://developer.arm.com/tools-and-software/open-source-software/developer-tools/gnu-toolchain/gnu-a/downloads
Then follow the steps in this tutorial:
https://developer.arm.com/tools-and-software/embedded/legacy-tools/ds-5-development-studio/resources/tutorials/getting-started-with-ds-5-ce-and-armv8-foundation-platform
https://community.arm.com/developer/tools-software/tools/b/tools-software-ides-blog/posts/running-bare-metal-software-on-the-raspberry-pi-3-using-arm-ds-5
You should have the arm-none-eabi-gcc.exe for Windows Compile.
Also, you have the linux environment like MinGW and use installed terminal(xterm).
then, you have to copy the .so files into MinGW /lib or /usr/lib folder under C:/MinGW.
Hope this would be helpful for you.
In brief: How do I change the path to gdb to point to the right location?
Details
I know this topic is a quite common one, but I am desperate. I installed eclipse CDT on my MacOS High Sierra. Then after some time of searching I found out how to install the GDB debugger including code-signing. So I installed gdb 8.1 at /usr/local/bin (forgot which method I exactly used). It all seemed fine (gdb --version in console etc.) but then I found out that gdb 8.1 does not work under MacOS.
The way out of my dilemma seemed this post: https://stackoverflow.com/a/49104154/1552080
which created a parallel installation of gdb at /usr/local/Cellar/gdb/8.0.1/bin.
I did all the code signing stuff and entered the path to gdb 8.0.1. Furthermore I entered the new path in the eclipse debugger settings and modified my .bash_profile to point to the 8.0.1 location.
Nevertheless, eclipse seemed to point to the gdb 8.1 location /usr/local/bin. That's why I deleted the 8.1 gdb executable. Since then I always get an error message:
"Error with command: /usr/local/bin/gdb --version Cannot run program
"/usr/local/bin/gdb": Unknown reason"
Obviously, eclipse still looks in the wrong place for a debugger.
Maybe it is important to mention that when installing gdb 8.1 I did some trick in the save mode (see point 14 of https://gist.github.com/gravitylow/fb595186ce6068537a6e9da6d8b5b96d)
any help appreciated
2018-05-13, Update: the error above still persists after I copied the gdb 8.0.1 executable to the location /usr/local/bin
I've seen some other stakoverflow question like this one:
CLion Installation: Cmake compilers not found, GDB not found
But it's not quite the same problem.
My problem is that only my gdb.exe is not found by Clion. I can compile and run programs without problem, but when i need to debug the program tell me that only the debbuger is incorrect.
The problem is that my gbd.exe is present in my cygwin/bin folder
and i have it also in my PATH (system variable)
What i've done so far:
delete, shutdown and reinstall cygwin from scratch.
Install Netbeans and try to run with cygwin config (and debugger) -> everthing is working and i can debug my program. I also try to select it manualy.
So the real question is why Clion think my gdb is not present?
An how can i make it work?
Thank you for your help
Try to install GDB version 7.10.1
My settings:
Short answer: check what versions of gcc, g++ and gdb you have installed. They should be of the same major version.
Long answer:
Try to launch gdb.exe from cygwin terminal. You will probably get something like this (I'm using mingw64 from msys2 so folder will be different):
$ gdb
C:/msys64/mingw64/bin/gdb.exe: error while loading shared libraries: libgcc_s_seh-1.dll:
cannot open shared object file: No such file or directory
But you have gcc installed so you will have this DLL inside C:/msys64/mingw64/bin (in your case folder is different). The problem is that your gdb and gcc are of different major versions. I got this problem when installed mingw-w64-x86_64-gcc-7.3.0-2 with mingw-w64-x86_64-gdb-8.2.1-1. That's why gdb was not able to launch and CLion was not able to check GDB version thus outputting "Not found" error.
If this is the case - remove gdb and install it again. Now with correct major version (same as gcc). Since you're using cygwin, launch cygwin setup again, search for gdb package (don't forget to change view to full) and change version to be the same as gcc. Or, alternatively, you can change gcc version to be the same as gdb (in my case this wasn't possible).
I have a program that I'd like to run remotely under Valgrind using the Linux Tools remote Valgrind profiler.
I normally debug remotely on a headless server (which has special hardware, so it has to be done remotely on that machine) using RSE, which works fine. Both my machine and the target are Linux machines.
I am now trying to get Valgrind working through Eclipse using the Linux Tools plugin. I have Valgrind 3.10 installed on the remote target machine, and I can run it up manually (outside of Eclipse):
Remotely:
valgrind --vgdb=full --vgdb-error=0 /path/to/app --args
vgdb --port=2345 --pid=XXXX
Locally, connect with gdb with target remote host:2345.
However, I can't work out how to get the "Valgrind (remote)" Eclipse tooling to emulate this, aping the "RemoteTools" setup shown here: .
When I write in a "To:" executable that starts with "rse:/", I get an error in the Profiling Tools settings window top corner saying [Valgrind Options]: Couldn't determine version of Valgrind. What should I write here to get a working remote Valgrind connection?
Haven't found more recent posts on the topic, maybe it will be useful for somebody. I also didn't manage to use remote valgrind plugin with RSE. Seems like only dstore connection type will work for Linux Tools remote valgrind, because SSH or FTP didn't work for me. rseserver requires Perl and Java, and I didn't have them on my target.
I had to use this complicated solution via Launch Group combining this and this solutions. Preconditions: valgrind and vgdb are installed on remote target.
Write a script start_remote_valgrind.sh
set -x
remote_ip=192.168.7.2
remote_port=2222
app_name=test_app
remote_dir=/usr/local/bin/
local_dir=/home/project_name/
ssh -T root#$remote_ip killall -9 vgdb
ssh -T root#$remote_ip killall -9 valgrind
scp $local_dir$app_name root#$remote_ip:$remote_dir$app_name
ssh root#$remote_ip valgrind --vgdb=full --vgdb-error=0 --leak-check=full -v $remote_dir$app_name &
sleep 1
ssh root#$remote_ip vgdb --port=$remote_port
Create debug configuration Run->Debug Configurations->C/C++ remote application:
2.1 On themain tab set the project name and app binary
2.2 In the bottom of the configuration window click "Select Other" link and select "GDB (DSF) manual remote launcher"
2.3 On Debugger tab set GDB debugger for you target platform, command line script .gdbinit.
2.4 On Debugger->connection tab set TCP connection, remote ip and port.
Create external tool Run->external tools->external tools configuration...
Create Launch Group Run->Debug Configurations->Launch Group
external tool must be in Run configuration, remote gdb in Debug. The benefit of this approach is that remote valgrind output is printed in Eclipse console, so you don't need to launch vgdb manually in a separate console and see messages in separate window.