How to prevent GDB from loading debugging symbol for a (large) library?
Asked Answered
H

1

8

While debugging a Qt 5 application, I am sometimes not interested in the internals of Qt 5 but in the structure of the application itself. Therefore I do not need to load all debugging symbols of the Qt 5 libraries since these take a few seconds to load.

Is it possible to prevent GDB from loading symbols for these Qt 5 libraries while keeping the debugging symbols for my application?

Hirudin answered 1/8, 2015 at 16:17 Comment(2)
Maybe this page: developer.mozilla.org/en-US/docs/Using_gdb_on_wimpy_computers might be of some use.Planck
@RichardCritten The link is broken.Indianapolis
S
13

Is it possible to prevent GDB from loading symbols for these Qt 5 libraries while keeping the debugging symbols for my application?

Yes.

As Richard Critten's comment mentions, setting auto-solib-add to 0 will prevent loading of symbols for all shared libraries, and you can then add files manually with the sharedlibrary command (which accepts a regex). If this regex is omitted, then all shared libraries are loaded.

That however would prevent auto-loading of all symbols (not just debug symbols), and would also prevent auto-loading of symbols for system libraries, which are often required to unwind the stack.

A better approach may be to save a copy of Qt5 libraries with full debug info somewhere, e.g. ~/Qt5-debug/, then run strip -g on the original libraries. That way, you will get symbolic info for all libraries, and in the rare case when you actually need full-debug info for Qt5, you can still do that using the GDB file ~/Qt5-debug/libQt5Core.so.5.2 or similar commands.

The chapter GDB Files from the GDB manual has more documentation on using such separate debugging symbols.

Studdingsail answered 1/8, 2015 at 23:36 Comment(6)
Thanks rubber duck! Shortly after posting this question I found the relevant sections in the GDB manual, hopefully you do not mind me adding them :-)Hirudin
Great thanks!!! Start debugging of Qt app on the Raspberry takes a really long time. With this option starting gdb occurs instantly.Coyotillo
You can also add this exact command to ~/.gdbinit to make it permanent.Fantan
how do i prevent a library from loading with sharedlibrary regexDeflation
@PMat Specify a regex that doesn't match the library you don't want to load?Studdingsail
@EmployedRussian I want to specify exclude a specific lib, example: exclude libboost_thread.so, it only seems to take matches not negationsDeflation

© 2022 - 2024 — McMap. All rights reserved.