Search in sources :

Example 1 with GdbParseException

use of org.eclipse.che.plugin.gdb.server.exception.GdbParseException in project che by eclipse.

the class GdbDebugger method resume.

@Override
public void resume(ResumeAction action) throws DebuggerException {
    try {
        GdbContinue gdbContinue = gdb.cont();
        Breakpoint breakpoint = gdbContinue.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("Resume error. " + 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) GdbContinue(org.eclipse.che.plugin.gdb.server.parser.GdbContinue) GdbInfoProgram(org.eclipse.che.plugin.gdb.server.parser.GdbInfoProgram) 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 2 with GdbParseException

use of org.eclipse.che.plugin.gdb.server.exception.GdbParseException in project che by eclipse.

the class GdbDebugger method dumpStackFrame.

/**
     * Dump frame.
     */
@Override
public StackFrameDump dumpStackFrame() throws DebuggerException {
    try {
        Map<String, String> locals = gdb.infoLocals().getVariables();
        locals.putAll(gdb.infoArgs().getVariables());
        List<Variable> variables = new ArrayList<>(locals.size());
        for (Map.Entry<String, String> e : locals.entrySet()) {
            String varName = e.getKey();
            String varValue = e.getValue();
            String varType;
            try {
                varType = gdb.ptype(varName).getType();
            } catch (GdbParseException pe) {
                LOG.warn(pe.getMessage(), pe);
                varType = "";
            }
            VariablePath variablePath = new VariablePathImpl(singletonList(varName));
            VariableImpl variable = new VariableImpl(varType, varName, varValue, true, variablePath, Collections.emptyList(), true);
            variables.add(variable);
        }
        return new StackFrameDumpImpl(Collections.emptyList(), variables);
    } catch (GdbTerminatedException e) {
        disconnect();
        throw e;
    } catch (IOException | GdbParseException | InterruptedException e) {
        throw new DebuggerException("Can't dump stack frame. " + e.getMessage(), e);
    }
}
Also used : Variable(org.eclipse.che.api.debug.shared.model.Variable) VariablePathImpl(org.eclipse.che.api.debug.shared.model.impl.VariablePathImpl) DebuggerException(org.eclipse.che.api.debugger.server.exceptions.DebuggerException) ArrayList(java.util.ArrayList) IOException(java.io.IOException) StackFrameDumpImpl(org.eclipse.che.api.debug.shared.model.impl.StackFrameDumpImpl) VariablePath(org.eclipse.che.api.debug.shared.model.VariablePath) VariableImpl(org.eclipse.che.api.debug.shared.model.impl.VariableImpl) GdbTerminatedException(org.eclipse.che.plugin.gdb.server.exception.GdbTerminatedException) GdbParseException(org.eclipse.che.plugin.gdb.server.exception.GdbParseException) Map(java.util.Map)

Example 3 with GdbParseException

use of org.eclipse.che.plugin.gdb.server.exception.GdbParseException in project che by eclipse.

the class GdbDebugger method setValue.

@Override
public void setValue(Variable variable) throws DebuggerException {
    try {
        List<String> path = variable.getVariablePath().getPath();
        if (path.isEmpty()) {
            throw new DebuggerException("Variable path is empty");
        }
        gdb.setVar(path.get(0), variable.getValue());
    } catch (GdbTerminatedException e) {
        disconnect();
        throw e;
    } catch (IOException | GdbParseException | InterruptedException e) {
        throw new DebuggerException("Can't set value for " + variable.getName() + ". " + e.getMessage(), e);
    }
}
Also used : 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 4 with GdbParseException

use of org.eclipse.che.plugin.gdb.server.exception.GdbParseException 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 5 with GdbParseException

use of org.eclipse.che.plugin.gdb.server.exception.GdbParseException 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)

Aggregations

GdbParseException (org.eclipse.che.plugin.gdb.server.exception.GdbParseException)22 Matcher (java.util.regex.Matcher)13 DebuggerException (org.eclipse.che.api.debugger.server.exceptions.DebuggerException)10 IOException (java.io.IOException)9 GdbTerminatedException (org.eclipse.che.plugin.gdb.server.exception.GdbTerminatedException)9 SuspendEventImpl (org.eclipse.che.api.debug.shared.model.impl.event.SuspendEventImpl)5 GdbInfoLine (org.eclipse.che.plugin.gdb.server.parser.GdbInfoLine)3 Breakpoint (org.eclipse.che.api.debug.shared.model.Breakpoint)2 Location (org.eclipse.che.api.debug.shared.model.Location)2 LocationImpl (org.eclipse.che.api.debug.shared.model.impl.LocationImpl)2 GdbContinue (org.eclipse.che.plugin.gdb.server.parser.GdbContinue)2 GdbInfoProgram (org.eclipse.che.plugin.gdb.server.parser.GdbInfoProgram)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 Variable (org.eclipse.che.api.debug.shared.model.Variable)1 VariablePath (org.eclipse.che.api.debug.shared.model.VariablePath)1 SimpleValueImpl (org.eclipse.che.api.debug.shared.model.impl.SimpleValueImpl)1 StackFrameDumpImpl (org.eclipse.che.api.debug.shared.model.impl.StackFrameDumpImpl)1 VariableImpl (org.eclipse.che.api.debug.shared.model.impl.VariableImpl)1