HPlogo HP/DDE Debugger User's Guide: HP 9000 Series 700/800 Computers > Chapter 8 Debugging in Special Situations

Debugging Shared Libraries

» 

Technical documentation

Complete book in PDF

 » Table of Contents

 » Glossary

 » Index

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 -g option). A main program compiled without -g does 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 off 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 box also allows you to perform this action. Invoke it by selecting Execution:Enable Images/Libraries.

  5. Load alternate debugging information for a program or library that has been compiled partly with and partly without debugging information, so that you can debug the routines compiled without debugging information (initialize -altdbinfo). In this unusual situation, you must issue the initialize command after the library is loaded.

You may also find the following command useful:

list images

This command gives you a list of the shared libraries your program uses. Use list images -full to find out whether these libraries are mapped writable. The Execution:Enable Images/Libraries dialog box also allows you to perform this action.

See the online help for more information and examples on debugging shared libraries.