Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 you 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

like image 228
javaresearcher Avatar asked Oct 19 '10 22:10

javaresearcher


1 Answers

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.

like image 105
Yuval Rimar Avatar answered Sep 23 '22 03:09

Yuval Rimar