Community
Participate
Working Groups
Java SE 1.6 has support for remote debugging via ProcessAttach. We should provide a remote debug launching connector for this. The details are here: http://download.oracle.com/javase/6/docs/technotes/guides/jpda/enhancements.html
I should mention here that there are may other kinds of launching connectors that we also do not support (but could). More information is here: http://download.oracle.com/javase/6/docs/technotes/guides/jpda/conninv.html#Connectors The SA core attaching connector sounds interesting...
Getting the connection information is all included in the API for Process attach - which includes an API for getting all VMs (and their process ids) that can be attached to. Here is a simple snippet that enumerates all of the VMs running that can be attached to and dumps out their properties: import java.util.Iterator; import java.util.List; import java.util.Map.Entry; import java.util.Properties; import com.sun.tools.attach.VirtualMachine; import com.sun.tools.attach.VirtualMachineDescriptor; class AttachTest { public static void main(String args[]) { List<VirtualMachineDescriptor> vms = VirtualMachine.list(); try { for(int i = 0; i < vms.size(); i++) { VirtualMachine vm = VirtualMachine.attach(vms.get(i)); if(vm != null) { Properties props = vm.getAgentProperties(); printProps("Attached VM '"+vm.id()+"' agent properties:\n", props); props = vm.getSystemProperties(); printProps("Attached VM '"+vm.id()+"' system properties:\n", props); } } } catch(Exception e) { e.printStackTrace(); } } static void printProps(String desc, Properties props) { System.out.println(desc); Entry<Object, Object> entry = null; for(Iterator<Entry<Object, Object>> it = props.entrySet().iterator(); it.hasNext();) { entry = it.next(); System.out.print("\t[key: "+entry.getKey()); System.out.println("][value: "+entry.getValue()+"]"); } } } Once we are connected to the virtual machine we can insert our own Java agent. The biggest problem is that so far I have not found a way to begin a debug session (using JDI / JDWP).
After spending quite a bit more time investigating the other launching connectors, the only ones of much interest are the two connectors: 1. SA Core Attaching Connector 2. SA Core Debug Server Attaching Connector some more information about these connectors can be found: http://www.oracle.com/technetwork/java/javase/tooldescr-136044.html#gbmnc I pushed a new branch with my test code: http://git.eclipse.org/c/jdt/eclipse.jdt.debug.git/commit/?h=mrennie/bug335896&id=535d7b50cddb871270ead6a06a4abde56afe9a35 that has the hooks for those two launching connectors. I found them to be very cool, such that you can have a read-only view of a core dump on either a local or remote machine *and* allows you to attach to a hung process (local or remote, given the process id). The problem with these two connectors (and the reason I am deferring any more work on this) is that they rely on RMI for communication. This prevents us from using our current JDI impl's for VirtualMachine, etc, because those are coded to rely on socket communication. Therefore the effort to support either of these (very cool) connectors is very large.