HPlogo HP WDB 5.2 Release Notes: HP 9000 and HP Integrity Systems > Chapter 1 Announcement

Summary of Changes in Previous Versions of HP WDB

» 

Technical documentation

Complete book in PDF

 » Table of Contents

The following features and changes were part of the previous releases of HP WDB for Itanium and PA-RISC architectures:

  • HP WDB provides a prototype for Linux Runtime Environment (LRE) debugging, which allows you to debug applications ported from Linux that run under LRE. This provides a minimal debugging capability for LRE.

    LRE allows many Itanium-based Linux binaries to be copied to an HP-UX Itanium-based system and executed without modification.

  • When you try to set a watchpoint in an expression, HP WDB places a deferred watchpoint if HP WDB cannot evaluate the expression. The watchpoint is automatically enabled whenever the expression can be evaluated during the program’s execution. This is especially useful when placing the watchpoints on unallocated addresses.

  • The info threads command output now shows the priority of a thread along with other thread information.

    For example:

    6 system thread 2345 Priority:178 MyFunction () at ...
  • A new command, pathmap, allows you to define a list of substitution rules to be applied to path names to identify object files and the corresponding source files. The pathmap command, however, may not find source files if the object files are not available.

    This minimizes or eliminates the need to specify multiple objectdir commands when object files are moved from the compilation directories or when compilation directories are mounted over NFS.

    To use this feature, your program must be compiled with the +objdebug option.

    For information on how pathmap works type help pathmap at the HP WDB prompt.

  • HP WDB automatically detects mismatches between a library in a core file and the library used by HP WDB when it is invoked on the core file.

    Core library mismatch detection requires dld.so version B.12.21 on both the system used for compiling and the system used for debugging.

    The debugger shows a list of the mismatched libraries. You must then provide the location of the correct libraries. For example, you can set the GDB_SHLIB_PATH environment variable to point to the correct directories.

    A core library mismatch can occur when a core file is produced on one computer and debugged on another.

    The libraries used by the executable when it produced the core file on one computer may not be the same on another. Libraries that might cause this problem include libc, libm, etc. They may also include libraries specific to your executable. In these cases, debugging core files may produce wrong or inconsistent behavior such as truncated or missing stack trace, incorrect symbols, or incorrect data values.

  • Support for the new environment variable, LIBRTC_SERVER, which you can use to override the default location of librtc.sl.

  • Implementation of ask mode for set follow-fork-mode

    This command prompts user to select between parent and child as the debugger response to a program call of fork/vfork. Based on the user selection, the parent or the child process is debugged.

    For example:

    (gdb) set follow-fork-mode ask
    (gdb) show follow-fork-mode
    Debugger response to a program call of fork or vfork is “ask”.

    (gdb) run
    Starting program: sample
    [New process 4941]
    warning: reading `r3’ register: No data
    Select follow-fork-mode :
    [0] parent
    [1] child
    >

Additional Support for Command-line Calls in a Stripped Executable

HP WDB 3.2 enables you to perform command-line calls in a stripped executable. The various scenarios in which you can make command-line calls in a stripped executable are as follows:

  • For 32-bit applications:

    • To perform command line calls in a shared library, without the help of dynamic linker (using end.o), you must perform the following operations:

      • Execute the chatr -B immediate <executable> command.

      • Modify all the calls to shl_load() to specify BIND_IMMEDIATE, if any.

    • To perform command line calls after attaching GDB to a running process, without the help of dynamic linker (using end.o), you must do the following for the program:

      • Execute the chatr -B immediate <executable> command

      • Modify all the calls to shl_load() to specify BIND_IMMEDIATE, if any.

      • Execute the /opt/langtools/bin/pxdb -s on <executable> or
        chatr +dbg enable <executable> command.

    • To avoid changing of the run-time binding behavior of a program to BIND_IMMEDIATE, in order to perform command line call, do the following:

      • Use the new linker option, +ea, to export symbols from an object file.

      • Install the linker patch, PHSS_28870 (for 11.0) or PHSS_28871 (for 11i).

      • Execute the following commands:

        cc -c file.cld /opt/langtools/lib/crt0.o file.o +ea /opt/langtools/lib/end.o-lc -s

  • For 64-bit applications:

    • To perform command line calls in a stripped executable, linked with end.o, you need to do the following:

      • In the +std link mode, GDB supports this feature without any changes. You must export the __wdb_call_dummy symbol as shown in the next line.

      • In the +compat link mode, execute the following command:

        cc +DD64 -c file.c -Wl,+ee __wdb_call_dummy -o a.out

    • You cannot perform command line calls from a 64-bit program that is not linked with end.o.

Support for Debugging Stripped Binaries

HP WDB provides limited support for debugging stripped binaries.

Printing of Locals and Globals

HP WDB cannot print the locals and statics declared in a module that has been stripped. HP WDB, however, prints the exported symbols because exported symbols are not stripped by the strip command, they remain in dynsym.

HP WDB can access the globals or locals defined in other non-stripped shared libraries loaded into the stripped executable when you are in the appropriate scope.

Breakpoints

HP WDB places breakpoints using symbol names in the unstripped shared libraries loaded into the stripped executable. In stripped binaries, however, HP WDB cannot insert breakpoints using line numbers or symbolic names of the symbols not in the export list.

Backtraces

HP WDB can backtrace properly stripped frames, however, arguments will not be displayed, just as with non -g binaries. For fully archived stripped binaries, PCs, but not function names, will be displayed.

A known problem is that HP WDB displays improper function names instead of unknown_procedure for the symbols that are not known.

HP WDB versions earlier than 4.2 cannot backtrace through stripped archived binaries.

Command-line Calls

Command-line calls to the non-stripped library work correctly when called while stopped in a stripped binary, or elsewhere. Command-line calls to the functions (exported symbols) in the stripped binary work correctly.

Step and Continue

HP WDB cannot step into a function that does not contain debug information, nor can you use next to go past a line when there is no debug information. The continue command works correctly.

Disassembly

HP WDB cannot display disassembly for fully archived stripped binaries. You can, however, examine the addresses in assembly format with the HP WDB x/i address command:

(gdb) x/i 0x20000000792993c0
0x20000000792993c0:0 <time>: mov.m r31=ar.k7

The src-no-g Command

The src-no-g does not work for stripped binaries because the line table gets stripped.

The --pid Command-line Option

HP WDB now accepts --pid  or -p followed by a process id on the command line.

HP WDB makes a slight change in the way it handles command-line arguments. The first non-flag argument is always a program to debug, but the second non-flag argument may either be a core file or a process ID.

In earlier versions, HP WDB would attempt to open the second argument as a core file, and if that failed, would issue an error message and then attempt to attach it as a process.

Now, if the second argument begins with a non-digit, it will be treated as a core file. If it begins with a digit, HP WDB will attempt to attach it as a process, and if no such process is found, will then attempt to open it as a core file.

Additional Support for Procedural Breakpoints

HP WDB enables you to set permanent breakpoints at the entry and exit (first and final executable statement) of every function that can be debugged.

The new breakpoint commands are xbp and xdp.

  • xbp: Sets breakpoints at the first and final executable statement in all the functions, which can be debugged, in all the source files. These shared files also include shared libraries that are already loaded. After you set these breakpoints, you can manage them like any standard breakpoints. You can delete them, disable them, or make them conditional.

  • xdp: Deletes all the breakpoints set by the xbp command.

Here is an example of how to set a breakpoint at the start and end statement of each procedure:

(gdb) file a.out
Reading symbols from a.out...done.
(gdb) xbp
Breakpoints set from 3 to 8
(gdb)

Support for Dumping an Array into an ASCII File

HP WDB supports a new functionality for dumping an array into an ASCII file.

The array elements are stored in Array format of Matrix Market in a predefined (column-major order for Fortran arrays) order. The objective is to provide a simple mechanism to facilitate the exchange of matrix data and to enable easier parsing of the array elements.

For common file formats, see http://math.nist.gov/MatrixMarket/formats.html.

To dump an array, ARRAY, to a file named DUMPFILE, use the following command:

(gdb) dump2file ARRAY DUMPFILE

The entries of ARRAY are dumped into an ASCII file named DUMPFILE in the array format. The file is created in the current working directory. The content of the file has the following format:

%%ArrayBrowsing matrix array ARRAY
% A 5x5 matrix
5 5
0
2
4
6
8
2
..
..

where, ARRAY is the name of the array, and its size is 5x5.

The first two lines are comments about this file and the array. The third line denotes the array coordinates. From the fourth line, the elements of the array are listed.

NOTE: This feature is not supported for the FORTRAN array slices.

Arguments Supported for Target Programs

You can use the new --args option to specify command-line arguments for the target program from the HP WDB command line.

Support for “array slicing” for Fortran Programs

HP WDB supports “array slicing” for Fortran programs. Array slicing allows you to give a range of elements in place of an array subscript.

The syntax is:

:

Lower bound to upper bound

expr1:expor2

Given range

:expr

Lower bound to given expr

expr:

Given expr to upper bound

::

Lower bound to upper bound, stride of 1

::expr

Lower bound to upper bound, stride of expr

expr1:expr2:

Given range, stride of 1

expr1:expr2:expr3

Given range, stride of expr3

:expr1:expr3

Lower bound to expr2, stride of expr3

expr1::expr3

Given expr1 to upper bound, stride of expr3

Here is an example:

For this array: INTEGER*4 A(3,3)

The HP WDB command print A(1:2:1, :2) prints these values:

A(1,1), A(2,1), A(1,2) and A(2,2)

Commands to Enable and Disable Threads for DDE Compatibility

When debugging a multi-threaded application, if you suspect that a specific thread is causing a problem, it is useful to suspend the other threads in the debugger and debug the suspect thread. HP WDB provides commands to disable and enable specific threads.

  • The thread disable command prevents specified threads from running until they are enabled again using thread enable.

  • The thread enable command allows the specified thread to run when you issue a continue or step command. By default, all threads are enabled. Use thread enable to reactivate a disabled thread.

Support for Unwinding through Corrupted Program Counter

You can perform stack tracing when the program counter (PC) is corrupted due to a call through bad function pointer.

Runtime Memory Checking is Supported

Refer to Debugging with GDB for details on how do memory leak detection.

With HP WDB, you can also do memory checking on the attached processes, which was not supported previously.

  • To start memory checking from the time you attached:

    Attach to the process with -leaks, or set heap-check on at the gdb prompt.

    gdb -leaks a.out pid

    or

    gdb a.out pid
    (gdb) set heap-check on
  • To start memory checking when the target program starts:

    1. To use attach, you need to modify the your code to call __rtc_init_leaks(int). The value you provide controls the number of frames that HP WDB collects. Add this code to your main():

      void __rtc_init_leaks (int frame_count);
      int main()
         {
          /* Before you do anything else.. */
          __rtc_init_leaks (10);
          /* your code... */
          ....
         }
    2. Also modify your link command to link in this library:

      /opt/langtools/lib/hpux[32/64]/librtc[64].sl. 

      Make sure that this is the first library in your link line.

    3. During attach, use -leaks on the command line or use set heap-check on at the gdb prompt.

Printing CFM and PFS Registers

HP WDB prints Current Frame Marker (CFM) and Previous Frame State (PFS) ar64 registers twice: first as raw values as are other registers and in special formats identifying the size of rotating registers, frame and locals.

For example,

ar64: 0xc00000000000050c
      (sor:0, sol:10, sof:12)
cfm: 0x800000000000450a
      (sor:1, sol:10, sof:10)

Showing Unwind Information with the maint info unwind Command

The maint info unwind command prints the unwind information for the unwind regions at the given address expression.Usage:

maint info unwind exp

where exp is an address expression.

For example:

(gdb) maint info unwind $pc
modsched:
0x4000930 .. 0x4000a20, end_prologue@0x4000970
Info block version:0x0, flags:0x0, length:4 * 4 == 16

0x40172b20: (0c) R1prologue rlen=12
0x40172b21: (e8) P7preds_when t=11
0x40172b23: (b1) P3preds_gr gr=41
0x40172b25: (ea) P7lc_when t=7
0x40172b27: (b2) P3lc_gr gr=40
0x40172b29: (61) R3body rlen=33
0x40172b2b: (81) B1label_state label=1
0x40172b2c: (c0) B2epilogue t=44
0x40172b2e: (00) R1prologue rlen=0
0x40172b2f: (00) R1prologue rlen=0

Support for Debugging typedefs

When you have a typedef class as a template parameter you can set a breakpoint on a member function by using the command:

break Class<typedef_classB>::memfunc
  • Support for stack traces in Java/C/C++ programs.

  • Enhanced support for C++ templates.

  • New command: dumpcore.

  • Info threads command output changed.

Support for Stack Traces in Java/C/C++ Programs

This debugger release can show stack traces of mixed Java/C/C++ programs.

The stack trace functionality requires Java SDK version 1.3.1.06 or later for HP-UX. Please check the HP web site for Java, http://www.hp.com/go/java/, for availability.

The debugger uses the default libjunwind.sl library specified by the JVM. This library is part of the Java SDK version 1.3.1.06 or later for HP-UX. To override the default setting, set the environment variable GDB_JAVA_UNWINDLIB to the path of your libjunwind.sl.

The debugger supports these types of Java frames:

  • interpreter

  • compiled

  • adapter

For specific details on how to use this feature, refer to the HP web site for Java, http://www.hp.com/go/java/.

Enhanced Support for C++ Templates

HP WDB includes these features to support C++ templates:

  • Setting breakpoints in template class functions and template functions without having to specify details about the instantiation.

  • The ptype command shows any one of the class instantiations.

Setting Breakpoints in Template Class Member Functions

You can set a breakpoint in template class member functions and template functions by not specifying the type enclosed by angle brackets.

For example, if you have a template class named myClass with three instantiations:

  • myClass<char>

  • myClass<int>

  • myClass<volatile char* >

To set a breakpoint on the member function bar() you can use the following command and pick from the menu.

(gdb) break myclass::bar

[0] cancel
[1] all
[2] myClass< char volatile* >::myClass( int, char volatile* ) at /gdb.c++/templates.cc:567
[3] myclass< char >::myclass( int, char ) at /gdb.c++/templates.cc:567
[4] myClass< int >::myclass( int, int ) at /gdb.c++/templates.cc:567

Displaying an Instantiation of a Template Class

To display an instantiation of a template class use the ptype command.

For example:

(gdb) ptype myclass 
type = class myClass<char> {
  public:
    int x;
    signed char t;

    signed char myClass( int, char );
}

The dumpcore Command

HP WDB includes the command, dumpcore, to generate a core image file of a process running under the debugger in the middle of execution.

The dumpcore command takes no arguments and saves the core image for the current process being debugged in the file named core.pid, where pid is the process ID number.

To analyze this core file with HP WDB on HP-UX B.11.22 or earlier systems, you need to do the following:

When starting from HP WDB command line:

(gdb) set live_core 1
(gdb) core-file core.pid

When starting from shell prompt:

% gdb --lcore a.out core.pid
NOTE: HP WDB cannot debug the core file generated by the dumpcore command on a threaded program on HP-UX B.11.22.

The info threads Command Output Changed

The info threads command output is different than on WDB 1.4.00:

In 1.4.00 the output lines show:

1 system thread 2345 user thread 6 MyFunction () at ...

In WDB 1.4.01 the output lines show:

6 system thread 2345 MyFunction () at ...

In the WDB 1.4.01 output, the left-most number is the user thread ID, which stays constant throughout the execution of the program.

When show-all-kthreads is set to “1”, the info threads command includes threads that have no user threads attached to them. For these threads, the left-most number is a -ve number (-ve system thread ID).

Support for Assembly-level Debugging of Optimized Code

HP WDB supports assembly-level debugging of optimized code.

If a function is compiled with optimization level 2, the disassembly also displays the actual source line and column information for each assembly instruction.

Stack traces show line-number information for optimized functions.

You can set breakpoints and single-step at the source statement level for optimized functions.

Locals and argument values are not available for optimized functions.

NOTE: When debugging optimized code, Fortran, C, and C++ compilers emit column numbers that represent relative position in the source line, not actual column numbers. For example, column 4 represents a location in the source line that is guaranteed to occur before column 5, though neither column 4 nor 5 are necessarily refer to the correct columns in the source line. For legacy HP C compilers, however, the column positions are correct.

Support for Debugging MxN Threaded Programs

HP WDB provides additional support for programs that use the MxN model for threaded programs on HP-UX B.11.22.

  1. The info threads command now displays both the utid (user thread) and lwpid (system thread) for each thread. All user threads are displayed.

  2. You can modify only the registers of threads that have a non-zero lwpid associated with them (i.e. system thread != 0).

  3. You can place thread-specific breakpoints as before, but the breakpoint is associated with the utid of that thread.

    For example:

    6 system thread 818664 user thread 2

    When you put a breakpoint on thread 6 it will be associated with user thread 2.

Support for _Complex Variables in HP C

HP C supports a _Complex data type built from any of the floating point types.

A _Complex number holds a pair of floating point numbers, the first is the “real part” and the second is the “imaginary part”.

Here are examples of declarations and initializations using _Complex numbers:

float _Complex glob_float_complex;
double _Complex glob_double_complex = 6;
long double _Complex glob_long_double_complex = _Imaginary_I;
__float80 _Complex glob_float80_complex = 8 + 9 * _Imaginary_I;

_Imaginary_I is a keyword which represents the square root of -1.

The debugger has limited support for _Complex variables. No arithmetic operations are allowed with _Complex numbers. A _Complex number may be cast or assigned to any numeric data type and vice versa.

A _Complex variable can be initialized with an expression of the form:

A + B * _Imaginary_I

Where A and B are ordinary numeric expressions, perhaps in parentheses.

This is also the format in which gdb displays a _Complex value.

Complex numbers cannot be used in arithmetic expressions in the debugger.

For more information of _Complex type, refer to the HP C/ANSI C documentation.

Support for Debugging Namespaces

HP WDB for Itanium provides full support for debugging namespaces.

You do not need to use fully qualified names to access symbols within a namespace. The debugger can compile a list of namespaces active in the scope that you are in and when possible choose an appropriate symbol.

The debugger recognizes using declarations, using directives, namespace aliases, nested namespaces and unqualified lookup within a namespace. It also recognizes using directives, aliases and using declarations within namespaces.

When the debugger has a list of possible resolutions for a given symbol, it will display a menu that shows all names fully qualified whenever namespaces are involved. You can choose the appropriate symbol from the list.

For example, if you stop the debugger in a function that contains an int i using directive for a namespace such as:

using namespace A::AB::ABC::ABCD

You can use the command print i and if the only possible resolution for i is A::AB::ABC::ABCD::i the debugger prints out the name of the symbol and its value. If, however, a global i exists, the debugger will display a menu from which to choose:

(1) i
(2) A::AB::ABC::ABCD::i
>

Setting breakpoints on functions works in the same way.

The debugger also allows semi-qualified names. For example, if you stop in a function in namespace B, which is nested in namespace A, and namespace A has an int i, you can use print B::i to display the value of A::B::i.

To disable namespace support, use the command:

(gdb) set namespaces-enabled off

Support for Debugging PA-RISC Programs on Itanium-Based Systems

You can debug PA-RISC applications and core files on Itanium-based systems. When you start HP WDB, if the debug target is a PA-RISC binary program, the debugger automatically loads HP WDB 3.0.01. The PA-RISC version of HP WDB is provided as part of the HP-UX Operating System.

Debugging a PA-RISC Core File on Itanium-Based Systems

When a PA-RISC application creates a core file on an Itanium-based system, the file name must be core.program_name, for example, core.myprog.

To debug the core file for the PA-RISC application, use the normal HP WDB command, for example:

$gdb myprog core.myprog

HP WDB will automatically use the PA-RISC version of the debugger, WDB 3.0.01, and you can debug the core file as you would on a PA-RISC system.

NOTE: A core file named core or core.pid is not a core file of the PA-RISC program you are running. These core files were created by the PA-RISC emulator and cannot be used to debug your PA-RISC application.

Debugging a PA-RISC Core File on a Different Itanium-Based System

To debug a core file generated by a PA-RISC program on a machine other than the one on which the core file was generated, follow these steps:

  1. Transfer the executable program, core file and all shared libraries used by the PA-RISC application to the target machine.

  2. Set the GDB_SHLIB_PATH environment variable to a colon-separated list of directory path names on the system where the transferred shared libraries reside.

  3. Use the debugger to examine the core file.

Debugging a PA-RISC Program on Itanium-Based System

To debug a live PA-RISC program on Itanium-based systems, use these steps:

  1. Set the environment variable PA_DEBUG to 1.

  2. Set the environment variable SHELL to point to a PA-RISC shell, which needs to be present on the IPF machine on which debugging is being performed.

    You can copy PA-RISC shells from the /usr/bin directory on HP-UX PA-RISC machines.

  3. Make sure /usr/ccs/bin is in your PATH environment variable. All PA-RISC HP WDB binaries on Itanium-based systems are in this directory.

  4. Use the debugger to examine your program.

    $gdb a.out

    HP WDB automatically chooses the appropriate PA-RISC version of the debugger.

  5. After debugging is finished, unset the PA_DEBUG environment variable and restore the original value of the SHELL environment variable.

Minimal Support for Programs that do not Contain Debugging Information

HP WDB for Itanium-based systems includes minimal support for source-level debugging of programs compiled without the -g option at any optimization level.

The appropriate debugger commands enable these features on programs compiled without -g:

  • The ability to use the list, step, next commands.

  • The disassembly command shows interleaved source lines.

  • Stack traces display line numbers.

Local variable and type information, however, will still not be available without compiling with -g.

To enable debugging support for programs that have not been compiled with -g, use the set src-no-g command. Here are the options for the command:

set src-no-g = none | no_sys_libs | all

none

No source level debugging possible without -g. Default.

no_sys_libs

For all source files except those in system libraries.

all

For all source files.

To see the current settings, use show src-no-g.

Hardware Support Limited to Four Watchpoints

HP WDB includes hardware support for watchpoints. You should not set more than four watchpoints to get the best results. Setting a fifth watchpoint causes HP WDB to set a software watchpoint that can slow down in the execution of your program.

Support for Co-Variant Return Type

HP WDB can step into a co-variant function. The compiler-generated function called thunks, which is used internally by the compiler to support co-variant return type, will not be shown when you do a “backtrace” or switch from one frame to another frame. Similarly, using a finish or return command at a co-variant callee function directly returns the control back to the caller of thunks.

Support for Output Logging

The Visual Interface for HP WDB terminal user interface (TUI) mode supports a new command, log logfile_name, that saves the content of a session to the specified log file.

When you use the log command, the debugger saves a snapshot of the current session, from the start of the session to the point where you issued the log command. Each time you use the log command, HP WDB overwrites the specified log file with a new snapshot from the start of the session.

To run the Visual Interface for HP WDB, use the following command:

$v  db -tui

To redirect HP WDB output to a log file named mylogfile, use the log command in the following manner:

(gdb) log mylogfile

The Visual Interface for HP WDB stores the log file, mylogfile, in the current directory.

To view the log file from Visual Interface for HP WDB, start a shell process and use the following command:

(gdb) shell vi mylogfile 

New Functionality for Visual Interface for HP WDB

Visual Interface for HP WDB includes these changes:

  • A new disassembly window provides added visibility and support for monitoring programs at the instruction level. You can now easily switch between assembly and source level debugging

    To see the new disassembly window,

    • Run Visual Interface for HP WDB (vdb) on a program and click the DisAsm button in the right corner of the window

    • Run the terminal version (vdb -tui) and type layout src and layout asm to switch between source and assembly level debugging.

    For more information, click the faq button in the lower left corner of any graphical version window or see “Visual Interface for HP WDB”.

  • The graphical version of Visual Interface for HP WDB adds common HP WDB commands such as stepi, nexti, break (on an address location), and others available via buttons and menu selections.

  • You can control the automatic printing of changed registers when in disassembly mode.

    Turn this feature on by typing this command at the HP WDB prompt:

    (gdb) set print-changed-registers 1

    Turn this feature off by typing this command at the HP WDB prompt

    (gdb) set print-changed-registers 0

    When register printing is on, HP WDB prints old and new values for changed registers during assembly debugging.

  • Instructions on how to copy Visual Interface for HP WDB to a location on your systems other than the HP default (/opt/langtools/bin) are available in the online Visual Interface for HP WDB faq, which you can view by clicking on faq button in any Visual Interface window.

New Terminal-Based Interface

HP WDB uses a new HP-supported user interface with both the graphical and terminal modes. Visual Interface for HP WDB is based on Vim 5.7 and WDB. This interface replaces the -tui mode on Itanium-based systems. To use the interface with HP WDB, type vdb.

When you are using the interface, you are actually using vim, which is a vi-compatible editor. With the new interface you can use vi commands to browse in the WDB display.

Most of the interface functionality is also available for emacs users and does not require knowledge of vi commands.

For details about the interface, refer to the Debugging with GDB guide, which is included with the software.

Additional Features in HP WDB

HP WDB provides the following features in addition to the standard GDB features:

  • Support for debugging 32-bit and 64-bit programs.

  • Support for automatic loading of debug information from object modules.

  • Support for debugging code in shared libraries and archive libraries.

  • Support for assembly-level debugging.

  • Support for a subset of XDB commands, enabled with the -xdb option.

Referencing Instructions in a Memory Location

Changes in the architecture require that you use slightly different syntax to display the instructions in a memory location or setting a breakpoint to an instruction in a memory address.

In the Itanium architecture, the memory address represents the location of a “bundle” of three instructions. Unlike PA-RISC, the Itanium architecture stores three instructions at the memory location, called the bundle address.

Each instruction at the bundle address is referenced by a slot number, either 0, 1, or 2.

On Itanium-based systems the pc register value does not represent a byte address. It represents a byte address of a bundle plus the slot number of the instruction.

For example, if you print the program counter in hex with the print command you would see:

(gdb) p /x $pc
$2 = 0x4000941

In the example,

0x4000940

represents the bundle address

1

represents the slot number.

You can use the value just as you would use any other byte address.

Other examples of addresses you might see are:

These two representations are equivalent:

  • 0x40009400

  • 0x4000940:0

These two representations are also equivalent:

  • 0x40009402

  • 0x4000940:2

You need to use the bundle address and slot number format to specify breakpoints at a specific instruction. For example:

(gdb) b *0x400a980:1 
Breakpoint 6 at 0x400a980:1: file Hand.C, line 103.

This command sets a breakpoint at the second instruction in the bundle at the specified address. The output you would see at the breakpoint is:

Breakpoint 6, 0x400a980:1 in Show (this=0x7ffff988) at Hand.C:103

Debugging HP aC++ Programs Using Old Application Binary Interface

HP aC++ version A.05.01.00 adds support for new industry standard application binary interface (ABI). By default, HP WDB for Itanium-based systems correctly interprets the new ABI format.

If you need to debug programs compiled with a version of HP aC++ earlier than A.05.01.00, you must use the command set abi old in HP WDB before loading the file.

To debug a core file generated by a program compiled with a version of HP aC++ earlier than A.05.01.00, you must use the -old_abi command-line option when starting HP WDB:

gdb a.out core -old_abi

To confirm if a program uses the new ABI, use the command:

nm a.out | grep " _Z"

If the result shows mangled names starting with _Z, the program is a new ABI program.

Visual Interface for HP WDB

HP WDB includes an HP-supported Visual Interface for HP WDB with both graphical and terminal modes. The interface is based on Vim 5.7 and HP WDB. This interface replaces the -tui mode on Itanium-based systems.

When you use the interface you are actually using vim, which is a vi-compatible editor. With the interface you can use vi commands to browse in the WDB display.

Most of Visual Interface for HP WDB functionality is also available for emacs users. Visual Interface for HP WDB does not require knowledge of vi commands.

Visual Interface for HP WDB identifies you as an emacs user by looking at the environment variable $EDITOR. If this variable has a value that matches emacs, or gmacs, or xemacs, then Visual Interface for HP WDB starts in emacs mode automatically.

NOTE: If your program expects unbuffered input or uses curses, termcap, or terminfo or otherwise transmits escape or control sequences to the terminal, you must use one of the following methods to run Visual Interface for HP WDB:
  1. Start the process in one terminal and attach to it with Visual Interface for HP WDB.

  2. Use the tty command at the debugger prompt so the program’s input and output are directed to another terminal.

If the underlying GDB terminates abnormally when you are using Visual Interface for HP WDB, do not close the Visual Interface for HP WDB window. Wait for a minute or two. Visual Interface for HP WDB captures the stack trace and the debugging session details and sends you an e-mail. You can then forward this to HP when you report the problem. This is helpful to HP in reconstructing the crash scenario.

Starting and Stopping Visual Interface for HP WDB

You can use Visual Interface for HP WDB in either of two modes:

  • X-window -based graphical interface: Supports mouse and keyboard commands.

  • Terminal interface: Supports keyboard commands only.

Visual Interface for HP WDB accepts the same command-line arguments as GDB so you can add options to the startup command. See the manual page for GDB for the list of arguments.

  • To start Visual Interface for HP WDB in graphical mode with mouse support, run Visual Interface for HP WDB with the command:

    /opt/langtools/bin/vdb

  • To start Visual Interface for HP WDB in terminal user interface mode run Visual Interface for HP WDB with the command:

    /opt/langtools/bin/vdb -tui

  • To stop Visual Interface for HP WDB, type quit on the HP WDB command line.

    (wdb) quit

Navigating the Visual Interface for HP WDB Display

The Visual Interface for HP WDB screen consists of two areas:

  • Source pane at the top

  • Debugger pane at the bottom

You can use the arrow and pagination keys on the keyboard to move the cursor:

  • Pagination keys always move the cursor in the source window, at the top, above the status line.

  • Holding the shift key down while using the pagination keys moves the cursor in the debugger window.

  • The up and down arrow keys move the cursor in the source window.

  • Holding the shift key down while using the up and down arrow keys move the cursor in the debugger window.

  • The left and right arrow keys always move the cursor in the debugger window.

  • Two rows of labeled softkeys at the bottom of the display give you quick access to common commands.

Figure 1-1 Visual Interface for HP WDB GUI Display

Visual Interface for HP WDB GUI Display

You can click on the softkey or press a function key on your keyboard to invoke the command. The function keys F1 through F8 correspond to the bottom row of softkeys. The function keys f9 and up correspond to the top row.

This display show the Disassembly view.

Figure 1-2 Visual Interface for HP WDB GUI Disassembly Display

Visual Interface for HP WDB GUI Disassembly Display

Specifying Foreground and Background Colors

To change the foreground and background colors, update the .Xdefaults file in your home directory. The resources are the same as for hpterm.

Here is a sample entry:

HPterm*foreground:             white
HPterm*background: rgb:68/90/C4

Using the X-window Graphical Interface

To start Visual Interface for HP WDB in graphical mode with mouse support, run Visual Interface for HP WDB with the command:

/opt/langtools/bin/vdb

Visual Interface for HP WDB opens an hpterm window, ignoring the value of the TERM environment variable, for debugging a program.

With a mouse you can do the following:

  • You can left-click on the line number to insert or remove breakpoints.

  • You can left-click on an identifier to select the identifier as an operand for the Print, Print*, Type, List softkeys.

  • Where necessary you can manually select an expression by dragging the cursor over it.

  • You can right-click on the line number to activate a pop-up menu with several useful commands.

  • You can right-click on an identifier to automatically select it and use the selection as an operand for the pop-up window that appears.

  • You can right-click on an empty region for a third pop-up menu with several useful actions. For example, see Saving session to file.

  • You can left-click on the command softkeys at the bottom of Visual Interface for HP WDB window.

  • You can click middle button to paste the selection.

  • You can drag the status bar with the mouse to resize the debugger window relative to the source window.

Using the TUI Mode

To start Visual Interface for HP WDB in terminal user interface mode, run Visual Interface for HP WDB with the command:

/opt/langtools/bin/vdb -tui

This mode works well with hpterm and xterm and fairly well with dtterm and vt100 (telnet) terminals.

NOTE: A defect in dtterm may truncate the display of lines that do not fit within the window. To work around this defect you can refresh the display with CTRL-L or widen your terminal window so source lines will not wrap.

If you use xterm and dtterm, you should update your .Xdefaults file with keyboard translations to get the shifted arrows and shifted paging keys to work.

For xterm use these settings:

*XTerm*vt100.translations: #override \
Shift <Key>Prior: string(0x2) \n \
Shift <Key>Next: string(0x6) \n \
Shift <Key>Up: string(0x5) \n \
Shift <Key>Down: string(0x19) \n \
Shift <Key>Left: string(0x1b) string(i) \n \
Shift <Key>Right: string(0x1b) string(la)

For DtTerm use these settings:

*DtTerm*Translations: #override\n \
Shift <Key>osfPageUp: string(0x2) \n \
Shift <Key>osfPageDown: string(0x6) \n \
Shift <Key>osfUp: string(0x5) \n \
Shift <Key>osfDown: string(0x19) \n \
Shift <Key>osfLeft: string(0x1b) string(i) \n \
Shift <Key>osfRight: string(0x1b) string(la)

Mouse operations are not supported in the -tui mode. Also the paging and shift keys do not work well with vt100 terminals.

Changing the Size of the Source or Debugger Pane

If you are using the GUI mode:

  1. Escape to vi command mode.

  2. Drag the status bar to the desired position using the mouse.

If you are using -tui mode, use these commands to change the size of the current window:

CTRL-W +

to increase

CTRL-W -

to decrease

In Visual Interface for HP WDB, the current window is usually the debugger window.

Using Commands to Browse Through Source Files

Visual Interface for HP WDB is based on vim, so you can also use vi commands to browse. For example, CTRL-B, CTRL-F, CTRL-D, CTRL-U are useful for browsing the debugger window. These commands work whether or not you escape to vi mode.

These vim commands require you to escape to vi mode.

/

Search forward

?

Search backward

n
N

Repeat search

%

Match braces

[[ ]]

Skip to the next procedure

:line number

Go to any line number

All these commands require you to escape to vi command mode first. When you are done, type a for append or i for insert or other vi commands to return to text insertion mode.

You can also simply click on the Prompt softkey.

Loading Source Files

Escape to vi command mode and use the :e command to load a source file.

:e filename

When the source files are located in multiple directories, you can simply specify the base name alone as long as file names are unique and the appropriate dir commands have been executed.

Pressing the Prompt softkey takes you to the command prompt and also updates the source window so that the cursor is left at the point where the program is stopped.

Editing Source Files

To edit a file, kill the process then click on the Edit button. If you do not kill the process, the source file and binaries could get out of sync.

Editing the Command-line and Command-line History

Visual Interface for HP WDB preserves the entire session’s transactions so you can browse through these at any time.

To edit the command line press ESC to enter vi mode and then use vi commands. You can recall previous commands in history by using [jk^P^N]. Complete command lines using TAB.

Saving Contents of a Debugging Session to a File

You can save the contents of the current debugging session, including debugger input/output and program input/output) to a file.

To save a session to a file:

  1. Right-click on an empty region of the source or debugger pane.

  2. Choose Save Session to vdb.pid from the pop-up menu.

The debugger writes the input and output to a file whose name ends in the process ID (pid) of the debugger. If you save the session more than once, the new transactions are appended to the file.

© 2004-2005 Hewlett-Packard Development Company, L.P.