3

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.

Previously I use KDbg(2.5.2) on openSUSE(12.3). It works but with some very annoying limitation, e.g., 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.

Now I try to use 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.

I googled with words like 『eclipse debug pre-built C binary』, but few seems to care about this feature.

Can Eclipse CDT really do that? If Eclipse CDT can't, is there any better alternatives to KDbg? Please help.

enter image description here

2 Answers 2

4

According to hint from this answer, https://stackoverflow.com/a/248119/151453 , I finally figure out how to do it.

The key point is: In the Eclipse CDT project, create/edit a Launch Configuration so to tell the debugger what executable to load.

Now I have to admit, Eclipse CDT does quite well in C++ code debugging far better than KDbg.

Some screen shot below, on openSUSE 12.3 .

F:\ChjKeep\chj.dev\桌面\AUTO-SNAP\wizard-prjtype.png F:\ChjKeep\chj.dev\桌面\AUTO-SNAP\cdt-prjdir.png F:\ChjKeep\chj.dev\桌面\AUTO-SNAP\cdt-prjwiz-finish.png F:\ChjKeep\chj.dev\桌面\AUTO-SNAP\cdt-menu-prjprop.png F:\ChjKeep\chj.dev\桌面\AUTO-SNAP\cdt-prjprop-runsetting.png F:\ChjKeep\chj.dev\桌面\AUTO-SNAP\cdt-prj-exepath.png

Now we can Run -> Debug (F11) F:\ChjKeep\chj.dev\桌面\AUTO-SNAP\cdt-offer-switch-pers.png

Debugger automatically pauses the program at main()'s first statement.

F:\ChjKeep\chj.dev\桌面\AUTO-SNAP\cdt-pause-main.png

Sign up to request clarification or add additional context in comments.

2 Comments

Hi, How should I add the source code of the executable and other object files to the project?
Actually you DON'T have to! If a C++ program is compiled with -g flag, the resulting executable(exe) has "debug info" embedded inside that exe. And the debug info includes the path to the source files that was used to compile that exe. So, when you try to step into a function, the debugger automatically open the related .cpp file. BUT, if you want to set a breakpoint on a known function(Foo), you have to open foo.cpp manually in Eclipse editor and set breakpoint there, this can be a bit cumbersome. In short, the logic to locate a .cpp is totally different, for a compiler, and for a debugger
1

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:

bash /path/scripts/cdtdebug.sh -e executable [args]

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.