Search in sources :

Example 1 with GdbPrint

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

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

the class GdbTest method testVariables.

@Test
public void testVariables() throws Exception {
    gdb.file(file);
    gdb.breakpoint(7);
    gdb.run();
    GdbPrint gdbPrint = gdb.print("i");
    assertEquals(gdbPrint.getValue(), "0");
    gdb.setVar("i", "1");
    gdbPrint = gdb.print("i");
    assertEquals(gdbPrint.getValue(), "1");
    GdbPType gdbPType = gdb.ptype("i");
    assertEquals(gdbPType.getType(), "int");
}
Also used : GdbPrint(org.eclipse.che.plugin.gdb.server.parser.GdbPrint) GdbPType(org.eclipse.che.plugin.gdb.server.parser.GdbPType) Test(org.testng.annotations.Test)

Aggregations

GdbPrint (org.eclipse.che.plugin.gdb.server.parser.GdbPrint)2 IOException (java.io.IOException)1 SimpleValueImpl (org.eclipse.che.api.debug.shared.model.impl.SimpleValueImpl)1 DebuggerException (org.eclipse.che.api.debugger.server.exceptions.DebuggerException)1 GdbParseException (org.eclipse.che.plugin.gdb.server.exception.GdbParseException)1 GdbTerminatedException (org.eclipse.che.plugin.gdb.server.exception.GdbTerminatedException)1 GdbPType (org.eclipse.che.plugin.gdb.server.parser.GdbPType)1 Test (org.testng.annotations.Test)1