Remote Debugging Eclipse
Recently I ran into a nasty bug that will get reproduced only in a hosted instance ofEclipse. The best way to catch this type of bug is through remote debugging.
Remote Debugging
Remote debugging is a Java feature. Since Eclipse is a Java application (running inside a JVM) we can remote debug it given the JVM used to launch Eclipse supports it. Most JVMs supports remote debugging from pre-1.4 era.
WebSphere give a nice definition: "Debugging a program running on one system while controlling the program from another system is known as remote debugging. The debugger supports remote debugging by allowing you to run the debugger user interface on one system, while running the debug engine on another system. The system running the debugger user interface is known as the local system. The system where the debug engine runs is known as the remote system."
How to remote debug Eclipse?
Published at DZone with permission of Ankur Sharma, author and DZone MVB.Remote Debugging
Remote debugging is a Java feature. Since Eclipse is a Java application (running inside a JVM) we can remote debug it given the JVM used to launch Eclipse supports it. Most JVMs supports remote debugging from pre-1.4 era.
WebSphere give a nice definition: "Debugging a program running on one system while controlling the program from another system is known as remote debugging. The debugger supports remote debugging by allowing you to run the debugger user interface on one system, while running the debug engine on another system. The system running the debugger user interface is known as the local system. The system where the debug engine runs is known as the remote system."
How to remote debug Eclipse?
- Start the Eclipse as server We need to pass -Xdebug VM argument to Eclipse to tell JVM to get launched with debugger. We need to pass certain more options to tell it to start in server mode and listen to a particular socket.
- Creating a Remote Java Application debug config Start another instance of Eclipse where we will debug the other instance launched in Step 1. Also check out the code that you want to debug. Once this is done, open debug launch configurations and choose 'Remote Java Application' and create a new debug config.
- Connecting and attaching to the remote server Launch the debug config like any other debug config. This will launch the debug mode. Place the breakpoints and do the relevant actions in the server Eclipse instance to hit the.
- Debugging The debug process is the same as normal debug. No differences. However, if you change the code then the updated code is not what that would run. Remember the server Eclipse is still running in separate JVM. So what you are getting is only a reflection of the code execution. The debug session will end when the serve Eclipse instance is closed or the client Eclipse is disconnected using the disconnect button in the debug view.
This command shall be entered on the command prompt
eclipse.exe -vmargs -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=1044
See the complete details for the options and their meaning at Connection and Invocation Details page.
The project text box shall contain the project which has the code that needs to be debugged. The connection type shall be standard socket attach while port will contain the socket address we gave in Step 1. The host is localhost we both instances are running of same machine.
From http://blog.ankursharma.org/2010/05/remote-debugging-eclipse.html
(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)






Comments
Florin Botis replied on Tue, 2010/06/01 - 6:12am
Nirmal Mukundan replied on Fri, 2011/01/28 - 5:59am
Javin Paul replied on Fri, 2011/04/08 - 9:17am