Connecting multiple debuggers to a debugee (Java,JPDA)
Ive been trying unsuccessfully to connect two client debuggers to a Debuggee program in context of JPDA. Is this possible or are there workarounds to make it happen?
I am using eclipse as the IDE (edit for typo). Think of a server program as a Hello World which Prints out:
System.out.println("I have the String"); //1
System.out.println("You will have to pass through the breakpoints before you shall see");
System.out.println("breakpoints");
System.out.println("before yo开发者_如何学编程u shall see"); //4
We can put breakpoints at lines 1 and 4.
Step 1: The params passed to the program in Run Configuration:
-Xdebug -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=y
(server=y
tells vm to behave like a server, suspend=y
implies that prog execution will be suspended till debugger latches on to it)
and Run the program.
Step 2: Go to Debug as , Debug config ,Remote Java application
and
create a new instance:
Project: Same as before
Connection type: Socket Attach(Socket Attach)
Host:LocalHost
Port:8000
Now when I debug Prog execution stops at the specified breakpoint. What I cant do is create another instance of this remote debugger that can latch on to the server(prog 1), I get a connection refused when I do that. Let me know if anyone else has faced this problem and if a workaround exists. Thanks!
Thanks
AFAIK there can be only one instance of debugger connected to a java program any given time. Once you started you program in debug, Eclipse connects to the debugged program blocking all other connection attempts. If you want to connect remotely you can run the program not in debug mode and add the parameters: -Xdebug -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=y to java parameters manually, then you should be able to connect with another debugger.
I don't know how things were in 2010, but in 2014 this is doable. I'm debugging an applet and a servlet at the same time eventough they use different JVM, to do so just start your remote debug process in eclipse like socket Listen, the start the first java applicaction with:
-Xdebug -Xrunjdwp:transport=dt_socket,address=127.0.0.1:8787,suspend=y
Then start the same eclipse remote debug process and start another java process with the same options, you should see the processes spawn like this:
You can see the two different JVM listening in the same port (nevermind the name of the 'applet' process)
精彩评论