Search in sources :

Example 1 with GdbInfoProgram

use of org.eclipse.che.plugin.gdb.server.parser.GdbInfoProgram in project che by eclipse.

the class Gdb method next.

/**
     * `next` command.
     */
@Nullable
public GdbInfoLine next() throws IOException, InterruptedException, DebuggerException {
    sendCommand("next");
    GdbInfoProgram gdbInfoProgram = infoProgram();
    if (gdbInfoProgram.getStoppedAddress() == null) {
        return null;
    }
    return infoLine();
}
Also used : GdbInfoProgram(org.eclipse.che.plugin.gdb.server.parser.GdbInfoProgram) Nullable(org.eclipse.che.commons.annotation.Nullable)

Example 2 with GdbInfoProgram

use of org.eclipse.che.plugin.gdb.server.parser.GdbInfoProgram 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 3 with GdbInfoProgram

use of org.eclipse.che.plugin.gdb.server.parser.GdbInfoProgram 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 4 with GdbInfoProgram

use of org.eclipse.che.plugin.gdb.server.parser.GdbInfoProgram in project che by eclipse.

the class GdbTest method testInfoProgram.

@Test
public void testInfoProgram() throws Exception {
    gdb.file(file);
    GdbInfoProgram gdbInfoProgram = gdb.infoProgram();
    assertNull(gdbInfoProgram.getStoppedAddress());
    gdb.breakpoint(4);
    gdb.run();
    gdbInfoProgram = gdb.infoProgram();
    assertNotNull(gdbInfoProgram.getStoppedAddress());
    GdbContinue gdbContinue = gdb.cont();
    assertNull(gdbContinue.getBreakpoint());
    gdbInfoProgram = gdb.infoProgram();
    assertNull(gdbInfoProgram.getStoppedAddress());
}
Also used : GdbInfoProgram(org.eclipse.che.plugin.gdb.server.parser.GdbInfoProgram) GdbContinue(org.eclipse.che.plugin.gdb.server.parser.GdbContinue) Test(org.testng.annotations.Test)

Aggregations

GdbInfoProgram (org.eclipse.che.plugin.gdb.server.parser.GdbInfoProgram)4 GdbContinue (org.eclipse.che.plugin.gdb.server.parser.GdbContinue)3 IOException (java.io.IOException)2 Breakpoint (org.eclipse.che.api.debug.shared.model.Breakpoint)2 SuspendEventImpl (org.eclipse.che.api.debug.shared.model.impl.event.SuspendEventImpl)2 DebuggerException (org.eclipse.che.api.debugger.server.exceptions.DebuggerException)2 GdbParseException (org.eclipse.che.plugin.gdb.server.exception.GdbParseException)2 GdbTerminatedException (org.eclipse.che.plugin.gdb.server.exception.GdbTerminatedException)2 Nullable (org.eclipse.che.commons.annotation.Nullable)1 GdbRun (org.eclipse.che.plugin.gdb.server.parser.GdbRun)1 Test (org.testng.annotations.Test)1