Setting Breakpoints in Dynamically Loaded Libraries

dbx interacts with the following types of shared libraries:

Libraries that are implicitly loaded at the beginning of a program's execution.

Libraries that are explicitly (dynamically) loaded using dlopen(2). The names in such libraries are known only after the library has been loaded during a run, so you cannot place breakpoints in them after starting a debugging session with a debug or attach command.

Filter libraries that are explicitly loaded using dlopen(2). The names in such libraries are know only after the library has been loaded and the first function in it has been called.

You can set breakpoints in explicitly (dynamically) loaded libraries in two ways:

If you have a library, for example, mylibrary.so, which contains a function myfunc(), you could preload the library's symbol tale into dbx and set a breakpoint on the function as follows:

(dbx) loadobject -load fullpathto/mylibrary.so
(dbx) stop in myfunc

Alternatively, a much easier way is to run your program under dbx to completion. dbx records and remembers all shared libraries that are loaded with dlopen(2), even if they are closed with dlclose(). So after the first run of the program, you will be able to set breakpoints successfully: