Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Debugging with Eclipse CDT and GDB

I have Eclipse CDT C++ application project that uses shared library. This library is compiled with debug info and its source is available at the right path.

Now I try to debug my application with Eclipse and GDB. If I put breakpoints in my application source code, everything is fine. Then I open a source file of the included shared lib and put the breakpoint there. When launching the debug session I am warned that "No source file named xxx.cpp in loaded symbols" and execution isn't stoped at that point. If I put the same breakpoint in the same file when debugging session is already running, everything works fine. What is wrong?

Thanks for your help.

like image 988
Algirdas Avatar asked Oct 19 '09 09:10

Algirdas


People also ask

Does GDB work for C?

Gdb is a debugger for C (and C++). It allows you to do things like run the program up to a certain point then stop and print out the values of certain variables at that point, or step through the program one line at a time and print out the values of each variable after executing each line.

What does GDB mean in debugging?

GDB stands for the “Gnu DeBugger.” This is a powerful source-level debugging package that lets you see what is going on inside your program. You can step through the code, set breakpoints, examine and change variables, and so on. Like most Linux tools, GDB itself is command line driven, making it rather tedious to use.


2 Answers

I had this same problem, trying set breakpoints in Qt plugins (which are based on Windows DLL,s).

I found this discussion and the solution worked perfectly for me, though I am using a newer version of Eclipse than you were it sounds like much the same problem.

http://www.eclipse.org/forums/index.php?t=msg&goto=555294&S=2aed4155e654e34cb2e84a6fb23de9bf#msg_555294

Basically, it is to use an older gdb protocol that supports deferred breakpoints. Using the "Standard Create Process Launcher" instead of "GDB (DSF) Create Process Launcher" from Debug Configurations and I get all my DLL breakpoints set now.

Version: Helios Release Build id: 20100617-1415

CDT and GDB version 7.0.0.

Good luck!

like image 122
PhysicalEd Avatar answered Oct 24 '22 11:10

PhysicalEd


I found one topic that may answer this question: Why does Eclipse CDT ignore breakpoints?

Could it be that you are trying to set breakpoints in a shared library that has not been loaded yet. That won't work until the library has loaded. Newer gdb allow to set deferred breakpoints, but that may not (yet) be supported by CDT. A workaround is to set a breakpoint in a place that is available from the beginning that will be reached when the shared library in question is already loaded. Then set the other breakpoint in the shared library. Now it should work. It's a bit more tedious, but usually works.

coud it be the answear? I am using CDT v6.0.0.200906161748 and GDB v6.8

like image 22
Algirdas Avatar answered Oct 24 '22 11:10

Algirdas