LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (http://www.linuxquestions.org/questions/programming-9/)
-   -   Not able to debug a library compiled with debug information (http://www.linuxquestions.org/questions/programming-9/not-able-to-debug-a-library-compiled-with-debug-information-907237/)

gregorian 10-09-2011 07:48 AM

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.

dwhitney67 10-09-2011 03:41 PM

Quote:

Originally Posted by gregorian (Post 4493769)
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.

gregorian 10-09-2011 10:21 PM

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?

ta0kira 10-09-2011 10:34 PM

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

gregorian 10-11-2011 11:01 AM

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?

dwhitney67 10-11-2011 11:17 AM

Quote:

Originally Posted by gregorian (Post 4495610)
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.

gregorian 10-29-2011 09:53 AM

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.


All times are GMT -5. The time now is 12:27 PM.