Skip to main content

Problems with Debugger-Proxy Sniffer

9 replies [Last post]
kingpommes
Offline
Joined: 2008-11-12
Points: 0

Hi,
I have a problem with the sniffer option of the SDP.

If I start the proxy:
./d sdproxy -sniffer -cp:./squawk_classes.jar

and the SDA in the VM:
./squawk -cp:./squawk_classes.jar com.sun.squawk.debugger.sda.SDA HelloWorld

I get an error because of the wrong Handshake.
The Proxy sends "JDWP-Handshake" instead of "SDWP-Handshake" to the VM.

After I had fixed the Handshake the next error appeared:

SDP:
Trying to connect to VM on socket://localhost:2800
Failed to establish connection with VM: Connection refused - trying again in 5 seconds...
Trying to connect to VM on socket://localhost:2800
Established connection to VM (handshake took 16ms)
Waiting for connection from debugger on serversocket://:2900
Synchronizing debug state with VM....build failed: error invoking public static void com.sun.squawk.debugger.sdp.SDP.main(java.lang.String[]) throws java.io.IOException
caused by: java.lang.NullPointerException
at com.sun.squawk.debugger.sdp.SDP.waitTillReadyForDebugger0(SDP.java:429)
at com.sun.squawk.debugger.sdp.SDP$1.run(SDP.java:483)
at com.sun.squawk.debugger.JDWPConnection.(JDWPConnection.java:124)
at com.sun.squawk.debugger.JDWPListener.open(JDWPListener.java:102)
at com.sun.squawk.debugger.sdp.SDP.connect(SDP.java:480)
at com.sun.squawk.debugger.sdp.SDP.connectToDebugger(SDP.java:514)
at com.sun.squawk.debugger.sdp.SDP.goSniff(SDP.java:615)
at com.sun.squawk.debugger.sdp.SDP.main(SDP.java:590)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at com.sun.squawk.builder.Build.java(Build.java:2331)
at com.sun.squawk.builder.JavaCommand.run(JavaCommand.java:71)
at com.sun.squawk.builder.Build.run(Build.java:1018)
at com.sun.squawk.builder.Build.runCommand(Build.java:983)
at com.sun.squawk.builder.Build.mainProgrammatic(Build.java:1504)
at com.sun.squawk.builder.Build.main(Build.java:1468)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at com.sun.squawk.builder.launcher.Launcher.main(Launcher.java:58)

Am I doing something wrong?

Thanks,
Dennis

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
kingpommes
Offline
Joined: 2008-11-12
Points: 0

Hi Derek,
I have detected an error during my analysis of the communication between Java SE and the debugger of eclipse. The error appears after the VM has sent an VM_DEATH event to the debugger:

[i][Thread JVM-Sniffer] Received from JVM: CommandPacket[id=5,size=21]:Event.Composite
[Thread JVM-Sniffer] in[byte] suspendPolicy=0
[Thread JVM-Sniffer] suspendPolicy: NONE
[Thread JVM-Sniffer] in[int] events=1
[Thread JVM-Sniffer] in[byte] eventKind=99
[Thread JVM-Sniffer] eventKind: VM_DEATH
[Thread JVM-Sniffer] in[int] requestID=0
[Thread JVM-Sniffer] Sending to Debugger: CommandPacket[id=5,size=21]:Event.Composite
[b][Thread JVM-Sniffer] Stopping JDWP listener due to exception: java.io.EOFException
java.io.EOFException
at java.io.DataInputStream.readInt(DataInputStream.java:375)
at com.sun.squawk.debugger.JDWPConnection.readPacket(JDWPConnection.java:192)
at com.sun.squawk.debugger.JDWPListener.run(JDWPListener.java:122)
at java.lang.Thread.run(Thread.java:619)[/b]
[Thread JVM-Sniffer] Completed event loop
[Thread JVM-Sniffer] Initiating shutdown of com.sun.squawk.debugger.sdp.JDWPSniffer$JVMSniffer@63415de6...
[Thread JVM-Sniffer] Closing connection: socket://localhost:2800
[Thread JVM-Sniffer] Initiating shutdown of com.sun.squawk.debugger.sdp.JDWPSniffer$JDBSniffer@6443226...
[Thread JVM-Sniffer] Closing connection: serversocket://:2900
[Thread Debugger-Sniffer] Stopping JDWP as connection was closed: Closed by Thread[JVM-Sniffer,5,main]
[Thread Debugger-Sniffer] Completed event loop
[Thread SDP] Completed shutdown
Sniff session completed.
[/i]

Dennis

derek_white
Offline
Joined: 2006-09-08
Points: 0

Hi Dennis,

Thanks for noticing this. Unless this is blocking you it may not get fixed as quickly as your last bug. Could you please add it as a defect so it doesn't get lost:

https://squawk.dev.java.net/servlets/ProjectIssues

Thank you,

- Derek

kingpommes
Offline
Joined: 2008-11-12
Points: 0

I have added the problem as a defect. ID:1417

Dennis

kingpommes
Offline
Joined: 2008-11-12
Points: 0

Hi Derek,
I've tried to place the Debugger-Proxy between Eclipse and Java SE. It doesn't work:

start java:
[i]kingpommes@Karlsruhe:~/workspace2/HelloWorld/bin$ java -agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=localhost:2800 HelloWorld[/i]

start sdp-proxy:
[i]kingpommes@Karlsruhe:~/workspace2/Squawk$ ./d sdproxy -log:debug -sniffer -cp:../HelloWorld/bin
Launcher: Found tools.jar in /home/kingpommes/jdk1.5.0_16_i586/lib/tools.jar, by popping up a level from jre.
Builder.JDK: Looking for JDK in /home/kingpommes/jdk1.5.0_16_i586, popped up a level from jre
Launcher: Found tools.jar in /home/kingpommes/jdk1.5.0_16_i586/lib/tools.jar, by popping up a level from jre.
For vm2c tools.jar=/home/kingpommes/jdk1.5.0_16_i586/lib/tools.jar
[running sdproxy...]
Paramter 0:-log:debug
Paramter 1:-sniffer
Paramter 2:-cp:../HelloWorld/bin
Trying to connect to VM on socket://localhost:2800
logging level: 3
logging to System.out
[Thread SDP] Establishing connection with socket://localhost:2800...
[Thread SDP] Connection with socket://localhost:2800 established
Established connection to VM (handshake took 18ms)
Waiting for connection from debugger on serversocket://:2900
[/i]

after the start of the eclipse debugger:
[i][Thread SDP] Establishing connection with serversocket://:2900...
[Thread SDP] Connection with serversocket://:2900 established
Synchronizing debug state with VM...[Thread SDP] Waiting for proxy types to be populated...
.build failed: error invoking public static void com.sun.squawk.debugger.sdp.SDP.main(java.lang.String[]) throws java.io.IOException
caused by: java.lang.NullPointerException
at com.sun.squawk.debugger.sdp.SDP.waitTillReadyForDebugger0(SDP.java:429)
at com.sun.squawk.debugger.sdp.SDP$1.run(SDP.java:483)
at com.sun.squawk.debugger.JDWPConnection.(JDWPConnection.java:124)
at com.sun.squawk.debugger.JDWPListener.open(JDWPListener.java:102)
at com.sun.squawk.debugger.sdp.SDP.connect(SDP.java:480)
at com.sun.squawk.debugger.sdp.SDP.connectToDebugger(SDP.java:514)
at com.sun.squawk.debugger.sdp.SDP.goSniff(SDP.java:615)
at com.sun.squawk.debugger.sdp.SDP.main(SDP.java:590)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at com.sun.squawk.builder.Build.java(Build.java:2331)
at com.sun.squawk.builder.JavaCommand.run(JavaCommand.java:71)
at com.sun.squawk.builder.Build.run(Build.java:1018)
at com.sun.squawk.builder.Build.runCommand(Build.java:983)
at com.sun.squawk.builder.Build.mainProgrammatic(Build.java:1504)
at com.sun.squawk.builder.Build.main(Build.java:1468)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at com.sun.squawk.builder.launcher.Launcher.main(Launcher.java:58)
[/i]

Do you have an idea, why it doesn't work?

Is there a way to start the debugger-proxy without the script [i]"d.sh"[/i]?
If I try to start the SDP with the following line:

[i]java -cp ./debugger/classes:./debugger-proxy/classes com.sun.squawk.debugger.sdp.SDP -cp:../HelloWorld/bin[/i]

I get an error:

[i]Exception in thread "SDP" java.lang.NullPointerException
at java.util.Hashtable.remove(Hashtable.java:436)
at com.sun.squawk.debugger.sdp.SDP.main(SDP.java:596)[/i]

Dennis

derek_white
Offline
Joined: 2006-09-08
Points: 0

Yep, you found some bugs! A fix is in progress...

In the mean time, here is the best way to invoke the sniffer from the command line:

> java -cp hosted-support/classes:debugger/classes:debugger-proxy/classes:cldc/classes com.sun.squawk.debugger.sdp.SDP -sniffer -log:debug

The first bug that turned up in the sniffer was due to some changes in the non-sniffing proxy. The 2nd was basically due to fact that the sniffer is repurposing the Squawk proxy to talk to any JVM instead of just Squawk, and it isn't always flexible enough to do that. But it's getting better.

derek_white
Offline
Joined: 2006-09-08
Points: 0

Bug #1416 is fixed in svn rev 242.

https://squawk.dev.java.net/issues/show_bug.cgi?id=1416

Let me know if that helps...

kingpommes
Offline
Joined: 2008-11-12
Points: 0

Hi Derek,
thank you for fixing the problem with the debugger-proxy and the sniffer option. It seems to work now.

Dennis

derek_white
Offline
Joined: 2006-09-08
Points: 0

Hi Dennis,

If you ever look at the JDWP documentation you'll see that it basically documents packet formats, not higher level interactions. The purpose of the "sniffer" option is to help figure out what the IDE/debugger is expecting to get from a JVM. it is designed to run between a JVM (like Java SE) and and IDE like NetBeans or Eclipse.

If you want to see the interactions between the IDE and Squawk, you can do "normal" debugging with the proxy, and use the logging options on both the proxy and the debugger agent in Squawk itself ("-log:verbose"). For even more detail, you can build withe the build property DEBUG_CODE_ENABLED=true, and use "-log:debug".

Was this what you were trying to do?

- Derek

kingpommes
Offline
Joined: 2008-11-12
Points: 0

Hi Derek,

thanks for your answer.

You are right. I want to see the interaction between the IDE and Squawk. The "-log:debug" option for the proxy is what I was looking for.

Dennis