Supported on windows
Supported on linux
Not supported on embedded
Supported on android

sharedlibrary command

Forces GDB to load symbols for the specified shared libraries or all loaded shared libraries.

Syntax

sharedlibrary
sharedlibrary [Library Name]
sharedlibrary [Regular Expression]
share [...]

Parameters

Library Name
Specifies the library to load debugging symbols for.
Regular Expression
When specified, GDB will load the symbols for all currently loaded libraries matching the specified expression.

Remarks

Normally, GDB will load the shared library symbols automatically. You can control this behavior using set auto-solib-add command. However, in some cases (e.g. when debugging with gdbserver and having incompatible symbols or using old Android toolchains) GDB will not load the symbols automatically. In this case you can use the info sharedlibrary command to list the loaded shared libraries and the sharedlibrary command to force the symbols to be loaded.

If GDB does not automatically load debugging symbols for your library when debugging with gdbserver, please check the search path using the set solib-search-path command.

Examples

In this example we will disable shared library loading using the set auto-solib-add command, then run the application, list the source files and load the symbols manually:

(gdb) set auto-solib-add off
(gdb) break main
Breakpoint 1 at 0x80484ed: file main.cpp, line 7.
(gdb) run
Starting program: /home/testuser/libtest/testApp

Breakpoint 1, main () at main.cpp:7
7 printf("In main()\n");
(gdb) info sources
Source files for which symbols have been read in:

/home/testuser/libtest/main.cpp

Source files for which symbols will be read in on demand:


(gdb) info sharedlibrary
From To Syms Read Shared Object Library
0xb7fde820 0xb7ff6b9f No /lib/ld-linux.so.2
0xb7fd83a0 0xb7fd84c8 No /home/testuser/libtest/libTest.so
0xb7e30f10 0xb7f655cc No /lib/i386-linux-gnu/libc.so.6
(gdb) sharedlibrary libTest
Reading symbols from /home/testuser/libtest/libTest.so...done.
Loaded symbols for /home/testuser/libtest/libTest.so
(gdb) info sources
Source files for which symbols have been read in:

/home/testuser/libtest/main.cpp

Source files for which symbols will be read in on demand:

/home/testuser/libtest/lib.cpp
(gdb) break lib.cpp:5
Breakpoint 2 at 0xb7fd846e: file lib.cpp, line 5.
(gdb) continue
Continuing.
In main()

Breakpoint 2, func () at lib.cpp:5
5 printf("In func()\n");

Compatibility with VisualGDB

Normally VisualGDB automatically manages the shared library symbol loading. Alternatively you can always issue the sharedlibrary command using the GDB Session window.

See also