LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 10-09-2011, 07:48 AM   #1
gregorian
Member
 
Registered: Apr 2006
Location: India
Posts: 473

Rep: Reputation: 33
Not able to debug a library compiled with debug information


I have an executable that depends on several dynamically loaded libraries. I have built the application and the library with the -g information, but I'm unable to set break points. Even if I choose mark breakpoint on shared library load, it does not hit the breakpoint. Is there some special method I need to use when debugging libraries.
 
Old 10-09-2011, 03:41 PM   #2
dwhitney67
Senior Member
 
Registered: Jun 2006
Location: Maryland
Distribution: Kubuntu, Fedora, RHEL
Posts: 1,523

Rep: Reputation: 332Reputation: 332Reputation: 332Reputation: 332
Quote:
Originally Posted by gregorian View Post
I have an executable that depends on several dynamically loaded libraries. I have built the application and the library with the -g information, but I'm unable to set break points. Even if I choose mark breakpoint on shared library load, it does not hit the breakpoint. Is there some special method I need to use when debugging libraries.
No; from what you have described, you are doing things correctly. Is there something else perhaps that you might have left out?

Or maybe you should share with us how you built the library, and how you built the application.
 
Old 10-09-2011, 10:21 PM   #3
gregorian
Member
 
Registered: Apr 2006
Location: India
Posts: 473

Original Poster
Rep: Reputation: 33
Actually, there were two issues.

1. It seems I have to attach to a running process. Starting the program in GDB won't read any debug symbols.

2. After I did step 1, I could put breakpoints. But there were several instances where the program was crashing. It turns out I need to compile each individual library with exactly the same compile flags, or it doesn't seem to work. There are about twenty individual libraries. Some of them don't have debug information, and some are optimized. But I have only one library of interest and that is compiled with the debug flags and no optimization. Can't I debug only that?
 
Old 10-09-2011, 10:34 PM   #4
ta0kira
Senior Member
 
Registered: Sep 2004
Distribution: FreeBSD 9.1, Kubuntu 12.10
Posts: 3,078

Rep: Reputation: Disabled
How many libraries of the 20 or so does the one you're debugging depend on? Can you write a testing framework that only needs to link to the library you're debugging?
Kevin Barry
 
Old 10-11-2011, 11:01 AM   #5
gregorian
Member
 
Registered: Apr 2006
Location: India
Posts: 473

Original Poster
Rep: Reputation: 33
Well, I'm looking for a general solution to the problem. The program won't compile unless all the libraries are installed. I'm interested in compiling one of the many libraries that it uses. I have built only that with debugging symbols. Can I debug only that?
 
Old 10-11-2011, 11:17 AM   #6
dwhitney67
Senior Member
 
Registered: Jun 2006
Location: Maryland
Distribution: Kubuntu, Fedora, RHEL
Posts: 1,523

Rep: Reputation: 332Reputation: 332Reputation: 332Reputation: 332
Quote:
Originally Posted by gregorian View Post
Well, I'm looking for a general solution to the problem. The program won't compile unless all the libraries are installed. I'm interested in compiling one of the many libraries that it uses. I have built only that with debugging symbols. Can I debug only that?
There's no way for you to create a small, test, application that calls upon the library that you wish to debug?

There should nothing stopping you from building one library with debugging (symbolic) information, and to leave the other libraries as is. The one with the debugging symbols should be able to be debugged, whereas the others will not be.
 
Old 10-29-2011, 09:53 AM   #7
gregorian
Member
 
Registered: Apr 2006
Location: India
Posts: 473

Original Poster
Rep: Reputation: 33
The problem was that the program was compiled with a newer version of gcc, while gdb was of an older version. Using the newer version of the debugger worked.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Extract dwarf information debug a section webquinty Programming 5 05-19-2011 05:17 AM
debug shared library pike87 Programming 3 03-08-2011 12:26 AM
How to find a library is compiled in debug mode or release mode babu198649 Linux - Newbie 1 05-26-2009 09:42 AM
How to obtain debug information from a section!!!!! webquinty Linux - Newbie 2 10-30-2008 04:23 AM
[debug]what does the following debug information mean icoming Programming 21 06-08-2004 02:13 AM


All times are GMT -5. The time now is 03:38 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration