views:

35

answers:

1

Hi, 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 Para's 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

A: 

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.

Yuval Rimar
well The core idea is to allow debugging of mutually exclusive threads within the same Server process, Tried it manually to get a Connection Refused. Is there a existing protocol that allows listening on a new port if a request comes in at a existing port that is servicing another request?(Edit for Punctuation) Thank you for your comments Yuval and Fredrick.
javaresearcher
Further I came across: http://download.oracle.com/javase/6/docs/technotes/guides/jpda/jpda_spis.html#TransportDev which talks about Developing a TransportService to support multiple concurrent connections to a single listener address. Now another question is has anyone made this or attempted to?
javaresearcher
@javaresearcher keep listening on a port after accepting a connection is not a problem. The problem here is that it would make the whole debugging process extremely unintuitive. A bit like driving a car with three passengers and a set of steering wheels and pedals in front of each seat. Only one would be able to be in control at any given time or things would go terribly wrong. I think it would make more sense if you tried to explain why you are trying to do it. Maybe there is a much better way to do what you want. (edit: see the "core idea" in your top comment now but why two debuggers?)
Fredrik
@Fredrik, Think cloud. Separate threads, mutually exclusive belonging to separate entities compartmentalized within a server process, But then each entity wants to debug its own Thread, though essentially it does not know what it is debugging is only a subset, Hope this sheds more light. I would love to hear if better ways exist.
javaresearcher
@javaresearcher I am thinking cloud just about everyday of the week but the debugger you want to use is not even in that picture. Stopping the VM on a breakpoint is not an option in such an environment.
Fredrik
@Fredrik, Thanks for your inputs!
javaresearcher