use of org.eclipse.che.api.debug.shared.model.VariablePath in project che by eclipse.
the class GdbDebugger method dumpStackFrame.
/**
* Dump frame.
*/
@Override
public StackFrameDump dumpStackFrame() throws DebuggerException {
try {
Map<String, String> locals = gdb.infoLocals().getVariables();
locals.putAll(gdb.infoArgs().getVariables());
List<Variable> variables = new ArrayList<>(locals.size());
for (Map.Entry<String, String> e : locals.entrySet()) {
String varName = e.getKey();
String varValue = e.getValue();
String varType;
try {
varType = gdb.ptype(varName).getType();
} catch (GdbParseException pe) {
LOG.warn(pe.getMessage(), pe);
varType = "";
}
VariablePath variablePath = new VariablePathImpl(singletonList(varName));
VariableImpl variable = new VariableImpl(varType, varName, varValue, true, variablePath, Collections.emptyList(), true);
variables.add(variable);
}
return new StackFrameDumpImpl(Collections.emptyList(), variables);
} catch (GdbTerminatedException e) {
disconnect();
throw e;
} catch (IOException | GdbParseException | InterruptedException e) {
throw new DebuggerException("Can't dump stack frame. " + e.getMessage(), e);
}
}
use of org.eclipse.che.api.debug.shared.model.VariablePath in project che by eclipse.
the class ZendDbgSessionTest method testGetValue.
@Test(groups = { "zendDbg" }, dependsOnGroups = { "checkPHP" })
public void testGetValue() throws Exception {
List<Breakpoint> breakpoints = new ArrayList<>();
Breakpoint bp1 = new BreakpointImpl(ZendDbgLocationHandler.createDBG(dbgClassesFile, 16));
breakpoints.add(bp1);
triggerSession(dbgHelloFile, getDbgSettings(false, false), breakpoints);
awaitBreakpointActivated(bp1);
awaitSuspend(dbgClassesFile, 16);
debugger.dumpStackFrame();
VariablePath variablePath = new VariablePathImpl("0");
SimpleValue simpleValue = debugger.getValue(variablePath);
assertEquals(simpleValue.getVariables().size(), 3);
List<String> path = Arrays.asList("0", "0");
variablePath = new VariablePathImpl(path);
simpleValue = debugger.getValue(variablePath);
assertEquals(simpleValue.getValue(), "\"A\"");
path = Arrays.asList("0", "1");
variablePath = new VariablePathImpl(path);
simpleValue = debugger.getValue(variablePath);
assertEquals(simpleValue.getValue(), "123");
path = Arrays.asList("0", "2");
variablePath = new VariablePathImpl(path);
simpleValue = debugger.getValue(variablePath);
assertEquals(simpleValue.getValue(), "array [3]");
}
use of org.eclipse.che.api.debug.shared.model.VariablePath in project che by eclipse.
the class DebuggerService method getValue.
@GET
@Path("{id}/value")
@Produces(MediaType.APPLICATION_JSON)
public SimpleValueDto getValue(@PathParam("id") String sessionId, @Context UriInfo uriInfo) throws DebuggerException {
List<String> path = new ArrayList<>();
MultivaluedMap<String, String> parameters = uriInfo.getQueryParameters();
int i = 0;
String item;
while ((item = parameters.getFirst("path" + (i++))) != null) {
path.add(item);
}
VariablePath variablePath = new VariablePathImpl(path);
return asDto(debuggerManager.getDebugger(sessionId).getValue(variablePath));
}
use of org.eclipse.che.api.debug.shared.model.VariablePath in project che by eclipse.
the class DebuggerTest method testChangeVariableValue.
@Test
public void testChangeVariableValue() throws Exception {
final List<String> path = mock(List.class);
final String newValue = "new-value";
VariablePath variablePath = mock(VariablePathDto.class);
doReturn(path).when(variablePath).getPath();
VariableDto variableDto = mock(VariableDto.class);
doReturn(variableDto).when(dtoFactory).createDto(VariableDto.class);
Variable variable = mock(Variable.class);
doReturn(mock(VariablePathDto.class)).when(dtoFactory).createDto(VariablePathDto.class);
doReturn(variablePath).when(variable).getVariablePath();
doReturn(newValue).when(variable).getValue();
doReturn(Collections.emptyList()).when(variable).getVariables();
doReturn(promiseVoid).when(service).setValue(SESSION_ID, variableDto);
doReturn(promiseVoid).when(promiseVoid).then((Operation<Void>) any());
debugger.setValue(variable);
verify(promiseVoid).then(operationVoidCaptor.capture());
operationVoidCaptor.getValue().apply(null);
verify(observer).onValueChanged(path, newValue);
verify(promiseVoid).catchError(operationPromiseErrorCaptor.capture());
operationPromiseErrorCaptor.getValue().apply(promiseError);
verify(promiseError).getMessage();
}
use of org.eclipse.che.api.debug.shared.model.VariablePath 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");
}
Aggregations