diff options
Diffstat (limited to 'development/org.eclipse.wst.jsdt.debug.chrome/src')
21 files changed, 363 insertions, 111 deletions
diff --git a/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/ChromePlugin.java b/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/ChromePlugin.java index d1eb3a0..e63d292 100644 --- a/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/ChromePlugin.java +++ b/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/ChromePlugin.java @@ -15,7 +15,7 @@ public class ChromePlugin extends Plugin { /** * Id of the bundle */ - public static final String PLUGIN_ID = "org.eclipse.wst.jsdt.debug.internal.chrome"; //$NON-NLS-1$ + public static final String PLUGIN_ID = "org.eclipse.wst.jsdt.debug.chrome"; //$NON-NLS-1$ /** * PacketImpl tracing option name */ @@ -89,7 +89,7 @@ public class ChromePlugin extends Plugin { * @param t throwable to log */ public static void log(Throwable t) { - log(newErrorStatus("Error logged from Crossfire Debug: ", t)); //$NON-NLS-1$ + log(newErrorStatus("Error logged from Google Chrome Debug: ", t)); //$NON-NLS-1$ } /** @@ -98,7 +98,7 @@ public class ChromePlugin extends Plugin { * @param message the error message to log */ public static void logErrorMessage(String message) { - log(newErrorStatus("Internal message logged from Crossfire Debug: " + message, null)); //$NON-NLS-1$ + log(newErrorStatus("Internal message logged from Google Chrome Debug: " + message, null)); //$NON-NLS-1$ } /** diff --git a/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/Tracing.java b/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/Tracing.java index 6d2e4ec..efe751a 100644 --- a/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/Tracing.java +++ b/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/Tracing.java @@ -27,7 +27,7 @@ public class Tracing { * @param string */ public static void writeString(String string) { - System.out.println(string.replaceAll(JSON.LINE_FEED, PRINTABLE_LINE_FEED)); + System.out.println("[CHROME] " +string.replaceAll(JSON.LINE_FEED, PRINTABLE_LINE_FEED)); //$NON-NLS-1$ } } diff --git a/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/connect/ChromeAttachingConnector.java b/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/connect/ChromeAttachingConnector.java index a7a3bf2..f3d7360 100644 --- a/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/connect/ChromeAttachingConnector.java +++ b/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/connect/ChromeAttachingConnector.java @@ -14,6 +14,7 @@ import java.io.IOException; import java.util.HashMap; import java.util.Map; +import org.eclipse.osgi.util.NLS; import org.eclipse.wst.jsdt.debug.core.jsdi.VirtualMachine; import org.eclipse.wst.jsdt.debug.core.jsdi.connect.AttachingConnector; import org.eclipse.wst.jsdt.debug.internal.chrome.ChromePlugin; @@ -46,6 +47,7 @@ public class ChromeAttachingConnector implements AttachingConnector { Map args = new HashMap(); args.put(HostArgument.HOST, new HostArgument(null)); args.put(PortArgument.PORT, new PortArgument(5000)); + args.put(TimeoutArgument.TIMEOUT, new TimeoutArgument()); args.put(BrowserArgument.BROWSER, new BrowserArgument()); return args; } @@ -76,41 +78,76 @@ public class ChromeAttachingConnector implements AttachingConnector { */ public VirtualMachine attach(Map arguments) throws IOException { String str = (String)arguments.get(BrowserArgument.BROWSER); - boolean browser = Boolean.valueOf(str).booleanValue(); - TransportService service = new ChromeTransportService(); - String host = (String) arguments.get(HostArgument.HOST); - String port = (String) arguments.get(PortArgument.PORT); - if(browser) { - launchBrowser(host, port); + Connection c = null; + if(Boolean.valueOf(str).booleanValue()) { + c = launchForBrowser(arguments); + } + else { + c = launch(arguments); } - Connection c = service.attach(host + ":" + Integer.parseInt(port), 10000, 10000); //$NON-NLS-1$ DebugSession session = new DebugSession(c); return new VMImpl(session); } /** - * Launch the browser on the given host / port - * @param host - * @param port + * Launches the browser and connects to it. This method will poll for the browser to be launched + * but only for a fixed timeout. + * @param arguments + * @return the created connection or <code>null</code> if the attempt to connect times out, the browser process + * terminates before we can connect * @throws IOException */ - void launchBrowser(final String host, final String port) throws IOException { - Thread thread = new Thread() { - public void run() { + Connection launchForBrowser(Map arguments) throws IOException { + TransportService service = new ChromeTransportService(); + String host = (String) arguments.get(HostArgument.HOST); + String port = (String) arguments.get(PortArgument.PORT); + StringBuffer buffer = new StringBuffer("/opt/google/chrome/chrome --remote-shell-port="); //$NON-NLS-1$ + buffer.append(port); + Process proc = null; + try { + proc = Runtime.getRuntime().exec(buffer.toString()); + } catch (IOException e) { + ChromePlugin.log(e); + } + String timeoutstr = (String) arguments.get(TimeoutArgument.TIMEOUT); + int timeout = Integer.parseInt(timeoutstr); + buffer = new StringBuffer(); + buffer.append(host).append(':').append(Integer.parseInt(port)); + Connection c = null; + long timer = System.currentTimeMillis() + 60000; + while(proc != null && System.currentTimeMillis() < timer && c == null) { + try { + c = service.attach(buffer.toString(), timeout, timeout); + } + catch(IOException ioe) { + //ignore while pinging to connect try { - Thread.sleep(1000); + Thread.sleep(200); } catch (InterruptedException e) { - ChromePlugin.log(e); - } - StringBuffer buffer = new StringBuffer("/opt/google/chrome/chrome --remote-shell-port= "); //$NON-NLS-1$ - buffer.append(port); - try { - Runtime.getRuntime().exec(buffer.toString()); - } catch (IOException e) { - ChromePlugin.log(e); + e.printStackTrace(); } - }; - }; - thread.start(); + } + } + if(c == null) { + throw new IOException(NLS.bind("Failed to attach to debugger at {0} on port {1}", new String[] {host, port})); //$NON-NLS-1$ + } + return c; + } + + /** + * Tries to connect to the given + * @param arguments + * @return the {@link Connection} or throws an exception + * @throws IOException + */ + Connection launch(Map arguments) throws IOException { + TransportService service = new ChromeTransportService(); + String host = (String) arguments.get(HostArgument.HOST); + String port = (String) arguments.get(PortArgument.PORT); + String timeoutstr = (String) arguments.get(TimeoutArgument.TIMEOUT); + int timeout = Integer.parseInt(timeoutstr); + StringBuffer buffer = new StringBuffer(); + buffer.append(host).append(':').append(Integer.parseInt(port)); + return service.attach(buffer.toString(), timeout, timeout); } } diff --git a/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/jsdi/VMImpl.java b/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/jsdi/VMImpl.java index a32df55..c6f854c 100644 --- a/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/jsdi/VMImpl.java +++ b/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/jsdi/VMImpl.java @@ -28,6 +28,8 @@ import org.eclipse.wst.jsdt.debug.core.jsdi.request.EventRequestManager; import org.eclipse.wst.jsdt.debug.internal.chrome.ChromePlugin; import org.eclipse.wst.jsdt.debug.internal.chrome.Tracing; import org.eclipse.wst.jsdt.debug.internal.chrome.event.EventQueueImpl; +import org.eclipse.wst.jsdt.debug.internal.chrome.request.EventReqManager; +import org.eclipse.wst.jsdt.debug.internal.chrome.transport.Attributes; import org.eclipse.wst.jsdt.debug.internal.chrome.transport.EventPacketImpl; import org.eclipse.wst.jsdt.debug.internal.chrome.transport.RequestPacketImpl; import org.eclipse.wst.jsdt.debug.internal.chrome.transport.Commands; @@ -65,7 +67,7 @@ public class VMImpl extends MirrorImpl implements VirtualMachine { */ private static UndefinedValue undefinedValue = null; - private EventRequestManager ermanager = null; + private EventRequestManager ermanager = new EventReqManager(this); private EventQueue queue = new EventQueueImpl(this, ermanager); private final DebugSession session; @@ -130,7 +132,7 @@ public class VMImpl extends MirrorImpl implements VirtualMachine { * @see org.eclipse.wst.jsdt.debug.core.jsdi.VirtualMachine#version() */ public String version() { - Request request = new RequestPacketImpl(Commands.VERSION); + RequestPacketImpl request = new RequestPacketImpl(Commands.VERSION, Attributes.TOOL_DEVTOOLSRVC); Response response = sendRequest(request); if(response != null && response.isSuccess()) { return (String) response.getBody().get(Commands.VERSION); @@ -251,10 +253,10 @@ public class VMImpl extends MirrorImpl implements VirtualMachine { } /** - * Receives an {@link CFEvent} from the underlying {@link DebugSession}, + * Receives an {@link EventPacket} from the underlying {@link DebugSession}, * waiting for the {@link VirtualMachine#DEFAULT_TIMEOUT}. * - * @return the next {@link CFEvent} never <code>null</code> + * @return the next {@link EventPacket} never <code>null</code> * @throws TimeoutException * @throws DisconnectedException */ @@ -263,10 +265,10 @@ public class VMImpl extends MirrorImpl implements VirtualMachine { } /** - * Receives an {@link CFEvent} from the underlying {@link DebugSession}, + * Receives an {@link EventPacket} from the underlying {@link DebugSession}, * waiting for the {@link VirtualMachine#DEFAULT_TIMEOUT}. * @param timeout - * @return the next {@link CFEvent} never <code>null</code> + * @return the next {@link EventPacket} never <code>null</code> * @throws TimeoutException * @throws DisconnectedException */ diff --git a/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/request/BreakpointReqImpl.java b/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/request/BreakpointReqImpl.java index d6948a7..39636b3 100644 --- a/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/request/BreakpointReqImpl.java +++ b/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/request/BreakpointReqImpl.java @@ -13,48 +13,84 @@ package org.eclipse.wst.jsdt.debug.internal.chrome.request; import org.eclipse.wst.jsdt.debug.core.jsdi.Location; import org.eclipse.wst.jsdt.debug.core.jsdi.ThreadReference; import org.eclipse.wst.jsdt.debug.core.jsdi.request.BreakpointRequest; +import org.eclipse.wst.jsdt.debug.internal.chrome.jsdi.VMImpl; /** - * + * {@link BreakpointRequest} impl + * + * @since 1.0 */ public class BreakpointReqImpl extends EventReqImpl implements BreakpointRequest { - /* (non-Javadoc) - * @see org.eclipse.wst.jsdt.debug.core.jsdi.request.EventRequest#isEnabled() + private Location location = null; + private ThreadReference thread = null; + private int hitcount = 0; + private String condition = null; + + /** + * Constructor + * + * @param vm + * @param location + * @param enabled */ - public boolean isEnabled() { - return false; - } - - /* (non-Javadoc) - * @see org.eclipse.wst.jsdt.debug.core.jsdi.request.EventRequest#setEnabled(boolean) - */ - public void setEnabled(boolean enabled) { + public BreakpointReqImpl(VMImpl vm, Location location, boolean enabled) { + super(vm, enabled); + this.location = location; } /* (non-Javadoc) * @see org.eclipse.wst.jsdt.debug.core.jsdi.Locatable#location() */ public Location location() { - return null; + return location; } /* (non-Javadoc) * @see org.eclipse.wst.jsdt.debug.core.jsdi.request.BreakpointRequest#addThreadFilter(org.eclipse.wst.jsdt.debug.core.jsdi.ThreadReference) */ public void addThreadFilter(ThreadReference thread) { + this.thread = thread; } + /** + * Returns the underlying {@link ThreadReference} this request applies to + * + * @return the underlying {@link ThreadReference} + */ + public synchronized ThreadReference thread() { + return this.thread; + } + /* (non-Javadoc) * @see org.eclipse.wst.jsdt.debug.core.jsdi.request.BreakpointRequest#addConditionFilter(java.lang.String) */ public void addConditionFilter(String condition) { + this.condition = condition; } + /** + * Returns the condition for this breakpoint + * + * @return the condition + */ + public synchronized String condition() { + return condition; + } + /* (non-Javadoc) * @see org.eclipse.wst.jsdt.debug.core.jsdi.request.BreakpointRequest#addHitCountFilter(int) */ public void addHitCountFilter(int hitcount) { + this.hitcount = hitcount; + } + + /** + * Returns the hit count for the breakpoint + * + * @return the hit count for the breakpoint + */ + public synchronized int hitcount() { + return this.hitcount; } - } diff --git a/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/request/DebuggerStatementReqImpl.java b/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/request/DebuggerStatementReqImpl.java index 7a97b77..430ad69 100644 --- a/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/request/DebuggerStatementReqImpl.java +++ b/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/request/DebuggerStatementReqImpl.java @@ -12,30 +12,40 @@ package org.eclipse.wst.jsdt.debug.internal.chrome.request; import org.eclipse.wst.jsdt.debug.core.jsdi.ThreadReference; import org.eclipse.wst.jsdt.debug.core.jsdi.request.DebuggerStatementRequest; +import org.eclipse.wst.jsdt.debug.internal.chrome.jsdi.VMImpl; /** - * + * {@link DebuggerStatementRequest} impl + * + * @since 1.0 */ -public class DebuggerStatementReqImpl extends EventReqImpl implements - DebuggerStatementRequest { +public class DebuggerStatementReqImpl extends EventReqImpl implements DebuggerStatementRequest { - /* (non-Javadoc) - * @see org.eclipse.wst.jsdt.debug.core.jsdi.request.EventRequest#isEnabled() + private ThreadReference thread = null; + + /** + * Constructor + * + * @param vm + * @param enabled */ - public boolean isEnabled() { - return false; - } - - /* (non-Javadoc) - * @see org.eclipse.wst.jsdt.debug.core.jsdi.request.EventRequest#setEnabled(boolean) - */ - public void setEnabled(boolean enabled) { + public DebuggerStatementReqImpl(VMImpl vm, boolean enabled) { + super(vm, enabled); } /* (non-Javadoc) * @see org.eclipse.wst.jsdt.debug.core.jsdi.request.DebuggerStatementRequest#addThreadFilter(org.eclipse.wst.jsdt.debug.core.jsdi.ThreadReference) */ public void addThreadFilter(ThreadReference thread) { + this.thread = thread; + } + + /** + * Returns the underlying {@link ThreadReference} this request applies to + * + * @return the underlying {@link ThreadReference} + */ + public synchronized ThreadReference thread() { + return this.thread; } - } diff --git a/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/request/EventReqImpl.java b/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/request/EventReqImpl.java index 6635e45..a753210 100644 --- a/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/request/EventReqImpl.java +++ b/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/request/EventReqImpl.java @@ -12,23 +12,39 @@ package org.eclipse.wst.jsdt.debug.internal.chrome.request; import org.eclipse.wst.jsdt.debug.core.jsdi.request.EventRequest; import org.eclipse.wst.jsdt.debug.internal.chrome.jsdi.MirrorImpl; +import org.eclipse.wst.jsdt.debug.internal.chrome.jsdi.VMImpl; /** - * + * Impl of {@link EventRequest} + * + * @since 1.0 */ public class EventReqImpl extends MirrorImpl implements EventRequest { + private boolean enabled = false; + + /** + * Constructor + * + * @param vm + * @param enabled + */ + public EventReqImpl(VMImpl vm, boolean enabled) { + super(vm); + this.enabled = enabled; + } + /* (non-Javadoc) * @see org.eclipse.wst.jsdt.debug.core.jsdi.request.EventRequest#isEnabled() */ public boolean isEnabled() { - return false; + return enabled; } /* (non-Javadoc) * @see org.eclipse.wst.jsdt.debug.core.jsdi.request.EventRequest#setEnabled(boolean) */ public void setEnabled(boolean enabled) { + this.enabled = enabled; } - } diff --git a/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/request/EventReqManager.java b/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/request/EventReqManager.java index bd27542..f534d0f 100644 --- a/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/request/EventReqManager.java +++ b/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/request/EventReqManager.java @@ -60,23 +60,25 @@ public class EventReqManager extends MirrorImpl implements EventRequestManager { */ public EventReqManager(VirtualMachine vm) { super(vm); - /*kind.put(CFBreakpointRequest.class, breakpoints); - kind.put(CFDebuggerRequest.class, debuggers); - kind.put(CFExceptionRequest.class, exceptions); - kind.put(CFScriptLoadRequest.class, loads); - kind.put(CFStepRequest.class, steps); - kind.put(CFSuspendRequest.class, suspends); - kind.put(CFThreadEnterRequest.class, threadenters); - kind.put(CFThreadExitRequest.class, threadexits); - kind.put(CFDisconnectRequest.class, disconnects); - kind.put(CFDeathRequest.class, deaths);*/ + kind.put(BreakpointReqImpl.class, breakpoints); + kind.put(DebuggerStatementReqImpl.class, debuggers); + kind.put(ExceptionReqImpl.class, exceptions); + kind.put(ScriptLoadReqImpl.class, loads); + kind.put(StepReqImpl.class, steps); + kind.put(SuspendReqImpl.class, suspends); + kind.put(ThreadEnterReqImpl.class, threadenters); + kind.put(ThreadExitReqImpl.class, threadexits); + kind.put(VMDisconnectReqImpl.class, disconnects); + kind.put(VMDeathReqImpl.class, deaths); } /* (non-Javadoc) * @see org.eclipse.wst.jsdt.debug.core.jsdi.request.EventRequestManager#createBreakpointRequest(org.eclipse.wst.jsdt.debug.core.jsdi.Location) */ public BreakpointRequest createBreakpointRequest(Location location) { - return null; + BreakpointReqImpl req = new BreakpointReqImpl(chromeVM(), location, true); + breakpoints.add(req); + return req; } /* (non-Javadoc) @@ -90,7 +92,9 @@ public class EventReqManager extends MirrorImpl implements EventRequestManager { * @see org.eclipse.wst.jsdt.debug.core.jsdi.request.EventRequestManager#createDebuggerStatementRequest() */ public DebuggerStatementRequest createDebuggerStatementRequest() { - return null; + DebuggerStatementReqImpl req = new DebuggerStatementReqImpl(chromeVM(), true); + debuggers.add(req); + return req; } /* (non-Javadoc) @@ -104,6 +108,8 @@ public class EventReqManager extends MirrorImpl implements EventRequestManager { * @see org.eclipse.wst.jsdt.debug.core.jsdi.request.EventRequestManager#createExceptionRequest() */ public ExceptionRequest createExceptionRequest() { + ExceptionReqImpl req = new ExceptionReqImpl(chromeVM(), true); + exceptions.add(req); return null; } @@ -118,7 +124,9 @@ public class EventReqManager extends MirrorImpl implements EventRequestManager { * @see org.eclipse.wst.jsdt.debug.core.jsdi.request.EventRequestManager#createScriptLoadRequest() */ public ScriptLoadRequest createScriptLoadRequest() { - return null; + ScriptLoadReqImpl req = new ScriptLoadReqImpl(chromeVM(), true); + loads.add(req); + return req; } /* (non-Javadoc) @@ -132,7 +140,9 @@ public class EventReqManager extends MirrorImpl implements EventRequestManager { * @see org.eclipse.wst.jsdt.debug.core.jsdi.request.EventRequestManager#createStepRequest(org.eclipse.wst.jsdt.debug.core.jsdi.ThreadReference, int) */ public StepRequest createStepRequest(ThreadReference thread, int step) { - return null; + StepReqImpl req = new StepReqImpl(chromeVM(), thread, step, true); + steps.add(req); + return req; } /* (non-Javadoc) @@ -146,7 +156,9 @@ public class EventReqManager extends MirrorImpl implements EventRequestManager { * @see org.eclipse.wst.jsdt.debug.core.jsdi.request.EventRequestManager#createSuspendRequest(org.eclipse.wst.jsdt.debug.core.jsdi.ThreadReference) */ public SuspendRequest createSuspendRequest(ThreadReference thread) { - return null; + SuspendReqImpl req = new SuspendReqImpl(chromeVM(), thread, true); + suspends.add(req); + return req; } /* (non-Javadoc) @@ -160,7 +172,9 @@ public class EventReqManager extends MirrorImpl implements EventRequestManager { * @see org.eclipse.wst.jsdt.debug.core.jsdi.request.EventRequestManager#createThreadEnterRequest() */ public ThreadEnterRequest createThreadEnterRequest() { - return null; + ThreadEnterReqImpl req = new ThreadEnterReqImpl(); + threadenters.add(req); + return req; } /* (non-Javadoc) @@ -174,7 +188,9 @@ public class EventReqManager extends MirrorImpl implements EventRequestManager { * @see org.eclipse.wst.jsdt.debug.core.jsdi.request.EventRequestManager#createThreadExitRequest() */ public ThreadExitRequest createThreadExitRequest() { - return null; + ThreadExitReqImpl req = new ThreadExitReqImpl(); + threadexits.add(req); + return req; } /* (non-Javadoc) @@ -208,7 +224,9 @@ public class EventReqManager extends MirrorImpl implements EventRequestManager { * @see org.eclipse.wst.jsdt.debug.core.jsdi.request.EventRequestManager#createVMDeathRequest() */ public VMDeathRequest createVMDeathRequest() { - return null; + VMDeathReqImpl req = new VMDeathReqImpl(); + deaths.add(req); + return req; } /* (non-Javadoc) @@ -222,7 +240,9 @@ public class EventReqManager extends MirrorImpl implements EventRequestManager { * @see org.eclipse.wst.jsdt.debug.core.jsdi.request.EventRequestManager#createVMDisconnectRequest() */ public VMDisconnectRequest createVMDisconnectRequest() { - return null; + VMDisconnectReqImpl req = new VMDisconnectReqImpl(); + disconnects.add(req); + return req; } /* (non-Javadoc) diff --git a/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/request/ExceptionReqImpl.java b/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/request/ExceptionReqImpl.java index d715326..d80f388 100644 --- a/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/request/ExceptionReqImpl.java +++ b/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/request/ExceptionReqImpl.java @@ -12,16 +12,40 @@ package org.eclipse.wst.jsdt.debug.internal.chrome.request; import org.eclipse.wst.jsdt.debug.core.jsdi.ThreadReference; import org.eclipse.wst.jsdt.debug.core.jsdi.request.ExceptionRequest; +import org.eclipse.wst.jsdt.debug.internal.chrome.jsdi.VMImpl; /** - * + * {@link ExceptionRequest} impl + * + * @since 1.0 */ public class ExceptionReqImpl extends EventReqImpl implements ExceptionRequest { + private ThreadReference thread = null; + + /** + * Constructor + * + * @param vm + * @param enabled + */ + public ExceptionReqImpl(VMImpl vm, boolean enabled) { + super(vm, enabled); + } + /* (non-Javadoc) * @see org.eclipse.wst.jsdt.debug.core.jsdi.request.ExceptionRequest#addThreadFilter(org.eclipse.wst.jsdt.debug.core.jsdi.ThreadReference) */ public void addThreadFilter(ThreadReference thread) { + this.thread = thread; } + /** + * Returns the underlying {@link ThreadReference} this request applies to + * + * @return the underlying {@link ThreadReference} + */ + public synchronized ThreadReference thread() { + return this.thread; + } } diff --git a/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/request/ScritpLoadReqImpl.java b/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/request/ScriptLoadReqImpl.java index 0b949e1..72871dd 100644 --- a/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/request/ScritpLoadReqImpl.java +++ b/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/request/ScriptLoadReqImpl.java @@ -11,11 +11,22 @@ package org.eclipse.wst.jsdt.debug.internal.chrome.request; import org.eclipse.wst.jsdt.debug.core.jsdi.request.ScriptLoadRequest; +import org.eclipse.wst.jsdt.debug.internal.chrome.jsdi.VMImpl; /** - * + * {@link ScriptLoadRequest} impl + * + * @since 1.0 */ -public class ScritpLoadReqImpl extends EventReqImpl implements - ScriptLoadRequest { +public class ScriptLoadReqImpl extends EventReqImpl implements ScriptLoadRequest { + + /** + * Constructor + * @param vm + * @param enabled + */ + public ScriptLoadReqImpl(VMImpl vm, boolean enabled) { + super(vm, enabled); + } } diff --git a/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/request/StepReqImpl.java b/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/request/StepReqImpl.java index 9864e7a..119f69b 100644 --- a/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/request/StepReqImpl.java +++ b/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/request/StepReqImpl.java @@ -12,24 +12,42 @@ package org.eclipse.wst.jsdt.debug.internal.chrome.request; import org.eclipse.wst.jsdt.debug.core.jsdi.ThreadReference; import org.eclipse.wst.jsdt.debug.core.jsdi.request.StepRequest; +import org.eclipse.wst.jsdt.debug.internal.chrome.jsdi.VMImpl; /** - * + * {@link StepRequest} impl + * + * @since 1.0 */ public class StepReqImpl extends EventReqImpl implements StepRequest { + private int stepkind = 0; + private ThreadReference thread = null; + + /** + * Constructor + * @param vm + * @param thread + * @param step + * @param enabled + */ + public StepReqImpl(VMImpl vm, ThreadReference thread, int step, boolean enabled) { + super(vm, enabled); + this.thread = thread; + this.stepkind = step; + } + /* (non-Javadoc) * @see org.eclipse.wst.jsdt.debug.core.jsdi.request.StepRequest#step() */ public int step() { - return 0; + return stepkind; } /* (non-Javadoc) * @see org.eclipse.wst.jsdt.debug.core.jsdi.request.StepRequest#thread() */ public ThreadReference thread() { - return null; + return thread; } - } diff --git a/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/request/SuspendReqImpl.java b/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/request/SuspendReqImpl.java index f2f14b4..5886faa 100644 --- a/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/request/SuspendReqImpl.java +++ b/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/request/SuspendReqImpl.java @@ -12,17 +12,32 @@ package org.eclipse.wst.jsdt.debug.internal.chrome.request; import org.eclipse.wst.jsdt.debug.core.jsdi.ThreadReference; import org.eclipse.wst.jsdt.debug.core.jsdi.request.SuspendRequest; +import org.eclipse.wst.jsdt.debug.internal.chrome.jsdi.VMImpl; /** - * + * {@link SuspendRequest} impl + * + * @since 1.0 */ public class SuspendReqImpl extends EventReqImpl implements SuspendRequest { + private ThreadReference thread = null; + + /** + * Constructor + * @param vm + * @param thread + * @param enabled + */ + public SuspendReqImpl(VMImpl vm, ThreadReference thread, boolean enabled) { + super(vm, enabled); + this.thread = thread; + } + /* (non-Javadoc) * @see org.eclipse.wst.jsdt.debug.core.jsdi.request.SuspendRequest#thread() */ public ThreadReference thread() { - return null; + return thread; } - } diff --git a/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/transport/Attributes.java b/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/transport/Attributes.java index 75126db..240b46a 100644 --- a/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/transport/Attributes.java +++ b/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/transport/Attributes.java @@ -18,6 +18,19 @@ package org.eclipse.wst.jsdt.debug.internal.chrome.transport; public interface Attributes { /** + * The name for the development tools service + * <br><br> + * Value is: <code>DevToolsService</code> + */ + public static final String TOOL_DEVTOOLSRVC = "DevToolsService"; //$NON-NLS-1$ + /** + * The name for the V8 debugger service + * <br><br> + * Value is: <code>V8Debugger</code> + */ + public static final String TOOL_V8DEBUGGER = "V8Debugger"; //$NON-NLS-1$ + + /** * The "arguments" attribute */ public static final String ARGUMENTS = "arguments"; //$NON-NLS-1$ @@ -158,6 +171,10 @@ public interface Attributes { */ public static final String THIS = "this"; //$NON-NLS-1$ /** + * the "tool" attribute + */ + public static final String TOOL = "tool"; //$NON-NLS-1$ + /** * The "type" attribute */ public static final String TYPE = "type"; //$NON-NLS-1$ diff --git a/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/transport/ChromeSocketConnection.java b/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/transport/ChromeSocketConnection.java index b7c7869..41cb177 100644 --- a/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/transport/ChromeSocketConnection.java +++ b/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/transport/ChromeSocketConnection.java @@ -45,7 +45,7 @@ public class ChromeSocketConnection extends SocketConnection { * @see org.eclipse.wst.jsdt.debug.transport.socket.SocketConnection#writePacket(org.eclipse.wst.jsdt.debug.transport.packet.Packet) */ public void writePacket(Packet packet) throws IOException { - String serialized = JSON.serialize(packet); + String serialized = JSON.serialize((PacketImpl) packet); if(PacketImpl.TRACE) { Tracing.writeString("WRITE PACKET: "+serialized); //$NON-NLS-1$ } @@ -116,6 +116,9 @@ public class ChromeSocketConnection extends SocketConnection { } r = c == '\r'; } + if(PacketImpl.TRACE) { + Tracing.writeString("READ HANDSHAKE: "+buffer.toString()); //$NON-NLS-1$ + } return buffer.toString().equals(HANDSHAKE); } diff --git a/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/transport/EventPacketImpl.java b/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/transport/EventPacketImpl.java index 64a2a74..94172d3 100644 --- a/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/transport/EventPacketImpl.java +++ b/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/transport/EventPacketImpl.java @@ -32,10 +32,12 @@ public class EventPacketImpl extends PacketImpl implements Event { /** * Constructor + * * @param event + * @param tool the name of the tools service that issued this event */ - public EventPacketImpl(String event) { - super(EVENT); + public EventPacketImpl(String event, String tool) { + super(EVENT, tool); if(event == null) { throw new IllegalArgumentException(Messages.cannot_create_packet_with_no_event); } diff --git a/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/transport/JSON.java b/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/transport/JSON.java index 515632c..e6f001b 100644 --- a/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/transport/JSON.java +++ b/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/transport/JSON.java @@ -24,7 +24,6 @@ import java.util.Map; import org.eclipse.wst.jsdt.debug.internal.chrome.Tracing; import org.eclipse.wst.jsdt.debug.internal.chrome.jsdi.NullImpl; import org.eclipse.wst.jsdt.debug.internal.chrome.jsdi.UndefinedImpl; -import org.eclipse.wst.jsdt.debug.transport.packet.Packet; /** * Class for reading / writing JSON objects @@ -55,6 +54,11 @@ public final class JSON { public static final String CONTENT_LENGTH = "Content-Length:"; //$NON-NLS-1$ /** + * The default <code>Tools:</code> pre-amble + */ + public static final String TOOL_HEADER = "Tool:"; //$NON-NLS-1$ + + /** * Enables / Disables tracing in the all of the JSDI implementations * * @param trace @@ -221,19 +225,31 @@ public final class JSON { } /** - * Serializes the given {@link CFPacket} to a {@link String} + * Writes the <code>Tool:name</code> pre-amble to the head of the given buffer + * + * @param buffer + * @param tool + */ + public static void writeToolHeader(StringBuffer buffer, String tool) { + StringBuffer buff = new StringBuffer(18); + buff.append(TOOL_HEADER).append(tool).append(LINE_FEED); + buffer.insert(0, buff); + } + + /** + * Serializes the given {@link PacketImpl} to a {@link String} * * @param packet the packet to serialize * * @return the serialized {@link String}, never <code>null</code> */ - public static String serialize(Packet packet) { + public static String serialize(PacketImpl packet) { Object json = packet.toJSON(); StringBuffer buffer = new StringBuffer(); writeValue(json, buffer); int length = buffer.length(); - buffer.append(LINE_FEED); writeContentLength(buffer, length); + writeToolHeader(buffer, packet.tool()); if(TRACE) { Tracing.writeString("SERIALIZE: " + packet.getType() +" packet as "+buffer.toString()); //$NON-NLS-1$ //$NON-NLS-2$ } diff --git a/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/transport/Messages.java b/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/transport/Messages.java index 1352db9..93ee74b 100644 --- a/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/transport/Messages.java +++ b/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/transport/Messages.java @@ -25,6 +25,8 @@ public class Messages extends NLS { public static String no_command_in_request_json; public static String no_event_found_in_json; public static String no_packet_type_in_json; + public static String no_tool_found_in_packet_json; + public static String packet_tools_service_name_cannot_be_null; public static String packet_type_cannot_be_null; static { // initialize resource bundle diff --git a/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/transport/PacketImpl.java b/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/transport/PacketImpl.java index 4853963..eb47938 100644 --- a/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/transport/PacketImpl.java +++ b/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/transport/PacketImpl.java @@ -27,18 +27,24 @@ public class PacketImpl implements Packet { */ public static boolean TRACE = false; - private String type = null; + private final String type; + private final String tool; /** * Constructor * - * @param type + * @param type the type of the packet + * @param tool the tools service expected to handle the packet */ - public PacketImpl(String type) { + public PacketImpl(String type, String tool) { if(type == null) { throw new IllegalArgumentException(Messages.packet_type_cannot_be_null); } + if(tool == null) { + throw new IllegalArgumentException(Messages.packet_tools_service_name_cannot_be_null); + } this.type = type; + this.tool = tool; } /** @@ -54,6 +60,10 @@ public class PacketImpl implements Packet { if(type == null) { throw new IllegalArgumentException(Messages.no_packet_type_in_json); } + tool = (String) json.get(Attributes.TOOL); + if(tool == null) { + throw new IllegalArgumentException(Messages.no_tool_found_in_packet_json); + } } /** @@ -64,6 +74,15 @@ public class PacketImpl implements Packet { TRACE = tracing; } + /** + * Returns the name of the tools service expected to handle this packet + * + * @return the tools service name + */ + public String tool() { + return tool; + } + /* (non-Javadoc) * @see org.eclipse.wst.jsdt.debug.transport.packet.Packet#getType() */ @@ -76,7 +95,7 @@ public class PacketImpl implements Packet { */ public Map toJSON() { Map json = new HashMap(); - json.put(Attributes.TYPE, type); + //json.put(Attributes.TYPE, type); return json; } diff --git a/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/transport/RequestPacketImpl.java b/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/transport/RequestPacketImpl.java index 5b2e8b3..7289a92 100644 --- a/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/transport/RequestPacketImpl.java +++ b/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/transport/RequestPacketImpl.java @@ -36,9 +36,10 @@ public class RequestPacketImpl extends PacketImpl implements Request { * Constructor * * @param command + * @param tool the name of the tools service expected to handle the request */ - public RequestPacketImpl(String command) { - super(REQUEST); + public RequestPacketImpl(String command, String tool) { + super(REQUEST, tool); if(command == null) { throw new IllegalArgumentException(Messages.cannot_create_request_null_command); } @@ -105,7 +106,7 @@ public class RequestPacketImpl extends PacketImpl implements Request { */ public Map toJSON() { Map json = super.toJSON(); - json.put(Attributes.SEQ, new Integer(seq)); + //json.put(Attributes.SEQ, new Integer(seq)); json.put(Attributes.COMMAND, command); if(!args.isEmpty()) { json.put(Attributes.ARGUMENTS, args); diff --git a/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/transport/ResponsePacketImpl.java b/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/transport/ResponsePacketImpl.java index daabdae..503eb62 100644 --- a/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/transport/ResponsePacketImpl.java +++ b/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/transport/ResponsePacketImpl.java @@ -37,9 +37,10 @@ public class ResponsePacketImpl extends PacketImpl implements Response { * Constructor * @param requestSequence * @param command + * @param tool the name of the tools service that issued this response */ - public ResponsePacketImpl(int requestSequence, String command) { - super(RESPONSE); + public ResponsePacketImpl(int requestSequence, String command, String tool) { + super(RESPONSE, tool); if(command == null) { throw new IllegalArgumentException(Messages.cannot_create_response_null_command); } diff --git a/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/transport/messages.properties b/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/transport/messages.properties index 6cd72e2..dc2d70f 100644 --- a/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/transport/messages.properties +++ b/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/transport/messages.properties @@ -6,4 +6,6 @@ no_command_in_json_response=There was no command found in the initializing JSON no_command_in_request_json=There was no command found in the initializing JSON map to create a request packet from no_event_found_in_json=There was no event found in the initializing JSON map to create an event packet from no_packet_type_in_json=There was no type found in the initializing JSON map to create a packet from +no_tool_found_in_packet_json=There was no tool found in the initializing JSON map to create a packet from +packet_tools_service_name_cannot_be_null=Packet tool service name cannot be null packet_type_cannot_be_null=The type of a packet cannot be null |