Whole document tree
ContentsTransports TransportsA JPDA transport is a form of inter-process communication used by a debugger application process and the virtual machine that is being debugged (often called the target VM). JDI and JDWP admit the existence of transports and refer to individual transports by a unique name, but the JDI and JDWP specifications do not require specific transport implementations to exist. Transport implementations can allow communications between processes running in a single machine, on different machines, or either.In establishing a connection between a debugger application and a target VM, one side acts as a server, listening for a connection. At some later time the other side attaches to the listener and a connection is established. JPDA transports allow either the debugger application or the target VM to act as a server. During the establishment of a connection, transport addresses are used to identify the other side of a connection. Transport addresses are strings; their format depends on the transport implementation. The JPDA reference implementation on Win32 provides two transports: a shared memory transport and a socket transport. The JPDA reference implementation on Solaris platforms provides a socket transport. Future versions of the JPDA reference implementation may include additional transports, Future versions of the JPDA specification may provide an interface for plugging additional transports into an implementation. Socket TransportThe JPDA reference implementation provides a socket transport on both Solaris and Win32 platforms. The socket transport uses standard TCP/IP sockets to communicate information between debugger applications and target VM. With the socket transport, the debugger application and target VM can reside either on the same machine or on different machines. The socket transport is identified through a unique string, dt_socket. This name can be used to select the socket transport when invoking the target VM and when selecting a JDI connector.In contexts where a client is attaching to a server, socket transport addresses have the format "<name>:<port>" where <name> is the host name and <port> is the socket port number at which it attaches or listens. In contexts where a server is waiting for a client to attach, the address consists of the port number alone (the host name is implicit). Shared Memory TransportIn addition to the socket transport, the JPDA reference implementation provides a shared memory transport on the Win32 platform. The shared transport uses Win32 shared memory primitives to communicate information between debugger applications and target VM. With the shared memory transport, the debugger application and target VM must reside on the same machine. The shared memory transport is identified through a unique string, dt_shmem. This name can be used to select the socket transport when invoking the target VM and when selecting a JDI connector.Shared memory transport addresses are simply names that can be used as Win32 file-mapping object names.The name string can consist of any combination of characters, excluding the backslash. ConnectorsA connector is a JDI abstraction that is used in establishing a connection between a debugger application (written to the JDI) and a target VM. Different JDI implementations are free to provide different connector implementations to match the transports and VMs they support. The connector interfaces are very general, to allow JDI to be used with varying connector implementations. Connectors are configured through a set of name/value pairs. Specific connectors accept different name/value pairs.A good JDI client application will allow users to choose and configure any connector that may be present, but it can be beneficial to incorporate knowledge of specific connectors into the debugger to make their configuration a more pleasant user experience. The example JDB implementation provided with the JPDA illustrates this approach. The JDI reference implementations provides several connectors which map to the available transport types and the modes of connection (launching, listening, and attaching). These connectors are described in the following sections. Sun Command Line Launching ConnectorThis connector can be used by a debugger application to launch a Sun VM or any other VM which supports the same invocation options with respect to debugging. The details of launching the VM and specifying the necessary debug options are handled by the connector. The underlying transport used by this connector depends on the platform. On Win32, the shared memory transport is used. On Solaris, the socket transport is used.This connector is uniquely identified by the name "com.sun.jdi.CommandLineLaunch".
Raw Command Line Launching ConnectorThis connector can be used by a debugger application to launch any VM. The entire command line must be specified and it is not edited in any way. The details of launching the VM with the given command line are handled by the connector. The underlying transport used by this connector depends on the platform. On Win32, the shared memory transport is used. On Solaris, the socket transport is used.This connector is uniquely identified by the name "com.sun.jdi.RawCommandLineLaunch".
Socket Attaching ConnectorThis connector can be used by a debugger application to attach to a currently running target VM through the socket transport.. The target VM must have been invoked with options consistent with this connector's arguments described in the table below. For Sun VMs, the necessary options are described below.This connector is uniquely identified by the name "com.sun.jdi.SocketAttach".
Shared Memory Attaching ConnectorThis connector can be used by a debugger application to attach to a currently running target VM through the shared memory transport..It is available only on the Win32 platform. The target VM must have been invoked with options consistent with this connectors arguments described in the table below. For Sun VMs, the necessary options are described below.This connector is uniquely identified by the name "com.sun.jdi.SharedMemoryAttach".
Socket Listening ConnectorThis connector can be used by a debugger application to accept a connection from a separately invoked target VM through the socket transport.. The target VM must be invoked with options consistent with this connector's arguments described in the table below. For Sun VMs, the necessary options are described below.This connector can accept connections from multiple target VMs. This connector is uniquely identified by the name "com.sun.jdi.SocketListen".
Shared Memory Listening ConnectorThis connector can be used by a debugger application to accept a connection from a separately invoked target VM through the shared memory transport..It is available only on the Win32 platform. The target VM must be invoked with options consistent with this connectors arguments described in the table below. For Sun VMs, the necessary options are described below.This connector can accept connections from multiple target VMs. This connector is uniquely identified by the name "com.sun.jdi.SharedMemoryListen".
Sun VM Invocation OptionsThis section describes the options necessary to invoke Sun VMs for debugging. If your debugger application uses the JDI Sun Command Line Launching Connector, the appropriate options are set for you. In other cases, when the VM is invoked manually, you will need to set them.Required Classic VM OptionsThe following VM invocation options are required to debug applications running under the classic VM.
Required Hotspot Performance Engine OptionsThe Hotspot Performance Engine requires the -Xdebug and -Xrunjdwp options described above. The -Xnoagent and -Djava.compiler=NONE options are not required; however, for compatibility, these options are accepted and ignored.-Xrunjdwp sub-optionsThe -Xrunjdwp option can be further qualified with sub-options. The sub-options are specified as follows:-Xrunjdwp:<name1>[=<value1>],<name2>[=<value2>]... The table below describes the options that can be used:
-Xrunjdwp Examples
Debugging Plug-in AppletsBeginning with version 1.2.2 of the Java Plug-in, applets running under the Plug-in can be debugged. The required VM options described above can be specified in the Plug-In control panel, under the "Basic" tab, in the "Java Run-Time Parameters". The debug options under the "Advanced" tab should not be used as they will enable the old sun.tools.debug debug support. In future versions of the Plug-in, these debug options will be changed to use JPDA.JDI launching connectors cannot be used to debug Plug-in applets. Connecting with JDBThe example implementation of JDB provided with the JPDA, provides an illustration of the usage of JDI connectors. There are "shortcut" options to JDB which assume the use of connectors known to it (that is, connectors present in the reference implementation). It also provides a way to establish a general connection using any connector. While JDB is hardly an example of a good debugger interface, it does provide a simple example of connectors in use.In JDB, the -attach option provides access to one of the attaching connectors in the reference implementation (shared memory on Win32, sockets on Solaris). The -listen option provides access to one of the listening connectors in the reference implementation (shared memory on Win32, sockets on Solaris). A class name and arguments specified directly on the command line provide access to the Sun command line launching connector. For example: jdb -attach myhost:8000 is an easy way to attach to a target VM with the Socket Attaching Connector (on Solaris), and jdb Hello 1 2 3 is an easy way to launch a target VM with the Sun Command Line Launching Connector. However, the -connect option is also provided by JDB to handle any connector by taking an connector name and a set of arbitrary name/value argument pairs. For example the command lines above have the following equivalents. jdb -connect com.sun.jdi.SocketAttach:hostname=myhost,port=8000
These command lines are more cumbersome than the ones above, but the -connect option can be used with any connector. This kind of operation is a primitive example of how a JDI debugger can deal with any kind of connector while providing a simplified interface for dealing with common, well-known connectors.
|