Search in sources :

Example 1 with StackFrameDumpImpl

use of org.eclipse.che.api.debug.shared.model.impl.StackFrameDumpImpl 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);
    }
}
Also used : Variable(org.eclipse.che.api.debug.shared.model.Variable) VariablePathImpl(org.eclipse.che.api.debug.shared.model.impl.VariablePathImpl) DebuggerException(org.eclipse.che.api.debugger.server.exceptions.DebuggerException) ArrayList(java.util.ArrayList) IOException(java.io.IOException) StackFrameDumpImpl(org.eclipse.che.api.debug.shared.model.impl.StackFrameDumpImpl) VariablePath(org.eclipse.che.api.debug.shared.model.VariablePath) VariableImpl(org.eclipse.che.api.debug.shared.model.impl.VariableImpl) GdbTerminatedException(org.eclipse.che.plugin.gdb.server.exception.GdbTerminatedException) GdbParseException(org.eclipse.che.plugin.gdb.server.exception.GdbParseException) Map(java.util.Map)

Aggregations

IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 Map (java.util.Map)1 Variable (org.eclipse.che.api.debug.shared.model.Variable)1 VariablePath (org.eclipse.che.api.debug.shared.model.VariablePath)1 StackFrameDumpImpl (org.eclipse.che.api.debug.shared.model.impl.StackFrameDumpImpl)1 VariableImpl (org.eclipse.che.api.debug.shared.model.impl.VariableImpl)1 VariablePathImpl (org.eclipse.che.api.debug.shared.model.impl.VariablePathImpl)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