2

I'm working on a Java debugger that uses JDWP, talking to the Android VM.

I'm most interested in going from the desktop to the Emulator, and not on the device. I know that on the device, it's a whole different matter, so that's why I want to concentrate going from the desktop to the Emulator.

I'm finding that some common JDWP packet commands get 'ERROR_NOT_IMPLEMENTED' errors, so it would be a lot easier if I could spy on, or be able to capture JDWP packets coming from known working debuggers, to get a better idea of what combination of commands they are sending. Being able to get the replies would be good too.

I looked at Wireshark and WinDump, but they all seem to be interface based, and no matter what settings I've tried to use, I get nothing packet-wise.

My question is, is there any tool I can use for this?

Thanks!

user1572522
  • 569
  • 2
  • 11
  • 26
  • 1
    I was under the impression this works via adb and that the two parts of adb talk to each other via a loopback TCP socket and to the emulator on loopback port 5555. But it is possible some of it is now unix domain sockets - adbd to the vm on the device has always been unix domain. Note that the source to adb is readily available - along with that for the DVM or ART. – Chris Stratton Oct 22 '14 at 01:43
  • 1
    For mine I do: 'adb jdwp' get the PID, then 'adb forward tcp:8000 jdwp:(PID)', but I guess other debuggers could get the port a different way. I'm trying to look at the VM code, but it's going to take a long time to find the different bits of info that I need. – user1572522 Oct 22 '14 at 03:31
  • Here's one of many issues I'm trying to resolve. I want to try to set a breakpoint, and that requires a Location object, and that has an "unsigned eight byte location", but when I try to do a LineTable command, with the ClassId and MethodId, it returns 'ERROR_NOT_IMPLEMENTED'.. – user1572522 Oct 22 '14 at 17:55
  • It seems you have the port identified, can't you tcpdump the loopback interface, filter on that port, and set a breakpoint in the debugger to see how it is done? – Chris Stratton Oct 22 '14 at 17:56
  • 1
    Thanks a lot for your replies. I tried to use RawCap, set to capture everything on 127.0.0.1 Loopback, ran my app, that I know was using port 8000, and it looks like it captured everything, in both directions! It saves everything to a .pcap file, and I can "read" it in Wireshark! I just have to skip the whole TCP header to look at the data for each packet. Thanks! – user1572522 Oct 22 '14 at 23:10
  • Great! Though I think all I've really done is encourage you to run with your original idea. – Chris Stratton Oct 23 '14 at 00:24

1 Answers1

1

I have a project on GitHub that allows you to "spy" on the JDWP traffic, I've developed it while I was working on the NetBeans debugger to help me analyze debugger related issues.

Have a look here: https://github.com/kherink/jdwp-analyzer

karel.herink
  • 927
  • 9
  • 10