简体   繁体   English

我可以使用Eclipse CDT调试预构建的C ++可执行文件吗?

[英]Can I use Eclipse CDT to debug a prebuilt C++ executable?

On Linux, I have some C++ programs built with my own makefiles, and I'm looking for some GUI debuggers to debug them at source level. 在Linux上,我有一些使用自己的Makefile构建的C ++程序,并且我正在寻找一些GUI调试器以在源代码级对其进行调试。

Previously I use KDbg(2.5.2) on openSUSE(12.3). 以前,我在openSUSE(12.3)上使用KDbg(2.5.2)。 It works but with some very annoying limitation, eg, I cannot set a breakpoint when the debugged program is not trapped by Kdbg -- I mean, in order to set a new breakpoint, I have to set it before the program is launched or the program pauses on hitting an already set breakpoint. 它可以工作,但是有一些非常烦人的限制,例如,当调试的程序没有被Kdbg捕获时,我无法设置断点-我的意思是,要设置一个新的断点,我必须在程序启动之前设置它, 或者程序在达到已设置的断点时暂停。

Now I try to use Eclipse CDT. 现在,我尝试使用Eclipse CDT。 I got eclipse-cpp-juno-SR2-linux-gtk.tar.gz but find that I don't know how to load my executable so to start debugging. 我得到了eclipse-cpp-juno-SR2-linux-gtk.tar.gz,但是发现我不知道如何加载可执行文件才能开始调试。

I googled with words like 『eclipse debug pre-built C binary』, but few seems to care about this feature. 我用诸如“ eclipse debug pre-built C binary”之类的词搜索,但似乎很少有人关心此功能。

Can Eclipse CDT really do that? Eclipse CDT真的可以做到吗? If Eclipse CDT can't, is there any better alternatives to KDbg? 如果Eclipse CDT无法做到,那么KDbg会有更好的替代方法吗? Please help. 请帮忙。

在此处输入图片说明

According to hint from this answer, https://stackoverflow.com/a/248119/151453 , I finally figure out how to do it. 根据这个答案的提示, https://stackoverflow.com/a/248119/151453 ,我终于弄清楚了该怎么做。

The key point is: In the Eclipse CDT project, create/edit a Launch Configuration so to tell the debugger what executable to load. 关键点是:在Eclipse CDT项目中,创建/编辑启动配置,以告知调试器要加载的可执行文件。

Now I have to admit, Eclipse CDT does quite well in C++ code debugging far better than KDbg. 现在我不得不承认,Eclipse CDT在C ++代码调试中的表现非常好,远胜过KDbg。

Some screen shot below, on openSUSE 12.3 . 以下是openSUSE 12.3上的一些屏幕截图。

F:\\ ChjKeep \\ chj.dev \\桌面\\ AUTO-SNAP \\向导prjtype.pngF:\\ ChjKeep \\ chj.dev \\桌面\\ AUTO-SNAP \\ CDT-prjdir.pngF:\\ ChjKeep \\ chj.dev \\桌面\\ AUTO-SNAP \\ CDT-prjwiz-finish.pngF:\\ ChjKeep \\ chj.dev \\桌面\\ AUTO-SNAP \\ CDT-菜单prjprop.pngF:\\ ChjKeep \\ chj.dev \\桌面\\ AUTO-SNAP \\ CDT-prjprop-runsetting.pngF:\\ ChjKeep \\ chj.dev \\桌面\\ AUTO-SNAP \\ CDT-PRJ-exepath.png

Now we can Run -> Debug (F11) 现在我们可以运行->调试(F11) F:\\ ChjKeep \\ chj.dev \\桌面\\ AUTO-SNAP \\ CDT要约开关兼pers.png

Debugger automatically pauses the program at main()'s first statement. 调试器自动在main()的第一条语句处暂停程序。

F:\\ ChjKeep \\ chj.dev \\桌面\\ AUTO-SNAP \\ CDT  - 暂停 -  main.png

The Stand-alone Debugger is an Eclipse application which packages the Eclipse plug-ins from the CDT (C/C++ Development Tools) project into an application that can be started from a command-line script: 独立调试器是一个Eclipse应用程序,它将CDT(C / C ++开发工具)项目中的Eclipse插件打包到可以从命令行脚本启动的应用程序中:

bash /path/scripts/cdtdebug.sh -e executable [args] bash /path/scripts/cdtdebug.sh -e可执行文件[args]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM