Search in sources :

Example 1 with StackFrameDump

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

the class JavaDebuggerTest method testSetAndGetValue.

@Test(priority = 11)
public void testSetAndGetValue() throws Exception {
    assertEquals(debugger.getValue(new VariablePathImpl("test")).getValue(), "\"hello\"");
    assertEquals(debugger.getValue(new VariablePathImpl("msg")).getValue(), "\"Hello, debugger!\"");
    debugger.setValue(new VariableImpl("\"new hello\"", (new VariablePathImpl("test"))));
    assertEquals(debugger.getValue(new VariablePathImpl("test")).getValue(), "\"new hello\"");
    StackFrameDump stackFrameDump = debugger.dumpStackFrame();
    Set<String> vars = stackFrameDump.getVariables().stream().map(Variable::getName).collect(Collectors.toSet());
    assertTrue(vars.contains("args"));
    assertTrue(vars.contains("msg"));
    assertTrue(vars.contains("test"));
}
Also used : VariableImpl(org.eclipse.che.api.debug.shared.model.impl.VariableImpl) VariablePathImpl(org.eclipse.che.api.debug.shared.model.impl.VariablePathImpl) StackFrameDump(org.eclipse.che.api.debug.shared.model.StackFrameDump) Test(org.testng.annotations.Test)

Example 2 with StackFrameDump

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

the class DebuggerPresenter method updateStackFrameDump.

private void updateStackFrameDump() {
    Debugger debugger = debuggerManager.getActiveDebugger();
    if (debugger != null && executionPoint != null) {
        Promise<StackFrameDump> promise = debugger.dumpStackFrame();
        promise.then(new Operation<StackFrameDump>() {

            @Override
            public void apply(StackFrameDump arg) throws OperationException {
                variables = new ArrayList<>();
                variables.addAll(arg.getFields());
                variables.addAll(arg.getVariables());
                view.setVariables(variables);
            }
        }).catchError(new Operation<PromiseError>() {

            @Override
            public void apply(PromiseError arg) throws OperationException {
                Log.error(DebuggerPresenter.class, arg.getCause());
            }
        });
    }
}
Also used : Debugger(org.eclipse.che.ide.debug.Debugger) PromiseError(org.eclipse.che.api.promises.client.PromiseError) StackFrameDump(org.eclipse.che.api.debug.shared.model.StackFrameDump) Operation(org.eclipse.che.api.promises.client.Operation) OperationException(org.eclipse.che.api.promises.client.OperationException)

Example 3 with StackFrameDump

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

the class DebuggerTest method testGetStackFrameDump.

@Test
public void testGetStackFrameDump() throws Exception {
    Promise<StackFrameDumpDto> promiseStackFrameDump = mock(Promise.class);
    StackFrameDumpDto mockStackFrameDumpDto = mock(StackFrameDumpDto.class);
    final String json = "json";
    doReturn(json).when(dtoFactory).toJson(mockStackFrameDumpDto);
    doReturn(promiseStackFrameDump).when(service).getStackFrameDump(SESSION_ID);
    doReturn(promiseStackFrameDump).when(promiseStackFrameDump).then((Function<StackFrameDumpDto, Object>) any());
    doReturn(promiseStackFrameDump).when(promiseStackFrameDump).catchError((Operation<PromiseError>) any());
    Promise<StackFrameDump> result = debugger.dumpStackFrame();
    assertEquals(promiseStackFrameDump, result);
}
Also used : StackFrameDumpDto(org.eclipse.che.api.debug.shared.dto.StackFrameDumpDto) PromiseError(org.eclipse.che.api.promises.client.PromiseError) StackFrameDump(org.eclipse.che.api.debug.shared.model.StackFrameDump) Matchers.anyString(org.mockito.Matchers.anyString) BaseTest(org.eclipse.che.plugin.debugger.ide.BaseTest) Test(org.junit.Test)

Example 4 with StackFrameDump

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

the class GdbDebuggerTest method doSetAndGetValues.

private void doSetAndGetValues() throws DebuggerException {
    VariablePath variablePath = new VariablePathImpl("i");
    Variable variable = new VariableImpl("int", "i", "2", true, variablePath, Collections.emptyList(), false);
    SimpleValue value = gdbDebugger.getValue(variablePath);
    assertEquals(value.getValue(), "0");
    gdbDebugger.setValue(variable);
    value = gdbDebugger.getValue(variablePath);
    assertEquals(value.getValue(), "2");
    String expression = gdbDebugger.evaluate("i");
    assertEquals(expression, "2");
    expression = gdbDebugger.evaluate("10 + 10");
    assertEquals(expression, "20");
    StackFrameDump stackFrameDump = gdbDebugger.dumpStackFrame();
    assertTrue(stackFrameDump.getFields().isEmpty());
    assertEquals(stackFrameDump.getVariables().size(), 1);
    assertEquals(stackFrameDump.getVariables().get(0).getName(), "i");
    assertEquals(stackFrameDump.getVariables().get(0).getValue(), "2");
    assertEquals(stackFrameDump.getVariables().get(0).getType(), "int");
}
Also used : VariablePath(org.eclipse.che.api.debug.shared.model.VariablePath) VariableImpl(org.eclipse.che.api.debug.shared.model.impl.VariableImpl) Variable(org.eclipse.che.api.debug.shared.model.Variable) VariablePathImpl(org.eclipse.che.api.debug.shared.model.impl.VariablePathImpl) StackFrameDump(org.eclipse.che.api.debug.shared.model.StackFrameDump) SimpleValue(org.eclipse.che.api.debug.shared.model.SimpleValue)

Example 5 with StackFrameDump

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

the class ZendDbgSessionTest method testVariables.

@Test(groups = { "zendDbg" }, dependsOnGroups = { "checkPHP" })
public void testVariables() throws Exception {
    List<Breakpoint> breakpoints = new ArrayList<>();
    Breakpoint bp1 = new BreakpointImpl(ZendDbgLocationHandler.createDBG(dbgClassesFile, 16));
    Breakpoint bp2 = new BreakpointImpl(ZendDbgLocationHandler.createDBG(dbgClassesFile, 25));
    breakpoints.add(bp1);
    breakpoints.add(bp2);
    triggerSession(dbgHelloFile, getDbgSettings(false, false), breakpoints);
    awaitBreakpointActivated(bp1);
    awaitBreakpointActivated(bp2);
    awaitSuspend(dbgClassesFile, 16);
    StackFrameDump stackFrameDump = debugger.dumpStackFrame();
    assertEquals(stackFrameDump.getVariables().size(), 1);
    assertEquals(stackFrameDump.getVariables().get(0).getName(), "$this");
    assertEquals(stackFrameDump.getVariables().get(0).getValue(), "A");
    assertEquals(stackFrameDump.getVariables().get(0).getType(), "object");
    debugger.resume(new ResumeActionImpl());
    awaitSuspend(dbgClassesFile, 25);
    stackFrameDump = debugger.dumpStackFrame();
    assertEquals(stackFrameDump.getVariables().size(), 3);
    assertEquals(stackFrameDump.getVariables().get(0).getName(), "$this");
    assertEquals(stackFrameDump.getVariables().get(0).getValue(), "B");
    assertEquals(stackFrameDump.getVariables().get(0).getType(), "object");
    assertEquals(stackFrameDump.getVariables().get(1).getName(), "$p");
    assertEquals(stackFrameDump.getVariables().get(1).getValue(), "123");
    assertEquals(stackFrameDump.getVariables().get(1).getType(), "int");
    assertEquals(stackFrameDump.getVariables().get(2).getName(), "$v");
    assertEquals(stackFrameDump.getVariables().get(2).getValue(), "\"B\"");
    assertEquals(stackFrameDump.getVariables().get(2).getType(), "string");
}
Also used : Breakpoint(org.eclipse.che.api.debug.shared.model.Breakpoint) BreakpointImpl(org.eclipse.che.api.debug.shared.model.impl.BreakpointImpl) ArrayList(java.util.ArrayList) StackFrameDump(org.eclipse.che.api.debug.shared.model.StackFrameDump) ResumeActionImpl(org.eclipse.che.api.debug.shared.model.impl.action.ResumeActionImpl) Test(org.testng.annotations.Test)

Aggregations

StackFrameDump (org.eclipse.che.api.debug.shared.model.StackFrameDump)6 VariableImpl (org.eclipse.che.api.debug.shared.model.impl.VariableImpl)3 VariablePathImpl (org.eclipse.che.api.debug.shared.model.impl.VariablePathImpl)3 Test (org.testng.annotations.Test)3 ArrayList (java.util.ArrayList)2 Breakpoint (org.eclipse.che.api.debug.shared.model.Breakpoint)2 Variable (org.eclipse.che.api.debug.shared.model.Variable)2 BreakpointImpl (org.eclipse.che.api.debug.shared.model.impl.BreakpointImpl)2 PromiseError (org.eclipse.che.api.promises.client.PromiseError)2 StackFrameDumpDto (org.eclipse.che.api.debug.shared.dto.StackFrameDumpDto)1 SimpleValue (org.eclipse.che.api.debug.shared.model.SimpleValue)1 VariablePath (org.eclipse.che.api.debug.shared.model.VariablePath)1 ResumeActionImpl (org.eclipse.che.api.debug.shared.model.impl.action.ResumeActionImpl)1 Operation (org.eclipse.che.api.promises.client.Operation)1 OperationException (org.eclipse.che.api.promises.client.OperationException)1 Debugger (org.eclipse.che.ide.debug.Debugger)1 BaseTest (org.eclipse.che.plugin.debugger.ide.BaseTest)1 Test (org.junit.Test)1 Matchers.anyString (org.mockito.Matchers.anyString)1