[SOLVED] Not able to debug a library compiled with debug information
ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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.
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.
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?
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
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?
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.
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.