Page 1 of 1

Problem with debugger and shared libraries

Posted: Mon Mar 16, 2009 6:34 pm
by marfi
Hi, I've discovered that it is quite difficult to debug shared libraries with the CL. The problem is that breakpoints set the in shared library's source code don't stop the debug process if the library is build and linked dynamically. If the library is build statically, the the breakpoints work (nearly) fine.

The debugger's output in a case it failed is as follows:

Code: Select all

Debug session started successfully!
Debuggee process ID: 8403
GNU gdb 6.8-debian
Copyright (C) 2008 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "i486-linux-gnu"...
set unwindonsignal on
set breakpoint pending on
set width 0
set height 0
No source file named /home/michal/Src/Projekty/wxXS/src/XmlSerializer.cpp.
No source file named /home/michal/Src/Projekty/wxXS/src/XmlSerializer.cpp.
Continuing...
[Thread debugging using libthread_db enabled]
[New Thread 0xb6804700 (LWP 8403)]
Debug session ended
This log tells that a file XmlSerializer.cpp doesn't exist but it is not the true. Moreover, If the library is linked statically, the breakpoint is found and work well.
Any idea where is the problem and how it can be fixed?

Best regards
Michal

Re: Problem with debugger and shared libraries

Posted: Mon Mar 16, 2009 7:02 pm
by eranif
This is a gdb problem.
To workaround it, place the breakpoint *after* your application has started and symbols are loaded into the memory.

BTW, I encountered such problems only when loading libraries using dlopen()

Eran

Re: Problem with debugger and shared libraries

Posted: Tue Mar 17, 2009 12:14 pm
by marfi
Hi Eran,
thank you for the advice. Unfortunately, the workaround you suggested is useful only in some cases and you cannot use it if you want to debug for example some class used in a main application frame's constructor, because you just cannot manage to add some breakpoint into this code AFTER debug symbols are loaded and BEFORE the application is started... Is there any way how to do it by the CL itself? I think some solution must exists because Code::Blocks IDE can debug the same project with no problem.

My system is: Ubuntu 8.10, GCC 4.3.x, GDB 6.8

Best regards
Michal

Re: Problem with debugger and shared libraries

Posted: Tue Mar 17, 2009 1:30 pm
by eranif
The bug IS gdb bug and not codelite bug. The problem is that GDB MI interface used by codelite (unlike C::B which uses the client interface combined with regexes) is probably broken - which is irrelevant since codelite is not going to switch to the standard GDB interface.

Have u tried to set a breakpoint in OnInit() (at this point all DLLs should have been loaded) and once stopped there, placing breakpoint in the constructor?
Eran

Re: Problem with debugger and shared libraries

Posted: Tue Mar 17, 2009 4:23 pm
by marfi
A breakpoint placed in OnInit() or main() function helped me. Thank you for your effort!
Michal

Re: Problem with debugger and shared libraries

Posted: Sat Jul 11, 2009 6:12 pm
by ndk
eranif wrote:which is irrelevant since codelite is not going to switch to the standard GDB interface.
But why? This is a useful functionality and nothing terrible will happen if limited use of CLI. Something is better than nothing. :)

Re: Problem with debugger and shared libraries

Posted: Sat Jul 11, 2009 10:47 pm
by ndk
For example see attached patch.