Java Platform Debugger Architecture - FAQs

»   Overview
 
»   Basic
 
»   CORBA
 
»   HotSpot VM
 
»   JNDI
 
  »   Mntr-Mgmt
 
»   Tools APIs
 
»   XML
 
 

Java Platform Debugger Architecture - FAQs


General

  1. What platforms are available? When will JPDA be available on the _______ platform?
  2. I'm getting a crash/exception/wrong result, what should I do?
  3. Is the JPDA source code available?
  4. Are there JPDA conformance tests?
  5. Are there debugger applications available which use JPDA?
  6. When will a better debugger application be available as part of the Java SE SDK?

Architecture

  1. Why are there three different interface layers in JPDA?
  2. Which interface layer should I use?
  3. Why do debugger applications run in a separate VM from the debuggee?
  4. Can JPDA be used to write a mixed mode (Java and C/C++) debugger?

Connection and Launching

  1. Can I attach multiple debuggers to the same VM?
  2. Can I attach a debugger to multiple VMs?
  3. What happens when I detach a debugger from a VM? Can a debugger be re-attached at a later time?
  4. What is the purpose of the -Xnoagent option?

JDI: Getting and Setting Values

  1. Can I evaluate Java programming language expressions?
  2. How do I retrieve instance field values?
  3. I see there are JDI methods to set values, but how do I get the instances of Value to pass into them?

JDI: Miscellaneous

  1. Why do I get AbsentInformationException when querying variable or line information from a method?
 

General

  1. 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.
  2. 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.
  3. 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.
  4. Are there JPDA conformance tests?
    At this time there are no conformance tests for JPDA.
  5. Are there debugger applications available which use JPDA?
    Yes. Search the internet for 'java ide' and 'java debugger' using your favorite search engine.
  6. 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

  1. 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.
  2. 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.
  3. 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.
  4. 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

  1. Can I attach multiple debuggers to the same VM?
    No.
  2. 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.
  3. 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.
  4. 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

  1. 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.
  2. How do I retrieve instance field values?
    Use com.sun.jdi.ObjectReference.getValue(Field).
  3. 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

  1. 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.
Left Curve
Java SDKs and Tools
Right Curve
Left Curve
Java Resources
Right Curve
VTS OnDemand RHS Banner



Duke's Choice RHS Banner

JavaOne 2014 Replay banner