4. Viewing and Navigating To Code
5. Controlling Program Execution
6. Setting Breakpoints and Traces
8. Evaluating and Displaying Data
11. Debugging Multithreaded Applications
16. Debugging Fortran Using dbx
17. Debugging a Java Application With dbx
Capabilities of dbx With Java Code
Limitations of dbx With Java Code
Environment Variables for Java Debugging
Starting to Debug a Java Application
Debugging a Java Application That Has a Wrapper
Attaching dbx to a Running Java Application
Debugging a C Application or C++ Application That Embeds a Java Application
Passing Arguments to the JVM Software
Specifying the Location of Your Java Source Files
Specifying the Location of Your C Source Files or C++ Source Files
Specifying a Path for Class Files That Use Custom Class Loaders
Setting Breakpoints on Java Methods
Setting Breakpoints in Native (JNI) Code
Customizing Startup of the JVM Software
Specifying a Path Name for the JVM Software
Passing Run Arguments to the JVM Software
Specifying a Custom Wrapper for Your Java Application
Using a Custom Wrapper That Accepts Command-Line Options
Using a Custom Wrapper That Does Not Accept Command-Line Options
dbx Modes for Debugging Java Code
Switching from Java or JNI Mode to Native Mode
Switching Modes When You Interrupt Execution
Using dbx Commands in Java Mode
The Java Expression Evaluation in dbx Commands
Static and Dynamic Information Used by dbx Commands
Commands With Identical Syntax and Functionality in Java Mode and Native Mode
Commands With Different Syntax in Java Mode
Commands Valid Only in Java Mode
18. Debugging at the Machine-Instruction Level
19. Using dbx With the Korn Shell
You might need to customize startup of the JVM software from dbx to do the following:
Specify a path name for the JVM software (see Specifying a Path Name for the JVM Software)
Pass some run arguments to the JVM software (see Passing Run Arguments to the JVM Software)
Specify a custom wrapper instead of the default Java wrapper for running Java applications (see Specifying a Custom Wrapper for Your Java Application)
Specify 64-bit JVM software (see Specifying 64-bit JVM Software)
You can customize startup of the JVM software using the jvm_invocation environment variable. By default, when the jvm_invocation environment variable is not defined, dbx starts the JVM software as follows
java -Xdebug -Xnoagent -Xrundbx_agent:syncpid
When the jvm_invocation environment variable is defined, dbx uses the value of the variable to start the JVM software.
You must include the -Xdebug option in the definition of the jvm_invocation environment variable. dbx expands -Xdebug into the internal options -Xdebug- Xnoagent -Xrundbxagent::sync.
If you do not include the -Xdebug option in the definition, as in the following example, dbx issues an error message.
jvm_invocation="/set/java/javasoft/sparc-S2/jdk1.2/bin/java"
dbx: Value of `$jvm_invocation’ must include an option to invoke the VM in debug mode
By default, dbx starts the JVM software in your path if you do not specify a path name for the JVM software.
To specify a path name for the JVM software, set the jvm_invocation environment variable to the appropriate path name, as in the following example.
jvm_invocation="/myjava/java -Xdebug"
This setting causes dbx to start the JVM software as follows:
/myjava/java -Djava.compiler=NONE -Xdebug -Xnoagent -Xrundbx_agent:sync
To pass run arguments to the JVM software, set the jvm_invocation environment variable to start the JVM software with those arguments, as in the following example.
jvm_invocation="java -Xdebug -Xms512 -Xmx1024 -Xcheck:jni"
This causes dbx to start the JVM software as follows:
java -Djava.compiler=NONE -Xdebug -Xnoagent -Xrundbx_agent:sync= -Xms512 -Xmx1024 -Xcheck:jni
A Java application can use a custom wrapper for startup. If your application uses a custom wrapper, you can use the jvm_invocation environment variable to specify the wrapper to be used, as in the following example.
jvm_invocation="/export/siva-a/forte4j/bin/forte4j.sh -J-Xdebug"
This causes dbx to start the JVM software as follows:
/export/siva-a/forte4j/bin/forte4j.sh - -J-Xdebug -J-Xnoagent -J-Xrundbxagent:sync=process_id
The following wrapper script (xyz) sets a few environment variables and accepts command line options:
#!/bin/sh CPATH=/mydir/myclass:/mydir/myjar.jar; export CPATH JARGS="-verbose:gc -verbose:jni -DXYZ=/mydir/xyz" ARGS= while [ $# -gt 0 ] ; do case "$1" in -userdir) shift; if [ $# -gt 0 ] ; then userdir=$1; fi;; -J*) jopt=`expr $1 : ’-J<.*>’` ; JARGS="$JARGS ’$jopt’";; *) ARGS="$ARGS ’$1’" ;; esac shift done java $JARGS -cp $CPATH $ARGS
This script accepts some command line options for the JVM software and the user application. For wrapper scripts of this form, you would set the jvm_invocation environment variable and start dbx as follows:
% jvm_invocation="xyz -J-Xdebug -Jany other java options" % dbx myclass.class -Dide=visual
The following wrapper script (xyz) sets a few environment variables and starts the JVM software, but does not accept any command line options or a class name:
#!/bin/sh CLASSPATH=/mydir/myclass:/mydir/myjar.jar; export CLASSPATH ABC=/mydir/abc; export ABC java <options> myclass
You could use such a script to debug a wrapper using dbx in one of two ways:
You could modify the script to start dbx from inside the wrapper script itself by adding the definition of the jvm_invocation variable to the script and starting dbx:
#!/bin/sh CLASSPATH=/mydir/myclass:/mydir/myjar.jar; export CLASSPATH ABC=/mydir/abc; export ABC jvm_invocation="java -Xdebug <options>"; export jvm_invocation dbx myclass.class
Once you have made this modification, you could start the debugging session by running the script.
You could modify the script slightly to accept some command line options as follows:
#!/bin/sh CLASSPATH=/mydir/myclass:/mydir/myjar.jar; export CLASSPATH ABC=/mydir/abc; export ABC JAVA_OPTIONS="$1 <options>" java $JAVA_OPTIONS $2
Once you made this modification, you would set the jvm_invocation environment variable and start dbx as follows:
% jvm_invocation="xyz -Xdebug"; export jvm_invocation % dbx myclass.class
If you want dbx to start 64-bit JVM software to debug an application that requires 64-bit object libraries, include the -d64 option when you set the jvm_invocation environment variable:
jvm_invocation="/myjava/java -Xdebug -d64"