Search in sources :

Example 16 with DebuggerException

use of org.eclipse.che.api.debugger.server.exceptions.DebuggerException in project che by eclipse.

the class JdiStackFrameImpl method getFields.

@Override
public JdiField[] getFields() throws DebuggerException {
    if (fields == null) {
        try {
            ObjectReference object = stackFrame.thisObject();
            if (object == null) {
                ReferenceType type = stackFrame.location().declaringType();
                List<Field> fs = stackFrame.location().declaringType().allFields();
                fields = new JdiField[fs.size()];
                int i = 0;
                for (Field f : fs) {
                    fields[i++] = new JdiFieldImpl(f, type);
                }
            } else {
                List<Field> fs = object.referenceType().allFields();
                fields = new JdiField[fs.size()];
                int i = 0;
                for (Field f : fs) {
                    fields[i++] = new JdiFieldImpl(f, object);
                }
            }
            Arrays.sort(fields);
        } catch (InvalidStackFrameException e) {
            throw new DebuggerException(e.getMessage(), e);
        }
    }
    return fields;
}
Also used : Field(com.sun.jdi.Field) ObjectReference(com.sun.jdi.ObjectReference) DebuggerException(org.eclipse.che.api.debugger.server.exceptions.DebuggerException) InvalidStackFrameException(com.sun.jdi.InvalidStackFrameException) ReferenceType(com.sun.jdi.ReferenceType)

Example 17 with DebuggerException

use of org.eclipse.che.api.debugger.server.exceptions.DebuggerException in project che by eclipse.

the class NodeJsDebugger method setValue.

@Override
public void setValue(Variable variable) throws DebuggerException {
    try {
        List<String> path = variable.getVariablePath().getPath();
        if (path.isEmpty()) {
            throw new DebuggerException("Variable path is empty");
        }
        library.setVar(path.get(0), variable.getValue());
    } catch (NodeJsDebuggerTerminatedException e) {
        disconnect();
        throw e;
    } catch (NodeJsDebuggerException e) {
        throw new DebuggerException("Can't set value for " + variable.getName() + ". " + e.getMessage(), e);
    }
}
Also used : DebuggerException(org.eclipse.che.api.debugger.server.exceptions.DebuggerException) NodeJsDebuggerException(org.eclipse.che.plugin.nodejsdbg.server.exception.NodeJsDebuggerException) NodeJsDebuggerException(org.eclipse.che.plugin.nodejsdbg.server.exception.NodeJsDebuggerException) NodeJsDebuggerTerminatedException(org.eclipse.che.plugin.nodejsdbg.server.exception.NodeJsDebuggerTerminatedException)

Example 18 with DebuggerException

use of org.eclipse.che.api.debugger.server.exceptions.DebuggerException in project che by eclipse.

the class NodeJsDebugger method addBreakpoint.

@Override
public void addBreakpoint(Breakpoint breakpoint) throws DebuggerException {
    try {
        Location location = breakpoint.getLocation();
        library.setBreakpoint(location.getTarget(), location.getLineNumber());
        debuggerCallback.onEvent(new BreakpointActivatedEventImpl(breakpoint));
    } catch (NodeJsDebuggerTerminatedException e) {
        disconnect();
        throw e;
    } catch (NodeJsDebuggerException e) {
        throw new DebuggerException("Can't add breakpoint: " + breakpoint + ". " + e.getMessage(), e);
    }
}
Also used : NodeJsDebuggerException(org.eclipse.che.plugin.nodejsdbg.server.exception.NodeJsDebuggerException) DebuggerException(org.eclipse.che.api.debugger.server.exceptions.DebuggerException) NodeJsDebuggerException(org.eclipse.che.plugin.nodejsdbg.server.exception.NodeJsDebuggerException) BreakpointActivatedEventImpl(org.eclipse.che.api.debug.shared.model.impl.event.BreakpointActivatedEventImpl) NodeJsDebuggerTerminatedException(org.eclipse.che.plugin.nodejsdbg.server.exception.NodeJsDebuggerTerminatedException) Location(org.eclipse.che.api.debug.shared.model.Location)

Example 19 with DebuggerException

use of org.eclipse.che.api.debugger.server.exceptions.DebuggerException in project che by eclipse.

the class NodeJsDebugger method start.

@Override
public void start(StartAction action) throws DebuggerException {
    try {
        for (Breakpoint breakpoint : action.getBreakpoints()) {
            Location location = breakpoint.getLocation();
            library.setBreakpoint(location.getTarget(), location.getLineNumber());
            debuggerCallback.onEvent(new BreakpointActivatedEventImpl(breakpoint));
        }
        library.backtrace();
    } catch (NodeJsDebuggerTerminatedException e) {
        disconnect();
        throw e;
    } catch (NodeJsDebuggerException e) {
        throw new DebuggerException("Start error. " + e.getMessage(), e);
    }
}
Also used : Breakpoint(org.eclipse.che.api.debug.shared.model.Breakpoint) NodeJsDebuggerException(org.eclipse.che.plugin.nodejsdbg.server.exception.NodeJsDebuggerException) DebuggerException(org.eclipse.che.api.debugger.server.exceptions.DebuggerException) NodeJsDebuggerException(org.eclipse.che.plugin.nodejsdbg.server.exception.NodeJsDebuggerException) BreakpointActivatedEventImpl(org.eclipse.che.api.debug.shared.model.impl.event.BreakpointActivatedEventImpl) NodeJsDebuggerTerminatedException(org.eclipse.che.plugin.nodejsdbg.server.exception.NodeJsDebuggerTerminatedException) Location(org.eclipse.che.api.debug.shared.model.Location)

Example 20 with DebuggerException

use of org.eclipse.che.api.debugger.server.exceptions.DebuggerException in project che by eclipse.

the class NodeJsDebuggerFactory method create.

@Override
public Debugger create(Map<String, String> properties, Debugger.DebuggerCallback debuggerCallback) throws DebuggerException {
    Map<String, String> normalizedProps = properties.entrySet().stream().collect(toMap(e -> e.getKey().toLowerCase(), Map.Entry::getValue));
    Integer pid = null;
    URI uri = null;
    String pidStr = normalizedProps.get("pid");
    if (!isNullOrEmpty(pidStr)) {
        try {
            pid = Integer.valueOf(pidStr);
        } catch (NumberFormatException e) {
            throw new DebuggerException(String.format("Illegal 'pid' format %s. Debugger can't be started.", pidStr));
        }
    }
    String uriStr = normalizedProps.get("uri");
    if (!isNullOrEmpty(uriStr)) {
        try {
            uri = URI.create(uriStr);
        } catch (IllegalArgumentException e) {
            throw new DebuggerException(String.format("Illegal 'uri' format %s. Debugger can't be started.", uriStr));
        }
    }
    String script = normalizedProps.get("script");
    if (!isNullOrEmpty(script) && !Files.exists(Paths.get(script))) {
        throw new DebuggerException(String.format("Script '%s' to debug not found. Debugger can't be started.", script));
    }
    if (isNullOrEmpty(pidStr) && isNullOrEmpty(uriStr) && isNullOrEmpty(script)) {
        throw new DebuggerException("Unrecognized debug connection options. Allowed only: pid, uri or script.");
    }
    return NodeJsDebugger.newInstance(pid, uri, script, debuggerCallback);
}
Also used : DebuggerException(org.eclipse.che.api.debugger.server.exceptions.DebuggerException) Collectors.toMap(java.util.stream.Collectors.toMap) Files(java.nio.file.Files) Paths(java.nio.file.Paths) Map(java.util.Map) Debugger(org.eclipse.che.api.debugger.server.Debugger) DebuggerFactory(org.eclipse.che.api.debugger.server.DebuggerFactory) Strings.isNullOrEmpty(com.google.common.base.Strings.isNullOrEmpty) URI(java.net.URI) DebuggerException(org.eclipse.che.api.debugger.server.exceptions.DebuggerException) Collectors.toMap(java.util.stream.Collectors.toMap) Map(java.util.Map) URI(java.net.URI)

Aggregations

DebuggerException (org.eclipse.che.api.debugger.server.exceptions.DebuggerException)31 IOException (java.io.IOException)13 GdbParseException (org.eclipse.che.plugin.gdb.server.exception.GdbParseException)10 GdbTerminatedException (org.eclipse.che.plugin.gdb.server.exception.GdbTerminatedException)10 SuspendEventImpl (org.eclipse.che.api.debug.shared.model.impl.event.SuspendEventImpl)7 Breakpoint (org.eclipse.che.api.debug.shared.model.Breakpoint)6 Location (org.eclipse.che.api.debug.shared.model.Location)6 Map (java.util.Map)5 Collectors.toMap (java.util.stream.Collectors.toMap)4 BreakpointActivatedEventImpl (org.eclipse.che.api.debug.shared.model.impl.event.BreakpointActivatedEventImpl)4 Debugger (org.eclipse.che.api.debugger.server.Debugger)4 DebuggerFactory (org.eclipse.che.api.debugger.server.DebuggerFactory)4 ArrayList (java.util.ArrayList)3 GdbInfoLine (org.eclipse.che.plugin.gdb.server.parser.GdbInfoLine)3 NodeJsDebuggerException (org.eclipse.che.plugin.nodejsdbg.server.exception.NodeJsDebuggerException)3 NodeJsDebuggerTerminatedException (org.eclipse.che.plugin.nodejsdbg.server.exception.NodeJsDebuggerTerminatedException)3 AbsentInformationException (com.sun.jdi.AbsentInformationException)2 InvalidStackFrameException (com.sun.jdi.InvalidStackFrameException)2 NativeMethodException (com.sun.jdi.NativeMethodException)2 ReferenceType (com.sun.jdi.ReferenceType)2