Search in sources :

Example 1 with BreakpointActivatedEventImpl

use of org.eclipse.che.api.debug.shared.model.impl.event.BreakpointActivatedEventImpl in project che by eclipse.

the class NodeJsDebugger method addBreakpoint.

@Override
public void addBreakpoint(Breakpoint breakpoint) throws DebuggerException {
    try {
        Location location = breakpoint.getLocation();
        library.setBreakpoint(location.getTarget(), location.getLineNumber());
        debuggerCallback.onEvent(new BreakpointActivatedEventImpl(breakpoint));
    } catch (NodeJsDebuggerTerminatedException e) {
        disconnect();
        throw e;
    } catch (NodeJsDebuggerException e) {
        throw new DebuggerException("Can't add breakpoint: " + breakpoint + ". " + e.getMessage(), e);
    }
}
Also used : NodeJsDebuggerException(org.eclipse.che.plugin.nodejsdbg.server.exception.NodeJsDebuggerException) DebuggerException(org.eclipse.che.api.debugger.server.exceptions.DebuggerException) NodeJsDebuggerException(org.eclipse.che.plugin.nodejsdbg.server.exception.NodeJsDebuggerException) BreakpointActivatedEventImpl(org.eclipse.che.api.debug.shared.model.impl.event.BreakpointActivatedEventImpl) NodeJsDebuggerTerminatedException(org.eclipse.che.plugin.nodejsdbg.server.exception.NodeJsDebuggerTerminatedException) Location(org.eclipse.che.api.debug.shared.model.Location)

Example 2 with BreakpointActivatedEventImpl

use of org.eclipse.che.api.debug.shared.model.impl.event.BreakpointActivatedEventImpl in project che by eclipse.

the class JavaDebugger method addBreakpoint.

@Override
public void addBreakpoint(Breakpoint breakpoint) throws DebuggerException {
    final String className = findFQN(breakpoint);
    final int lineNumber = breakpoint.getLocation().getLineNumber();
    List<ReferenceType> classes = vm.classesByName(className);
    // it may mean that class doesn't loaded by a target JVM yet
    if (classes.isEmpty()) {
        deferBreakpoint(breakpoint);
        throw new DebuggerException("Class not loaded");
    }
    ReferenceType clazz = classes.get(0);
    List<com.sun.jdi.Location> locations;
    try {
        locations = clazz.locationsOfLine(lineNumber);
    } catch (AbsentInformationException | ClassNotPreparedException e) {
        throw new DebuggerException(e.getMessage(), e);
    }
    if (locations.isEmpty()) {
        throw new DebuggerException("Line " + lineNumber + " not found in class " + className);
    }
    com.sun.jdi.Location location = locations.get(0);
    if (location.method() == null) {
        // Line is out of method.
        throw new DebuggerException("Invalid line " + lineNumber + " in class " + className);
    }
    // Ignore new breakpoint if already have breakpoint at the same location.
    EventRequestManager requestManager = getEventManager();
    for (BreakpointRequest breakpointRequest : requestManager.breakpointRequests()) {
        if (location.equals(breakpointRequest.location())) {
            LOG.debug("Breakpoint at {} already set", location);
            return;
        }
    }
    try {
        EventRequest breakPointRequest = requestManager.createBreakpointRequest(location);
        breakPointRequest.setSuspendPolicy(EventRequest.SUSPEND_ALL);
        String expression = breakpoint.getCondition();
        if (!(expression == null || expression.isEmpty())) {
            ExpressionParser parser = ExpressionParser.newInstance(expression);
            breakPointRequest.putProperty("org.eclipse.che.ide.java.debug.condition.expression.parser", parser);
        }
        breakPointRequest.setEnabled(true);
    } catch (NativeMethodException | IllegalThreadStateException | InvalidRequestStateException e) {
        throw new DebuggerException(e.getMessage(), e);
    }
    debuggerCallback.onEvent(new BreakpointActivatedEventImpl(new BreakpointImpl(breakpoint.getLocation(), true, breakpoint.getCondition())));
    LOG.debug("Add breakpoint: {}", location);
}
Also used : NativeMethodException(com.sun.jdi.NativeMethodException) BreakpointImpl(org.eclipse.che.api.debug.shared.model.impl.BreakpointImpl) AbsentInformationException(com.sun.jdi.AbsentInformationException) DebuggerAbsentInformationException(org.eclipse.che.plugin.jdb.server.exceptions.DebuggerAbsentInformationException) DebuggerException(org.eclipse.che.api.debugger.server.exceptions.DebuggerException) BreakpointRequest(com.sun.jdi.request.BreakpointRequest) EventRequest(com.sun.jdi.request.EventRequest) ClassNotPreparedException(com.sun.jdi.ClassNotPreparedException) EventRequestManager(com.sun.jdi.request.EventRequestManager) Breakpoint(org.eclipse.che.api.debug.shared.model.Breakpoint) ReferenceType(com.sun.jdi.ReferenceType) BreakpointActivatedEventImpl(org.eclipse.che.api.debug.shared.model.impl.event.BreakpointActivatedEventImpl) ExpressionParser(org.eclipse.che.plugin.jdb.server.expression.ExpressionParser) InvalidRequestStateException(com.sun.jdi.request.InvalidRequestStateException) Location(org.eclipse.che.api.debug.shared.model.Location)

Example 3 with BreakpointActivatedEventImpl

use of org.eclipse.che.api.debug.shared.model.impl.event.BreakpointActivatedEventImpl in project che by eclipse.

the class ZendDebugger method sendAddBreakpoints.

private void sendAddBreakpoints(String remoteFilePath) {
    List<ZendDbgBreakpoint> fileBreakpoints = new ArrayList<>();
    for (ZendDbgBreakpoint dbgBreakpoint : breakpoints.values()) {
        if (dbgBreakpoint.getLocation().getResourcePath().equals(remoteFilePath)) {
            fileBreakpoints.add(dbgBreakpoint);
        }
    }
    for (ZendDbgBreakpoint dbgBreakpoint : fileBreakpoints) {
        AddBreakpointResponse response = debugConnection.sendRequest(new AddBreakpointRequest(1, 2, dbgBreakpoint.getLocation().getLineNumber(), remoteFilePath));
        if (isOK(response)) {
            // Breakpoint was successfully registered in active session, send breakpoint activated event
            breakpointIds.put(dbgBreakpoint, response.getBreakpointID());
            debugCallback.onEvent(new BreakpointActivatedEventImpl(dbgBreakpoint.getVfsBreakpoint()));
        }
    }
}
Also used : AddBreakpointRequest(org.eclipse.che.plugin.zdb.server.connection.ZendDbgClientMessages.AddBreakpointRequest) ArrayList(java.util.ArrayList) BreakpointActivatedEventImpl(org.eclipse.che.api.debug.shared.model.impl.event.BreakpointActivatedEventImpl) AddBreakpointResponse(org.eclipse.che.plugin.zdb.server.connection.ZendDbgEngineMessages.AddBreakpointResponse)

Example 4 with BreakpointActivatedEventImpl

use of org.eclipse.che.api.debug.shared.model.impl.event.BreakpointActivatedEventImpl in project che by eclipse.

the class ZendDebugger method sendAddBreakpoint.

private void sendAddBreakpoint(ZendDbgBreakpoint dbgBreakpoint) {
    AddBreakpointResponse response = debugConnection.sendRequest(new AddBreakpointRequest(1, 2, dbgBreakpoint.getLocation().getLineNumber(), dbgBreakpoint.getLocation().getResourcePath()));
    if (isOK(response)) {
        // Breakpoint was successfully registered in active session, send breakpoint activated event
        breakpointIds.put(dbgBreakpoint, response.getBreakpointID());
        debugCallback.onEvent(new BreakpointActivatedEventImpl(dbgBreakpoint.getVfsBreakpoint()));
    }
}
Also used : AddBreakpointRequest(org.eclipse.che.plugin.zdb.server.connection.ZendDbgClientMessages.AddBreakpointRequest) BreakpointActivatedEventImpl(org.eclipse.che.api.debug.shared.model.impl.event.BreakpointActivatedEventImpl) AddBreakpointResponse(org.eclipse.che.plugin.zdb.server.connection.ZendDbgEngineMessages.AddBreakpointResponse)

Example 5 with BreakpointActivatedEventImpl

use of org.eclipse.che.api.debug.shared.model.impl.event.BreakpointActivatedEventImpl in project che by eclipse.

the class GdbDebugger method addBreakpoint.

@Override
public void addBreakpoint(Breakpoint breakpoint) throws DebuggerException {
    try {
        Location location = breakpoint.getLocation();
        if (location.getTarget() == null) {
            gdb.breakpoint(location.getLineNumber());
        } else {
            gdb.breakpoint(location.getTarget(), location.getLineNumber());
        }
        debuggerCallback.onEvent(new BreakpointActivatedEventImpl(breakpoint));
    } catch (GdbTerminatedException e) {
        disconnect();
        throw e;
    } catch (IOException | GdbParseException | InterruptedException e) {
        throw new DebuggerException("Can't add breakpoint: " + breakpoint + ". " + e.getMessage(), e);
    }
}
Also used : DebuggerException(org.eclipse.che.api.debugger.server.exceptions.DebuggerException) BreakpointActivatedEventImpl(org.eclipse.che.api.debug.shared.model.impl.event.BreakpointActivatedEventImpl) GdbTerminatedException(org.eclipse.che.plugin.gdb.server.exception.GdbTerminatedException) IOException(java.io.IOException) GdbParseException(org.eclipse.che.plugin.gdb.server.exception.GdbParseException) Location(org.eclipse.che.api.debug.shared.model.Location)

Aggregations

BreakpointActivatedEventImpl (org.eclipse.che.api.debug.shared.model.impl.event.BreakpointActivatedEventImpl)6 Location (org.eclipse.che.api.debug.shared.model.Location)4 DebuggerException (org.eclipse.che.api.debugger.server.exceptions.DebuggerException)4 Breakpoint (org.eclipse.che.api.debug.shared.model.Breakpoint)2 NodeJsDebuggerException (org.eclipse.che.plugin.nodejsdbg.server.exception.NodeJsDebuggerException)2 NodeJsDebuggerTerminatedException (org.eclipse.che.plugin.nodejsdbg.server.exception.NodeJsDebuggerTerminatedException)2 AddBreakpointRequest (org.eclipse.che.plugin.zdb.server.connection.ZendDbgClientMessages.AddBreakpointRequest)2 AddBreakpointResponse (org.eclipse.che.plugin.zdb.server.connection.ZendDbgEngineMessages.AddBreakpointResponse)2 AbsentInformationException (com.sun.jdi.AbsentInformationException)1 ClassNotPreparedException (com.sun.jdi.ClassNotPreparedException)1 NativeMethodException (com.sun.jdi.NativeMethodException)1 ReferenceType (com.sun.jdi.ReferenceType)1 BreakpointRequest (com.sun.jdi.request.BreakpointRequest)1 EventRequest (com.sun.jdi.request.EventRequest)1 EventRequestManager (com.sun.jdi.request.EventRequestManager)1 InvalidRequestStateException (com.sun.jdi.request.InvalidRequestStateException)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 BreakpointImpl (org.eclipse.che.api.debug.shared.model.impl.BreakpointImpl)1 GdbParseException (org.eclipse.che.plugin.gdb.server.exception.GdbParseException)1