用于valgrind + gdb的Eclipse CDT设置 [英] Eclipse CDT setup for valgrind + gdb
问题描述
如何在Eclipse中调试使用gdb运行的valgrind?
How can I debug a valgrind run with gdb in Eclipse?
我像这样启动程序:
Terminal A:
Terminal A:
valgrind vgdb=yes --vgdb-error=0 ./a.out
它可以从另一个终端调试如下:
It can debug it from another terminal like this:
终端B:
gdb ./a.out
target remote |vgdb
但是我无法在Eclipse中使用它...
因此,我想在Eclipse中以图形方式进行操作通过终端B中的命令行。
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.
我尝试了多种方法在Eclipse中设置调试配置,但是我无法使其正常工作。
I tried many ways to set up debug configurations in Eclipse, but I can't get it to work.
我得到的最接近的是通过 C ++附加到应用程序,其中我根据最后的这篇文章加载了自定义的.gdbinit: https://www.eclipse.org/forums/index.php/t/681832/
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/
启动该配置后,valgrin d运行继续(到下一个错误),但是Eclipse随后报告该应用程序已终止,并且它也终止了gdb会话。
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.
另外两个可能有用的链接:
https://bugs.eclipse.org/bugs/show_bug.cgi ?id = 269687
http:// www。 eclipse.org/forums/index.php/t/354700/ ,
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/,
我正在使用Eclipse 4.5.1(Mars.1)
I am using Eclipse 4.5.1 (Mars.1)
编辑:
我取得了一些进步-我发现了两种几乎可以正常工作的方式d wish:
I made some progress- I found two ways that almost work as I'd wish:
1)
我在.gdbinit中使用 C / C ++ Application设置:
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
我必须专门将文件语句添加到gdbinit中。
在这种情况下的缺点是,当我尝试退出/杀死程序时,Eclipse正在等待程序永久终止(因为它从未真正开始运行它...)。之后,我必须手动单击终止并删除。
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)
我将 C ++附加到应用程序与上面的.gdbinit相同。
Eclipse会要求我附加该过程;我搜索并选择valgrind。
我现在可以单步执行代码,但是无法在Eclipse中设置断点。
我只能在gdb shell中通过 break file.cpp:line来做到这一点。
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?
推荐答案
不是我最喜欢的解决方案,但是它可以在Ubuntu / Eclipse上运行:
Not my favorite solution, but its working on Ubuntu/Eclipse:
这些是我的步骤:
- 名称:
示例启动器
- 位置:
/ usr / bin / valgrind
- 参数:
-vgdb = full --vgdb-error = 0 --leak-check = full -v ./MyProg.elf参数1 ...
- Name:
Example Starter
- Location:
/usr/bin/valgrind
- Arguments:
--vgdb=full --vgdb-error=0 --leak-check=full -v ./MyProg.elf argument1 ...
文件gdb_vgdb_init的内容:
Content of File gdb_vgdb_init:
target remote | /usr/bin/vgdb
set sysroot /
define run
创建一个新的调试配置
- 类型:
C / C ++应用程序
- 名称:
示例调试器
- C / C ++应用程序:
MyProg.elf
- 参数->程序参数:不需要参数
- Debugger-> GDB命令文件:
/ path / to / gdb_vgdb_init
- Type:
C/C++ Application
- Name:
Example Debugger
- C/C++ Application:
MyProg.elf
- Arguments -> Programm Arguments: No Arguments needed
- Debugger -> GDB command file:
/path/to/gdb_vgdb_init
- 创建的外部工具
示例启动器
(在运行模式下) - 创建的C / C ++应用程序
示例调试器
(在 debug 模式下) - Created External Tool
Example Starter
(in run mode) - Created C/C++ Application
Example Debugger
(in debug mode)
Create a new Debug Configuration
新的启动组应包含:
之后,可以启动启动组。 Launchgroup将启动一个valgrind incl。 gdb已连接到它。
Afterwards the Launch Group can be started. the Launchgroup will start a valgrind incl. gdb connected to it.
这篇关于用于valgrind + gdb的Eclipse CDT设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!