How can I debug a valgrind run with gdb in Eclipse?
I start the program like this:
Terminal A:
valgrind vgdb=yes --vgdb-error=0 ./a.out
It can debug it from another terminal like this:
Terminal B:
gdb ./a.out
target remote |vgdb
But I can't get this to work in Eclipse... So, I want to do graphically in Eclipse what I can do via command line in terminal B.
I tried many ways to set up debug configurations in Eclipse, but I can't get it to work.
The closest I got was via "C++ Attach to Application", in which I loaded a customized .gdbinit according to this post at the end: https://www.eclipse.org/forums/index.php/t/681832/
After starting that configuration, the valgrind run continues (to the next error), but Eclipse then reports that the application terminated, and it also terminates the gdb session.
Two more links that might be helpful: https://bugs.eclipse.org/bugs/show_bug.cgi?id=269687 http://www.eclipse.org/forums/index.php/t/354700/,
I am using Eclipse 4.5.1 (Mars.1)
EDIT:
I made some progress- I found two ways that almost work as I'd wish:
1) I use the "C/C++ Application" setting with this in .gdbinit:
file /path/to/a.out
target remote | /usr/bin/vgdb
set sysroot /
define run
Note that I had to specifically add the "file" statement to gdbinit. The drawback in this case is that Eclipse is waiting for the program to terminate forever when I try to quit/kill (because it never actually started running it...). I have to click "Terminate and Remove" manually afterwards.
Would be nice if you can tell me a trick/hack how to prevent that.
2) I use "C++ Attach to Application" with the same .gdbinit from above. Eclipse will ask me for the process to attach to; I search for and select valgrind. I can now step through the code, but I cannot set breakpoints within Eclipse. I can do that only in the gdb shell via "break file.cpp:line".
Any ideas how to resolve that?