Ruby and the Java Debug Wire Protocol · Summer 2003 - Rich Meets Chad Chad and I started talking...
Transcript of Ruby and the Java Debug Wire Protocol · Summer 2003 - Rich Meets Chad Chad and I started talking...
![Page 1: Ruby and the Java Debug Wire Protocol · Summer 2003 - Rich Meets Chad Chad and I started talking about what I do for DARPA I mentioned the Ruby projects on my plate FreeRIDE, FreeBASE,](https://reader034.fdocuments.us/reader034/viewer/2022050119/5f4fe892503cf3427c53202d/html5/thumbnails/1.jpg)
Ruby and theJava Debug Wire Protocol
What were we thinking?
![Page 2: Ruby and the Java Debug Wire Protocol · Summer 2003 - Rich Meets Chad Chad and I started talking about what I do for DARPA I mentioned the Ruby projects on my plate FreeRIDE, FreeBASE,](https://reader034.fdocuments.us/reader034/viewer/2022050119/5f4fe892503cf3427c53202d/html5/thumbnails/2.jpg)
DARPA UltraLog Project
I get paid to write and maintain a Ruby framework on a DARPA project
Scripted control of a 300 machine distributed multi-agent Java framework
A single Ruby script controls the execution of the 100+ Java VMs per experiment run
Interaction is between Java & Ruby is limited to: Log4J ‘push events’ Servlet ‘pull events’ Servlet-based reporting
![Page 3: Ruby and the Java Debug Wire Protocol · Summer 2003 - Rich Meets Chad Chad and I started talking about what I do for DARPA I mentioned the Ruby projects on my plate FreeRIDE, FreeBASE,](https://reader034.fdocuments.us/reader034/viewer/2022050119/5f4fe892503cf3427c53202d/html5/thumbnails/3.jpg)
Summer 2003 - Rich Meets Chad
Chad and I started talking about what I do for DARPA
I mentioned the Ruby projects on my plate FreeRIDE, FreeBASE, Jabber4r Utopia (MetaUI), Rendezvous, Ratify (testing)
I mentioned the idea of having Ruby debug Java applications at a low level It would allow my project to have better control of the
JVMs We both thought that would be cool
![Page 4: Ruby and the Java Debug Wire Protocol · Summer 2003 - Rich Meets Chad Chad and I started talking about what I do for DARPA I mentioned the Ruby projects on my plate FreeRIDE, FreeBASE,](https://reader034.fdocuments.us/reader034/viewer/2022050119/5f4fe892503cf3427c53202d/html5/thumbnails/4.jpg)
Java Platform Debug Architecture (JPDA)
Java Virtual Machine Debug Interface (JVMDI) Low level native interface Service JVM must provide for debugging
Java Debug Wire Protocol (JDWP) Defines format of info and requests transferred between
debugging process and debugger from end Java Debug Interface (JDI)
High level programming interface for remote debugging
Java 1.4 delivers full speed debugging!!!
![Page 5: Ruby and the Java Debug Wire Protocol · Summer 2003 - Rich Meets Chad Chad and I started talking about what I do for DARPA I mentioned the Ruby projects on my plate FreeRIDE, FreeBASE,](https://reader034.fdocuments.us/reader034/viewer/2022050119/5f4fe892503cf3427c53202d/html5/thumbnails/5.jpg)
What to Implement?
JVMDI (N/A) For JVM writers
JDWP (Rich) Packet-based (over TCP) binary protocol 78 Packet formats
JDI (Chad) Needs to be implemented on top of JDWP High level Ruby API (iterators, blocks, etc)
![Page 6: Ruby and the Java Debug Wire Protocol · Summer 2003 - Rich Meets Chad Chad and I started talking about what I do for DARPA I mentioned the Ruby projects on my plate FreeRIDE, FreeBASE,](https://reader034.fdocuments.us/reader034/viewer/2022050119/5f4fe892503cf3427c53202d/html5/thumbnails/6.jpg)
Implementing JDWP
![Page 7: Ruby and the Java Debug Wire Protocol · Summer 2003 - Rich Meets Chad Chad and I started talking about what I do for DARPA I mentioned the Ruby projects on my plate FreeRIDE, FreeBASE,](https://reader034.fdocuments.us/reader034/viewer/2022050119/5f4fe892503cf3427c53202d/html5/thumbnails/7.jpg)
How to Implement JDWP
Detailed HTML specification
Binary packed format
Documentation in the specification
Parse the HTML? What do you do
with the content?
![Page 8: Ruby and the Java Debug Wire Protocol · Summer 2003 - Rich Meets Chad Chad and I started talking about what I do for DARPA I mentioned the Ruby projects on my plate FreeRIDE, FreeBASE,](https://reader034.fdocuments.us/reader034/viewer/2022050119/5f4fe892503cf3427c53202d/html5/thumbnails/8.jpg)
Convert Protocol to Ruby “Metadata”
![Page 9: Ruby and the Java Debug Wire Protocol · Summer 2003 - Rich Meets Chad Chad and I started talking about what I do for DARPA I mentioned the Ruby projects on my plate FreeRIDE, FreeBASE,](https://reader034.fdocuments.us/reader034/viewer/2022050119/5f4fe892503cf3427c53202d/html5/thumbnails/9.jpg)
Matadata Structures
Command sets Commands Documentation Repeat Structures Case/When Structures Data Elements Error Data Elements
![Page 10: Ruby and the Java Debug Wire Protocol · Summer 2003 - Rich Meets Chad Chad and I started talking about what I do for DARPA I mentioned the Ruby projects on my plate FreeRIDE, FreeBASE,](https://reader034.fdocuments.us/reader034/viewer/2022050119/5f4fe892503cf3427c53202d/html5/thumbnails/10.jpg)
Code Generate the Protocol
spec2ruby.rb(600 lines) packets.rb
(5600 lines)
jdwp_spec.rb(1300 lines)
metadata.rb(320 lines)
![Page 11: Ruby and the Java Debug Wire Protocol · Summer 2003 - Rich Meets Chad Chad and I started talking about what I do for DARPA I mentioned the Ruby projects on my plate FreeRIDE, FreeBASE,](https://reader034.fdocuments.us/reader034/viewer/2022050119/5f4fe892503cf3427c53202d/html5/thumbnails/11.jpg)
The spec2ruby Generator
![Page 12: Ruby and the Java Debug Wire Protocol · Summer 2003 - Rich Meets Chad Chad and I started talking about what I do for DARPA I mentioned the Ruby projects on my plate FreeRIDE, FreeBASE,](https://reader034.fdocuments.us/reader034/viewer/2022050119/5f4fe892503cf3427c53202d/html5/thumbnails/12.jpg)
Generator Output => packets.rb
5600 lines of fully RDoc’d code One Class per packet type
Subclass of JDWP::Packets::Packet Struct(s) for complex constructor data Struct for Reply Accessors for data encode method decode method
![Page 13: Ruby and the Java Debug Wire Protocol · Summer 2003 - Rich Meets Chad Chad and I started talking about what I do for DARPA I mentioned the Ruby projects on my plate FreeRIDE, FreeBASE,](https://reader034.fdocuments.us/reader034/viewer/2022050119/5f4fe892503cf3427c53202d/html5/thumbnails/13.jpg)
ClassesBySignature Example
![Page 14: Ruby and the Java Debug Wire Protocol · Summer 2003 - Rich Meets Chad Chad and I started talking about what I do for DARPA I mentioned the Ruby projects on my plate FreeRIDE, FreeBASE,](https://reader034.fdocuments.us/reader034/viewer/2022050119/5f4fe892503cf3427c53202d/html5/thumbnails/14.jpg)
ClassesBySignature Example
![Page 15: Ruby and the Java Debug Wire Protocol · Summer 2003 - Rich Meets Chad Chad and I started talking about what I do for DARPA I mentioned the Ruby projects on my plate FreeRIDE, FreeBASE,](https://reader034.fdocuments.us/reader034/viewer/2022050119/5f4fe892503cf3427c53202d/html5/thumbnails/15.jpg)
ClassesBySignature Example
![Page 16: Ruby and the Java Debug Wire Protocol · Summer 2003 - Rich Meets Chad Chad and I started talking about what I do for DARPA I mentioned the Ruby projects on my plate FreeRIDE, FreeBASE,](https://reader034.fdocuments.us/reader034/viewer/2022050119/5f4fe892503cf3427c53202d/html5/thumbnails/16.jpg)
ClassesBySignature Example
![Page 17: Ruby and the Java Debug Wire Protocol · Summer 2003 - Rich Meets Chad Chad and I started talking about what I do for DARPA I mentioned the Ruby projects on my plate FreeRIDE, FreeBASE,](https://reader034.fdocuments.us/reader034/viewer/2022050119/5f4fe892503cf3427c53202d/html5/thumbnails/17.jpg)
require “jdwp”
packets.rb Generated code
constrants.rb JDWP constants from the specification
packet.rb Encode/decode values and packet header
session.rb Manage connection, send/receive packets, events
socket_transport.rb TCP/IP based transport, send/receive data
![Page 18: Ruby and the Java Debug Wire Protocol · Summer 2003 - Rich Meets Chad Chad and I started talking about what I do for DARPA I mentioned the Ruby projects on my plate FreeRIDE, FreeBASE,](https://reader034.fdocuments.us/reader034/viewer/2022050119/5f4fe892503cf3427c53202d/html5/thumbnails/18.jpg)
Simple JDWP Example
![Page 19: Ruby and the Java Debug Wire Protocol · Summer 2003 - Rich Meets Chad Chad and I started talking about what I do for DARPA I mentioned the Ruby projects on my plate FreeRIDE, FreeBASE,](https://reader034.fdocuments.us/reader034/viewer/2022050119/5f4fe892503cf3427c53202d/html5/thumbnails/19.jpg)
Implementing JDI
![Page 20: Ruby and the Java Debug Wire Protocol · Summer 2003 - Rich Meets Chad Chad and I started talking about what I do for DARPA I mentioned the Ruby projects on my plate FreeRIDE, FreeBASE,](https://reader034.fdocuments.us/reader034/viewer/2022050119/5f4fe892503cf3427c53202d/html5/thumbnails/20.jpg)
JDI Overview High level Ruby classes to represent Java
debug structures JavaVirtualMachine
Suspend, resume, exit, dispose, capabilities, version, classpaths, each_class, each_thread, each_thread_group
Thread, ThreadGroup Class, Method, Variable Location, Breakpoint
Hides JDWP packet complexity
![Page 21: Ruby and the Java Debug Wire Protocol · Summer 2003 - Rich Meets Chad Chad and I started talking about what I do for DARPA I mentioned the Ruby projects on my plate FreeRIDE, FreeBASE,](https://reader034.fdocuments.us/reader034/viewer/2022050119/5f4fe892503cf3427c53202d/html5/thumbnails/21.jpg)
Simple JDI Example
![Page 22: Ruby and the Java Debug Wire Protocol · Summer 2003 - Rich Meets Chad Chad and I started talking about what I do for DARPA I mentioned the Ruby projects on my plate FreeRIDE, FreeBASE,](https://reader034.fdocuments.us/reader034/viewer/2022050119/5f4fe892503cf3427c53202d/html5/thumbnails/22.jpg)
Demo
![Page 23: Ruby and the Java Debug Wire Protocol · Summer 2003 - Rich Meets Chad Chad and I started talking about what I do for DARPA I mentioned the Ruby projects on my plate FreeRIDE, FreeBASE,](https://reader034.fdocuments.us/reader034/viewer/2022050119/5f4fe892503cf3427c53202d/html5/thumbnails/23.jpg)
Summary
RubyJDWP lets you debug Java applications from Ruby Low level packets (jdwp)
Metadata driven code generation High level API (jdi)
JDWP library complete JDI library started
Moving on to Breakpoints, Locations Project on RubyForge
http://www.rubyforge.org/projects/rubyjdwp