Search in sources :

Example 16 with GdbParseException

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

the class GdbVersion method parse.

/**
     * Factory method.
     */
public static GdbVersion parse(GdbOutput gdbOutput) throws GdbParseException {
    String output = gdbOutput.getOutput();
    Matcher matcher = GDB_VERSION.matcher(output);
    if (matcher.find()) {
        String name = matcher.group(1);
        String version = matcher.group(2);
        return new GdbVersion(name, version);
    }
    throw new GdbParseException(GdbVersion.class, output);
}
Also used : Matcher(java.util.regex.Matcher) GdbParseException(org.eclipse.che.plugin.gdb.server.exception.GdbParseException)

Example 17 with GdbParseException

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

Example 18 with GdbParseException

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

the class GdbDebugger method stepOver.

@Override
public void stepOver(StepOverAction action) throws DebuggerException {
    try {
        GdbInfoLine gdbInfoLine = gdb.next();
        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 19 with GdbParseException

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

the class GdbBacktrace method parse.

/**
     * Factory method.
     */
public static GdbBacktrace parse(GdbOutput gdbOutput) throws GdbParseException {
    Matcher matcher;
    final String output = gdbOutput.getOutput();
    final String[] framesInfo = output.split("#");
    final Map<Integer, Location> frames = new HashMap<>(framesInfo.length);
    for (String frame : framesInfo) {
        try {
            matcher = GDB_FILE_LOCATION.matcher(frame);
            if (matcher.find()) {
                final String fileLocation = matcher.group(2);
                final int lineNumber = Integer.parseInt(matcher.group(3));
                final int frameNumber = Integer.parseInt(matcher.group(1));
                final Location location = new LocationImpl(fileLocation, lineNumber);
                frames.put(frameNumber, location);
                continue;
            }
            matcher = GDB_LIBRARY_LOCATION.matcher(frame);
            if (matcher.find()) {
                final int frameNumber = Integer.parseInt(matcher.group(1));
                final String libraryLocation = matcher.group(2);
                final Location location = new LocationImpl(libraryLocation);
                frames.put(frameNumber, location);
            }
        } catch (NumberFormatException e) {
        //we can't get info about current frame, but we are trying to get info about another frames
        }
    }
    if (!frames.isEmpty()) {
        return new GdbBacktrace(frames);
    }
    throw new GdbParseException(GdbBacktrace.class, output);
}
Also used : Matcher(java.util.regex.Matcher) HashMap(java.util.HashMap) LocationImpl(org.eclipse.che.api.debug.shared.model.impl.LocationImpl) GdbParseException(org.eclipse.che.plugin.gdb.server.exception.GdbParseException) Location(org.eclipse.che.api.debug.shared.model.Location)

Example 20 with GdbParseException

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

the class GdbFile method parse.

/**
     * Factory method.
     */
public static GdbFile parse(GdbOutput gdbOutput) throws GdbParseException {
    String output = gdbOutput.getOutput();
    Matcher matcher = GDB_FILE.matcher(output);
    if (matcher.find()) {
        String file = matcher.group(1);
        return new GdbFile(file);
    }
    throw new GdbParseException(GdbFile.class, output);
}
Also used : Matcher(java.util.regex.Matcher) 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