Search code examples
javadebuggingremote-debugging

Java remote debugging, how does it work technically?


I really like the remote debugging facilities of the JVM. But I wonder how it works internally.

My assumption: It is done through a JVM feature where the running process is downloading/using the source-code from the attached remote-debugger (like IDE) It knows the line of the current stack-trace and then can jump to the respective IDE breakpoint. The communication of stack-trace and introspection of the application state is then done either through sockets or shared-memory (setting of remote debugger).

Has anybody interesting links/resources on that?


Solution

  • The debugging features of the JVM are provided via the Java Platform Debugger Architecture (JPDA).

    The JPDA itself is composed of the following:

    • Java Virtual Machine Tool Interface (JVM TI) - the native programming interface for tools to use. This interface allows for state inspection and helps in controlling the flow of execution within the debuggee.
    • Java Debug Wire Protocol (JDWP) - used to define the communication between the debugger and debuggee processes.
    • Java Debug Interface (JDI) - this interface allows tool developers to write remote debugger applications.

    The diagram listed in the JPDA architecture structure is a good starting point. Additional places to look for would be the guides listed in the JPDA page.