Problem with debugger and shared libraries

CodeLite installation/troubleshooting forum
marfi
CodeLite Expert
Posts: 159
Joined: Mon Nov 03, 2008 9:17 pm
Contact:

Problem with debugger and shared libraries

Post 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
User avatar
eranif
CodeLite Plugin
Posts: 6372
Joined: Wed Feb 06, 2008 9:29 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: Problem with debugger and shared libraries

Post 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
Make sure you have read the HOW TO POST thread
marfi
CodeLite Expert
Posts: 159
Joined: Mon Nov 03, 2008 9:17 pm
Contact:

Re: Problem with debugger and shared libraries

Post 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
User avatar
eranif
CodeLite Plugin
Posts: 6372
Joined: Wed Feb 06, 2008 9:29 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: Problem with debugger and shared libraries

Post 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
Make sure you have read the HOW TO POST thread
marfi
CodeLite Expert
Posts: 159
Joined: Mon Nov 03, 2008 9:17 pm
Contact:

Re: Problem with debugger and shared libraries

Post by marfi »

A breakpoint placed in OnInit() or main() function helped me. Thank you for your effort!
Michal
ndk
CodeLite Enthusiast
Posts: 10
Joined: Sun Jun 14, 2009 6:58 pm
Contact:

Re: Problem with debugger and shared libraries

Post 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. :)
ndk
CodeLite Enthusiast
Posts: 10
Joined: Sun Jun 14, 2009 6:58 pm
Contact:

Re: Problem with debugger and shared libraries

Post by ndk »

For example see attached patch.
You do not have the required permissions to view the files attached to this post.
Post Reply