In This Book

Debugging Shared Libraries

You can debug shared libraries that are either implicitly or explicitly loaded by your program. Implicitly loaded shared libraries are libraries that your program is linked against. Explicitly loaded shared libraries are loaded by calls within your program to shl load (3X). (On Solaris systems, shared libraries are loaded by calls to dlopen(3X).)

To debug shared libraries, you must compile your main program debuggable (with the -goption). A main program compiled without -gdoes not have enough information about shared libraries to allow you to debug them, even if the libraries were compiled with -g.

If the shared library you want to debug was compiled with -g, you can use full source-level debugging. If it was not compiled with -g, you must debug at the assembly level; but you can step into library routines, set breakpoints in the routines, and refer to symbols in the library.

The basic steps in debugging a shared library, and the debugger commands that accomplish these, are as follows:

1.Make the library writable using the property flags tgt_shlib_debug command. This command is issued by default when you invoke the debugger, but you can turn it o￿ if you wish.

2.Intercept the loading of a library using the intercept load command. This command is required only if you want the debugger to stop at the loading of an explicitly loaded shared library. You can use Execution: Signals/Intercepts . . . to perform this action.

3.Load the library. You do not need to issue a command to do this. An implicitly loaded shared library is loaded at program startup. An explicitly

loaded shared library is loaded by a shl load(3X) call.

4.Load debugging information for the library using the property libraries command. You can issue this command before or after the library itself is loaded.

The Dynamic Images dialog bo x also allows you to perform this action. Invoke it by selecting Execution:Enable Images/Libraries .

8-4 Debugging in Special Situations