|
 Technologies |
|
|
|
|
|
Java Platform Debugger Architecture - FAQs
General
- What platforms are available? When will JPDA be available on the _______ platform?
- I'm getting a crash/exception/wrong result, what should I do?
- Is the JPDA source code available?
- Are there JPDA conformance tests?
- Are there debugger applications available which use JPDA?
- When will a better debugger application be available as part of the Java SE SDK?
Architecture
- Why are there three different interface layers in JPDA?
- Which interface layer should I use?
- Why do debugger applications run in a separate VM from the debuggee?
- Can JPDA be used to write a mixed mode (Java and C/C++) debugger?
Connection and Launching
- Can I attach multiple debuggers to the same VM?
- Can I attach a debugger to multiple VMs?
- What happens when I detach a debugger from a VM? Can a debugger be re-attached at a later time?
- What is the purpose of the
-Xnoagent option?
JDI: Getting and Setting Values
- Can I evaluate Java programming language expressions?
- How do I retrieve instance field values?
- I see there are JDI methods to set values, but how do I get the instances of
Value to pass into them?
JDI: Miscellaneous
- Why do I get
AbsentInformationException when querying variable or line information from a method?
General
-
What platforms are available? When will JPDA be available on the _______ platform?
JPDA is included in the Java Software Development Kit (SDK), Standard Edition (Java SE) for all platforms that Sun supports.
JPDA implementations on other platforms are the responsibility of those porting the SDK - please contact them for information.
-
I'm getting a crash/exception/wrong result, what should I do?
Please submit a bug report.
Be sure to include:
- Sample code that reproduces the problem.
- The text of the run, including the error text.
- Your platform.
- Which SDK (including version) you are using.
- Which version of JPDA you are using.
-
Is the JPDA source code available?
JPDA is included in the JDK code drops on jdk.java.net
In addition the source code for the example programs jdb and trace are included in file demo/jpda/examples.jar in the JDK installation directory.
-
Are there JPDA conformance tests?
At this time there are no conformance tests for JPDA.
-
Are there debugger applications available which use JPDA?
Yes. Search the internet for 'java ide' and 'java debugger' using your favorite search engine.
-
When will a better debugger application be available as part of the Java SE SDK?
Our mission is to create the infrastructure
by which quality development tools can be created - not to
create the best tools. A simple command line debugger (JDB)
is included with JPDA, but most users will find that they are much more productive using a JPDA based IDE such as NetBeans.
Architecture
- Why are there three different interface layers in JPDA?
Theoretically JPDA could have only one interface,
the Java Debug Wire Protocol (JDWP). This would allow
cross-platform remote debugging. Java virtual machines would
directly use the debuggee side of JDWP and debugger
applications would use the debugger side of JDWP. In fact,
some Java virtual machines do directly use the debuggee side of JDWP.
And some debugger applications do directly use the debugger side of JDWP.
Writing directly to JDWP however is painstaking work, information sent
across the wire must be read and written precisely. The Java Debug
Interface (JDI) is provided to make interfacing to JDWP easier, much
easier. Not only does JDI format data to be sent across the wire
and parse incoming data, but it provides queuing, caching, connection
initiation and many other services. And all this functionality
is available from an easy to use (OK, all things are relative) Java
programming language interface. In an analogous way, JVM TI insulates
Java virtual machine implementors from the intricacies of the debuggee
side of JDWP.
- Which interface layer should I use?
If you are writing a debugger (or debugger
like tool), the easy answer is, use JDI. You might
want to use JDWP if your front-end tool is not written
in the Java programming language. You might want to use
JVM TI if your tool has very specialized functionality,
not available in JDWP/JDI, that can only be performed
in the debuggee process and you have a lot of time on
your hands.
If you are writing a Java virtual machine the easy answer
is, implement JVM TI.
For more information see Why are there
three different interface layers in JPDA? and the
architecture documentation.
- Why do debugger applications run in a separate VM from the debuggee?
Any Java programming language code run for the
purpose of analyzing the behavior of a program (in the
same Java virtual machine) interferes with the behavior being
analyzed. Some of this interference is subtle,
for example: the order that
classes are loaded; and the scheduling of threads. More
severe however, is competition for resources,
for example, if the program
being analyzed is holding a lock needed by the analyzing code,
deadlock can occur. Finally, many operations can only be
reliably performed in a suspended virtual machine; if the
virtual machine is suspended the analysis code can not run.
At the core of the reliability problems of the old sun.tools.debug
interface is that part of its implementation ran as Java
programming language code in the debuggee virtual machine.
For this reason, the JPDA back-end implementation goes to great
pains to avoid the execution of any code in the debuggee virtual
machine.
- Can JPDA be used to write a mixed mode (Java and C/C++) debugger?
Yes, however this is a case where you would
probably need to use JVM TI (see Which interface
layer should I use?). We know of one product, not released
but working quite well, that uses a combination of JVM TI and native
debugging functionality to provide mixed mode debugging.
Connection and Launching
- Can I attach multiple debuggers to the same VM?
No.
- Can I attach a debugger to multiple VMs?
Yes, JDI allows you to have multiple VirtualMachine
objects, each connected to a separate Java virtual machine.
- What happens when I detach a debugger from a VM? Can a debugger be re-attached at a later time?
The documentation for
com.sun.jdi.VirtualMachine.dispose() describes what happens at
detach. If a Java virtual machine is detached properly
(with "dispose()"), a debugger can be re-attached.
- What is the purpose of the
-Xnoagent option?
This is a deprecated option which is accepted and ignored. It need not
be specified.
JDI: Getting and Setting Values
- Can I evaluate Java programming language expressions?
Expression evaluation is currently not included in
JPDA. However, there
is code in the supplied examples ( in demo/jpda/examples.jar) which implements expression
evaluation on top of JDI - see the "expr"
package. The JDB application
("tty" package) provides usage examples.
- How do I retrieve instance field values?
Use com.sun.jdi.ObjectReference.getValue(Field).
- I see there are JDI methods to set values, but how do I get the instances of
Value to pass into them?
The Value can of course come from a
previous getValue(). However, you are probably interested
in manufactured values like numbers and Strings - use the
mirrorOf methods in
com.sun.jdi.VirtualMachine, such as
VirtualMachine.mirrorOf(boolean).
JDI: Miscellaneous
- Why do I get
AbsentInformationException when querying variable or line information from a method?
Variable and line number information is stored in
the LocalVariableTable and
LineNumberTable attributes of
class files. These attributes are optional and compilers
generally have flags that control which are generated. For example,
by default Sun's javac produces line number but not variable
information; the "-g" flag specifies that all
debugging information should be generated.
|
|