Oracle® Solaris Studio 12.4: Debugging a Program With dbx

Exit Print View

Updated: January 2015
 
 

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 known 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
  • 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.

    (dbx) run
    execution completed, exit code is 0
    (dbx) loadobject -list
    u   myprogram (primary)
    u   /lib/libc.so.1
    u p /platform/sun4u-us3/lib/libc_psr.so.1
    u   fullpathto/mylibrary.so
    (dbx) stop in myfunc