1 7 34 35 package com.sun.tools.example.debug.bdi; 36 37 import com.sun.jdi.VirtualMachine; 38 import com.sun.jdi.VMDisconnectedException; 39 import com.sun.jdi.event.EventSet; 40 41 45 class Session { 46 47 final VirtualMachine vm; 48 final ExecutionManager runtime; 49 final OutputListener diagnostics; 50 51 boolean running = true; boolean interrupted = false; 54 private JDIEventSource eventSourceThread = null; 55 private int traceFlags; 56 private boolean dead = false; 57 58 public Session(VirtualMachine vm, ExecutionManager runtime, 59 OutputListener diagnostics) { 60 this.vm = vm; 61 this.runtime = runtime; 62 this.diagnostics = diagnostics; 63 this.traceFlags = VirtualMachine.TRACE_NONE; 64 } 65 66 69 public boolean isInterrupted() { 70 return interrupted; 71 } 72 73 public void setTraceMode(int traceFlags) { 74 this.traceFlags = traceFlags; 75 if (!dead) { 76 vm.setDebugTraceMode(traceFlags); 77 } 78 } 79 80 public boolean attach() { 81 vm.setDebugTraceMode(traceFlags); 82 diagnostics.putString("Connected to VM"); 83 eventSourceThread = new JDIEventSource(this); 84 eventSourceThread.start(); 85 return true; 86 } 87 88 public void detach() { 89 if (!dead) { 90 eventSourceThread.interrupt(); 91 eventSourceThread = null; 92 try { 100 vm.dispose(); 101 } catch (VMDisconnectedException ee) {} 102 dead = true; 103 diagnostics.putString("Disconnected from VM"); 104 } 105 } 106 } 107 | Popular Tags |