Search in sources :

Example 1 with Breakpoint

use of org.eclipse.che.api.debug.shared.model.Breakpoint 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 Breakpoint

use of org.eclipse.che.api.debug.shared.model.Breakpoint 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 3 with Breakpoint

use of org.eclipse.che.api.debug.shared.model.Breakpoint in project che by eclipse.

the class GdbTest method testBreakpoints.

@Test
public void testBreakpoints() throws Exception {
    gdb.file(file);
    gdb.breakpoint(7);
    gdb.clear(7);
    gdb.breakpoint("h.cpp", 8);
    gdb.clear("h.cpp", 8);
    gdb.breakpoint(7);
    gdb.breakpoint(8);
    GdbInfoBreak gdbInfoBreak = gdb.infoBreak();
    List<Breakpoint> breakpoints = gdbInfoBreak.getBreakpoints();
    assertEquals(breakpoints.size(), 2);
    gdb.delete();
    gdbInfoBreak = gdb.infoBreak();
    breakpoints = gdbInfoBreak.getBreakpoints();
    assertTrue(breakpoints.isEmpty());
}
Also used : Breakpoint(org.eclipse.che.api.debug.shared.model.Breakpoint) GdbInfoBreak(org.eclipse.che.plugin.gdb.server.parser.GdbInfoBreak) Test(org.testng.annotations.Test)

Example 4 with Breakpoint

use of org.eclipse.che.api.debug.shared.model.Breakpoint in project che by eclipse.

the class GdbInfoBreakTest method testParse.

@Test
public void testParse() throws Exception {
    GdbOutput gdbOutput = GdbOutput.of("Num     Type           Disp Enb Address            What\n" + "1       breakpoint     keep y   0x00000000004008ca in main() at h.cpp:7\n" + "2       breakpoint     keep y   0x00000000004008ca in main() at h.cpp:8\n");
    GdbInfoBreak gdbInfoBreak = GdbInfoBreak.parse(gdbOutput);
    List<Breakpoint> breakpoints = gdbInfoBreak.getBreakpoints();
    assertEquals(breakpoints.size(), 2);
    Breakpoint breakpoint = breakpoints.get(0);
    assertEquals(breakpoint.getLocation().getTarget(), "h.cpp");
    assertEquals(breakpoint.getLocation().getLineNumber(), 7);
    breakpoint = breakpoints.get(1);
    assertEquals(breakpoint.getLocation().getTarget(), "h.cpp");
    assertEquals(breakpoint.getLocation().getLineNumber(), 8);
}
Also used : Breakpoint(org.eclipse.che.api.debug.shared.model.Breakpoint) Test(org.testng.annotations.Test)

Example 5 with Breakpoint

use of org.eclipse.che.api.debug.shared.model.Breakpoint in project che by eclipse.

the class GdbRunTest method testParse.

@Test
public void testParse() throws Exception {
    GdbOutput gdbOutput = GdbOutput.of("Starting program: /home/tolusha/java/gdb/hello \n" + "0\n" + "\n" + "Breakpoint 1, main () at h.cpp:7\n" + "7\t\t  std::cout << \"Hello World!\" << std::endl;\n");
    GdbRun gdbRun = GdbRun.parse(gdbOutput);
    Breakpoint breakpoint = gdbRun.getBreakpoint();
    assertNotNull(breakpoint);
    assertEquals(breakpoint.getLocation().getTarget(), "h.cpp");
    assertEquals(breakpoint.getLocation().getLineNumber(), 7);
}
Also used : Breakpoint(org.eclipse.che.api.debug.shared.model.Breakpoint) Test(org.testng.annotations.Test)

Aggregations

Breakpoint (org.eclipse.che.api.debug.shared.model.Breakpoint)32 Test (org.testng.annotations.Test)14 BreakpointImpl (org.eclipse.che.api.debug.shared.model.impl.BreakpointImpl)13 ArrayList (java.util.ArrayList)11 Location (org.eclipse.che.api.debug.shared.model.Location)7 LocationImpl (org.eclipse.che.api.debug.shared.model.impl.LocationImpl)7 DebuggerException (org.eclipse.che.api.debugger.server.exceptions.DebuggerException)5 BreakpointActivatedEvent (org.eclipse.che.api.debug.shared.model.event.BreakpointActivatedEvent)4 BreakpointRequest (com.sun.jdi.request.BreakpointRequest)3 DebuggerEvent (org.eclipse.che.api.debug.shared.model.event.DebuggerEvent)3 GdbContinue (org.eclipse.che.plugin.gdb.server.parser.GdbContinue)3 ClassPrepareRequest (com.sun.jdi.request.ClassPrepareRequest)2 EventRequestManager (com.sun.jdi.request.EventRequestManager)2 IOException (java.io.IOException)2 StackFrameDump (org.eclipse.che.api.debug.shared.model.StackFrameDump)2 Variable (org.eclipse.che.api.debug.shared.model.Variable)2 VariableImpl (org.eclipse.che.api.debug.shared.model.impl.VariableImpl)2 VariablePathImpl (org.eclipse.che.api.debug.shared.model.impl.VariablePathImpl)2 ResumeActionImpl (org.eclipse.che.api.debug.shared.model.impl.action.ResumeActionImpl)2 BreakpointActivatedEventImpl (org.eclipse.che.api.debug.shared.model.impl.event.BreakpointActivatedEventImpl)2