Jump to content United States-English
HP.com Home Products and Services Support and Drivers Solutions How to Buy
» Contact HP
More options
HP.com home
Java™ Troubleshooting Guide for HP-UX Systems: > Chapter 1 Diagnostic and Monitoring Tools and Options

gdb

» 

Technical documentation

Complete book in PDF
» Feedback
Content starts here

 » Table of Contents

 » Glossary

 » Index

Java stack unwind enhancements have been added to enable it to support unwinding across Java frames and provide an effective way to examine stack traces containing mixed language frames (Java and C/C++) of both live Java processes and core files. This has been implemented by adding subcommands for Java VM debugging to gdb.

The following table shows which Java versions on PA-RISC and Integrity systems have the stack unwind and the gdb Java subcommands features. These features are available in gdb version 4.5 and later versions.

Table 1-8 Java Version Information for gdb Java VM Debugging Features

Platform Stack Unwind EnhancementsJava SubcommandsGDB Version
PA-RISC 32-bit -pa11 (PA_RISC)SDK 1.3.1.02+SDK 1.4.1.05+4.5+
PA-RISC 32-bit (PA_RISC2.0)SDK 1.3.1.02+SDK 1.4.1.05+4.5+
PA-RISC 64-bit (PA_RISC2.0W)SDK 1.4.1.01+SDK 1.4.1.05+4.5+
Integrity 32-bit (IA64N)SDK 1.3.1.06+SDK 1.4.1.05+4.5–5.2
Integrity 64-bit (IA64W)SDK 1.4.0.01+SDK 1.4.1.05+4.5–5.2
Integrity 32 (IA64N), 64-bit (IA64W)SDK 1.4.2.10+SDK 1.4.2.10+*5.3+
Integrity 32 (IA64N), 64-bit (IA64W)JDK 1.5.0.03+JDK 1.5.0.03+*5.3+

 

* gdb version 5.3 requires SDK 1.4.2.10 and later versions or JDK 1.5.0.03 and later versions in order to use the Java VM debugging features.

To use this functionality, the GDB_JAVA_UNWINDLIB environment variable must be set to the path name of the Java unwind library. The following list contains the default locations of the Java unwind libraries on various systems. The examples are for SDK 1.4; if you are using JDK 1.5, substitute /opt/java1.5 for /opt/java1.4.

/opt/java1.4/jre/lib/PA_RISC/server/libjunwind.sl
/opt/java1.4/jre/lib/PA_RISC2.0/server/libjunwind.sl   
/opt/java1.4/jre/lib/PA_RISC2.0W/server/libjunwind.sl
/opt/java1.4/jre/lib/IA64N/server/libjunwind.so   
/opt/java1.4/jre/lib/IA64W/server/libjunwind.so
 

The following examples show how to set the GDB_JAVA_UNWINDLIB environment variable. If you are using ksh on a PA-RISC machine, this is how you set the environment variable for a 32–bit Java application:

$ export GDB_JAVA_UNWINDLIB=/opt/java1.4/jre/lib/PA_RISC2.0/server/libjunwind.sl

Additionally, this is how you set the environment variable on an Integrity machine for a 32–bit Java application:

$ export GDB_JAVA_UNWINDLIB=/opt/java1.4/jre/lib/IA64N/server/libjunwind.so
 

If the SDK is installed in a location other than the default, substitute the nondefault location for /opt/java1.4 in the previous commands.

Java Stack Unwind Features

The Java stack unwind features are useful for troubleshooting problems in the Java Virtual Machine (VM). The Java stack unwind features are:

  • View mixed language frames information, including Java frames and C/C++ native frames, in a gdb backtrace

  • Distinguish various Java frame types including interpreted, compiled, and adapter frames

  • View Java method name, signature, and class package name for Java method frames

Additional stack unwind features are available starting with SDK 1.4.2. These features fall into three categories: Java stack unwind enhancements, Java heap support, and Java threads support.

These additional features are available as part of the Java stack unwind enhancements:

  • View Java compiled frame inlined methods

  • View Java interpreted or compiled frame specific information.

  • View Java interpreted or compiled frame arguments and local variables

  • Disassemble Java method bytecodes

  • Print out the Java unwind table

These additional features are available as part of the Java heap support:

  • View Java heap parameters

  • Dump Java object.

  • Print Java heap histogram

  • Find all the instances of a given Java class

  • Find all the references to a given object in the Java heap

  • Find out the object OOP (object-oriented pointer) of the given field address

These additional features are available as part of Java threads support:

  • View Java threads state information

  • View current Java thread information

  • View Java interpreted frame monitors information

gdb Subcommands for Java VM Debugging

To view the gdb commands that support Java VM debugging, enter help java at the gdb prompt.

(gdb) help java Java and
JVM debugging commands.  

List of java subcommands:  

java args -- Show the current or specified Java frame arguments info 
java bytecodes -- Disassemble the given Java method's bytecodes  
java heap-histogram -- Show the Java heap object histogram  
java instances -- Find all the instances of the given klassOop in the Java heap 
java jvm-state -- Show Java virtual machine's current internal states 
java locals -- Show the current or specified Java frame locals info  
java mutex-info -- Print out details of the static mutexes  
java object -- Print out the given Java object's fields info  
java oop -- Find the Java object oop of the given Java heap address  
java references -- Find all the references to the given Java object in the Java heap  
java unwind-info -- Show the unwind info of the code where the given pc is located
java unwind-table -- Print out the dynamically generated Java Unwind Table  

Type "help java" followed by java subcommand name for full documentation. 
Command name abbreviations are allowed if unambiguous.

The following two tables list Java VM debugging commands and Java subcommands:

Table 1-9 Java VM Debugging Commands

backtracePrint backtrace of mixed Java and native frames
info framePrint Java frame specific information if this is a Java frame
info threadsPrint state information for all threads
threadPrint detailed state information for the current thread

 

Table 1-10 Java Subcommands

java argsShow the current or specified Java frame arguments information
java bytecodesDisassemble the given Java method's bytecodes
java heap-histogramShow the Java heap object histogram
java instances Find all the instances of the given klassOop in the Java heap
java jvm-stateShow the current internal state of the Java VM
java locals Show the current or specified Java frame locals information
java objectPrint the given Java object's fields information
java oop Find the Java object OOP of the given Java heap address
java referencesFind all the references to the given Java object in the Java heap
java unwind-infoShow the unwind information of the code where the given pc is located
java unwind-table Print the dynamically generated Java unwind table

 

Enter help java followed by the subcommand name for full documentation. Command name abbreviations are allowed if they are unambiguous.

The following examples illustrate the gdb command-line options for invoking gdb on a core file and on a hung process.

The first set of examples illustrate how to execute gdb on a core file:

  • Invoke gdb on a core file generated when running a 32-bit Java application on an Integrity system with /opt/java1.4/bin/java:

    $ gdb /opt/java1.4/bin/IA64N/java core.java
  • Invoke gdb on a core file generated when running a 64-bit Java application on an Integrity system with /opt/java1.4/bin/java -d64:

    $ gdb /opt/java1.4/bin/IA64W/java core.java

  • Invoke gdb on a core file generated when running a 32-bit Java application on PA-RISC using /opt/java1.4/bin/java:

    $ gdb /opt/java1.4/bin/PA_RISC2.0/java core.java

  • Invoke gdb on a core file generated when running a 64-bit Java application on PA-RISC using /opt/java1.4/bin/java:

    $ gdb /opt/java1.4/bin/PA_RISC2.0W/java core.java

When debugging a core file, it is good practice to rename the file from core to another name to avoid accidentally overwriting it.

If the Java and system libraries used by the failed application reside in nonstandard locations, then the GDB_SHLIB_PATH environment variable must be set to specify the location of the libraries.

The following example illustrates how to execute gdb on a hung process:

  • Determine the process id:

    $ ps -u user1 | grep java    
    23989 pts/9     8:52 java
  • Attach gdb to the running process:

    $ gdb -p 23989    
    
    HP gdb 5.0 for HP Itanium (32 or 64 bit) and target HP-UX 11.2x.   
    Copyright 1986 - 2001 Free Software Foundation, Inc.   
    Hewlett-Packard Wildebeest 5.0 (based on GDB) is covered by the GNU General Public License.
    Type "show copying" to see the conditions to change it and/or distribute copies. 
    Type "show warranty" for warranty/support.    
    
    Reading symbols from /opt/java1.4/bin/IA64N/java...   
    (no debugging symbols found)...done.
    Attaching to program: /opt/java1.4/bin/IA64N/java, process 23989
    (no debugging symbols found)...   
    Reading symbols from /usr/lib/hpux32/libpthread.so.1...
    (no debugging symbols found)...done.   
    Reading symbols from /usr/lib/hpux32/libdl.so.1...
    ...
NOTE: If the version of gdb on the system is older than version 4.5, it is necessary to specify the full path of the Java executable to use the gdb subcommands. For example:
$ gdb /opt/java1.4/bin/PA_RISC2.0/java –p 23989

A tutorial on gdb can be found at the following webpage:

http://www.hp.com/go/wdb

Printable version
Privacy statement Using this site means you accept its terms Feedback to webmaster
© 2009 Hewlett-Packard Development Company, L.P.