Search in sources :

Example 6 with DebuggerException

use of org.eclipse.che.api.debugger.server.exceptions.DebuggerException in project che by eclipse.

the class GdbDebugger method stepOut.

@Override
public void stepOut(StepOutAction action) throws DebuggerException {
    try {
        GdbInfoLine gdbInfoLine = gdb.finish();
        if (gdbInfoLine == null) {
            disconnect();
            return;
        }
        currentLocation = gdbInfoLine.getLocation();
        debuggerCallback.onEvent(new SuspendEventImpl(gdbInfoLine.getLocation()));
    } catch (GdbTerminatedException e) {
        disconnect();
        throw e;
    } catch (IOException | GdbParseException | InterruptedException e) {
        throw new DebuggerException("Step out error. " + e.getMessage(), e);
    }
}
Also used : SuspendEventImpl(org.eclipse.che.api.debug.shared.model.impl.event.SuspendEventImpl) GdbInfoLine(org.eclipse.che.plugin.gdb.server.parser.GdbInfoLine) DebuggerException(org.eclipse.che.api.debugger.server.exceptions.DebuggerException) GdbTerminatedException(org.eclipse.che.plugin.gdb.server.exception.GdbTerminatedException) IOException(java.io.IOException) GdbParseException(org.eclipse.che.plugin.gdb.server.exception.GdbParseException)

Example 7 with DebuggerException

use of org.eclipse.che.api.debugger.server.exceptions.DebuggerException in project che by eclipse.

the class GdbDebugger method start.

@Override
public void start(StartAction action) throws DebuggerException {
    try {
        for (Breakpoint b : action.getBreakpoints()) {
            try {
                addBreakpoint(b);
            } catch (DebuggerException e) {
            // can't add breakpoint, skip it
            }
        }
        Breakpoint breakpoint;
        if (isRemoteConnection()) {
            GdbContinue gdbContinue = gdb.cont();
            breakpoint = gdbContinue.getBreakpoint();
        } else {
            GdbRun gdbRun = gdb.run();
            breakpoint = gdbRun.getBreakpoint();
        }
        if (breakpoint != null) {
            currentLocation = breakpoint.getLocation();
            debuggerCallback.onEvent(new SuspendEventImpl(breakpoint.getLocation()));
        } else {
            GdbInfoProgram gdbInfoProgram = gdb.infoProgram();
            if (gdbInfoProgram.getStoppedAddress() == null) {
                disconnect();
            }
        }
    } catch (GdbTerminatedException e) {
        disconnect();
        throw e;
    } catch (IOException | GdbParseException | InterruptedException e) {
        throw new DebuggerException("Error during running. " + e.getMessage(), e);
    }
}
Also used : SuspendEventImpl(org.eclipse.che.api.debug.shared.model.impl.event.SuspendEventImpl) Breakpoint(org.eclipse.che.api.debug.shared.model.Breakpoint) GdbRun(org.eclipse.che.plugin.gdb.server.parser.GdbRun) DebuggerException(org.eclipse.che.api.debugger.server.exceptions.DebuggerException) GdbContinue(org.eclipse.che.plugin.gdb.server.parser.GdbContinue) GdbInfoProgram(org.eclipse.che.plugin.gdb.server.parser.GdbInfoProgram) GdbTerminatedException(org.eclipse.che.plugin.gdb.server.exception.GdbTerminatedException) IOException(java.io.IOException) GdbParseException(org.eclipse.che.plugin.gdb.server.exception.GdbParseException)

Example 8 with DebuggerException

use of org.eclipse.che.api.debugger.server.exceptions.DebuggerException in project che by eclipse.

the class GdbDebugger method stepInto.

@Override
public void stepInto(StepIntoAction action) throws DebuggerException {
    try {
        GdbInfoLine gdbInfoLine = gdb.step();
        if (gdbInfoLine == null) {
            disconnect();
            return;
        }
        currentLocation = gdbInfoLine.getLocation();
        debuggerCallback.onEvent(new SuspendEventImpl(gdbInfoLine.getLocation()));
    } catch (GdbTerminatedException e) {
        disconnect();
        throw e;
    } catch (IOException | GdbParseException | InterruptedException e) {
        throw new DebuggerException("Step into error. " + e.getMessage(), e);
    }
}
Also used : SuspendEventImpl(org.eclipse.che.api.debug.shared.model.impl.event.SuspendEventImpl) GdbInfoLine(org.eclipse.che.plugin.gdb.server.parser.GdbInfoLine) DebuggerException(org.eclipse.che.api.debugger.server.exceptions.DebuggerException) GdbTerminatedException(org.eclipse.che.plugin.gdb.server.exception.GdbTerminatedException) IOException(java.io.IOException) GdbParseException(org.eclipse.che.plugin.gdb.server.exception.GdbParseException)

Example 9 with DebuggerException

use of org.eclipse.che.api.debugger.server.exceptions.DebuggerException in project che by eclipse.

the class GdbDebugger method getValue.

@Override
public SimpleValue getValue(VariablePath variablePath) throws DebuggerException {
    try {
        List<String> path = variablePath.getPath();
        if (path.isEmpty()) {
            throw new DebuggerException("Variable path is empty");
        }
        GdbPrint gdbPrint = gdb.print(path.get(0));
        return new SimpleValueImpl(Collections.emptyList(), gdbPrint.getValue());
    } catch (GdbTerminatedException e) {
        disconnect();
        throw e;
    } catch (IOException | GdbParseException | InterruptedException e) {
        throw new DebuggerException("Can't get value for " + variablePath + ". " + e.getMessage(), e);
    }
}
Also used : GdbPrint(org.eclipse.che.plugin.gdb.server.parser.GdbPrint) SimpleValueImpl(org.eclipse.che.api.debug.shared.model.impl.SimpleValueImpl) DebuggerException(org.eclipse.che.api.debugger.server.exceptions.DebuggerException) GdbTerminatedException(org.eclipse.che.plugin.gdb.server.exception.GdbTerminatedException) IOException(java.io.IOException) GdbParseException(org.eclipse.che.plugin.gdb.server.exception.GdbParseException)

Example 10 with DebuggerException

use of org.eclipse.che.api.debugger.server.exceptions.DebuggerException in project che by eclipse.

the class ZendDbgFactory method create.

@Override
public Debugger create(Map<String, String> properties, Debugger.DebuggerCallback debuggerCallback) throws DebuggerException {
    Map<String, String> normalizedProps = properties.entrySet().stream().collect(toMap(e -> e.getKey().toLowerCase(), Map.Entry::getValue));
    String breakAtFirstLineProp = normalizedProps.get("break-at-first-line");
    if (breakAtFirstLineProp == null) {
        throw new DebuggerException("Can't establish connection: debug break at first line property is unknown.");
    }
    boolean breakAtFirstLine = Boolean.valueOf(breakAtFirstLineProp);
    String clientHostIPProp = normalizedProps.get("client-host-ip");
    if (clientHostIPProp == null) {
        throw new DebuggerException("Can't establish connection: client host/IP property is unknown.");
    }
    String debugPortProp = normalizedProps.get("debug-port");
    if (debugPortProp == null) {
        throw new DebuggerException("Can't establish connection: debug port property is unknown.");
    }
    int debugPort;
    try {
        debugPort = Integer.parseInt(debugPortProp);
    } catch (NumberFormatException e) {
        throw new DebuggerException("Unknown debug port property format: " + debugPortProp);
    }
    String useSslEncryptionProp = normalizedProps.get("use-ssl-encryption");
    if (useSslEncryptionProp == null) {
        throw new DebuggerException("Can't establish connection: debug use SSL encryption property is unknown.");
    }
    boolean useSslEncryption = Boolean.valueOf(useSslEncryptionProp);
    return new ZendDebugger(new ZendDbgSettings(debugPort, clientHostIPProp, breakAtFirstLine, useSslEncryption), new ZendDbgLocationHandler(), debuggerCallback);
}
Also used : DebuggerException(org.eclipse.che.api.debugger.server.exceptions.DebuggerException) Collectors.toMap(java.util.stream.Collectors.toMap) Map(java.util.Map) Debugger(org.eclipse.che.api.debugger.server.Debugger) DebuggerFactory(org.eclipse.che.api.debugger.server.DebuggerFactory) ZendDbgSettings(org.eclipse.che.plugin.zdb.server.connection.ZendDbgSettings) DebuggerException(org.eclipse.che.api.debugger.server.exceptions.DebuggerException) ZendDbgSettings(org.eclipse.che.plugin.zdb.server.connection.ZendDbgSettings) Collectors.toMap(java.util.stream.Collectors.toMap) Map(java.util.Map)

Aggregations

DebuggerException (org.eclipse.che.api.debugger.server.exceptions.DebuggerException)31 IOException (java.io.IOException)13 GdbParseException (org.eclipse.che.plugin.gdb.server.exception.GdbParseException)10 GdbTerminatedException (org.eclipse.che.plugin.gdb.server.exception.GdbTerminatedException)10 SuspendEventImpl (org.eclipse.che.api.debug.shared.model.impl.event.SuspendEventImpl)7 Breakpoint (org.eclipse.che.api.debug.shared.model.Breakpoint)6 Location (org.eclipse.che.api.debug.shared.model.Location)6 Map (java.util.Map)5 Collectors.toMap (java.util.stream.Collectors.toMap)4 BreakpointActivatedEventImpl (org.eclipse.che.api.debug.shared.model.impl.event.BreakpointActivatedEventImpl)4 Debugger (org.eclipse.che.api.debugger.server.Debugger)4 DebuggerFactory (org.eclipse.che.api.debugger.server.DebuggerFactory)4 ArrayList (java.util.ArrayList)3 GdbInfoLine (org.eclipse.che.plugin.gdb.server.parser.GdbInfoLine)3 NodeJsDebuggerException (org.eclipse.che.plugin.nodejsdbg.server.exception.NodeJsDebuggerException)3 NodeJsDebuggerTerminatedException (org.eclipse.che.plugin.nodejsdbg.server.exception.NodeJsDebuggerTerminatedException)3 AbsentInformationException (com.sun.jdi.AbsentInformationException)2 InvalidStackFrameException (com.sun.jdi.InvalidStackFrameException)2 NativeMethodException (com.sun.jdi.NativeMethodException)2 ReferenceType (com.sun.jdi.ReferenceType)2