Search in sources :

Example 26 with DebuggerException

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

the class JdiStackFrameImpl method getLocalVariables.

@Override
public JdiLocalVariable[] getLocalVariables() throws DebuggerException {
    if (localVariables == null) {
        try {
            List<LocalVariable> targetVariables = stackFrame.visibleVariables();
            localVariables = new JdiLocalVariable[targetVariables.size()];
            int i = 0;
            for (LocalVariable var : targetVariables) {
                localVariables[i++] = new JdiLocalVariableImpl(stackFrame, var);
            }
        } catch (AbsentInformationException e) {
            throw new DebuggerAbsentInformationException(e.getMessage(), e);
        } catch (InvalidStackFrameException | NativeMethodException e) {
            throw new DebuggerException(e.getMessage(), e);
        }
    }
    return localVariables;
}
Also used : NativeMethodException(com.sun.jdi.NativeMethodException) AbsentInformationException(com.sun.jdi.AbsentInformationException) DebuggerAbsentInformationException(org.eclipse.che.plugin.jdb.server.exceptions.DebuggerAbsentInformationException) DebuggerException(org.eclipse.che.api.debugger.server.exceptions.DebuggerException) LocalVariable(com.sun.jdi.LocalVariable) InvalidStackFrameException(com.sun.jdi.InvalidStackFrameException) DebuggerAbsentInformationException(org.eclipse.che.plugin.jdb.server.exceptions.DebuggerAbsentInformationException)

Example 27 with DebuggerException

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

the class JavaDebuggerUtils method getLocation.

/**
     * Returns Location for current debugger resource.
     *
     * @param location
     *         location type from JVM
     * @throws DebuggerException
     *         in case {@link org.eclipse.jdt.core.JavaModelException} or if Java {@link org.eclipse.jdt.core.IType}
     *         was not find
     */
public Location getLocation(com.sun.jdi.Location location) throws DebuggerException {
    String fqn = location.declaringType().name();
    List<IType> types;
    try {
        Pair<char[][], char[][]> fqnPair = prepareFqnToSearch(fqn);
        types = findTypeByFqn(fqnPair.first, fqnPair.second, createWorkspaceScope());
    } catch (JavaModelException e) {
        throw new DebuggerException("Can't find class models by fqn: " + fqn, e);
    }
    if (types.isEmpty()) {
        throw new DebuggerException("Type with fully qualified name: " + fqn + " was not found");
    }
    //TODO we need handle few result! It's temporary solution.
    IType type = types.get(0);
    String typeProjectPath = type.getJavaProject().getPath().toOSString();
    if (type.isBinary()) {
        IClassFile classFile = type.getClassFile();
        int libId = classFile.getAncestor(IPackageFragmentRoot.PACKAGE_FRAGMENT_ROOT).hashCode();
        return new LocationImpl(fqn, location.lineNumber(), null, true, libId, typeProjectPath);
    } else {
        ICompilationUnit compilationUnit = type.getCompilationUnit();
        typeProjectPath = type.getJavaProject().getPath().toOSString();
        String resourcePath = compilationUnit.getPath().toOSString();
        return new LocationImpl(fqn, location.lineNumber(), resourcePath, false, -1, typeProjectPath);
    }
}
Also used : ICompilationUnit(org.eclipse.jdt.core.ICompilationUnit) JavaModelException(org.eclipse.jdt.core.JavaModelException) IClassFile(org.eclipse.jdt.core.IClassFile) DebuggerException(org.eclipse.che.api.debugger.server.exceptions.DebuggerException) LocationImpl(org.eclipse.che.api.debug.shared.model.impl.LocationImpl) IType(org.eclipse.jdt.core.IType)

Example 28 with DebuggerException

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

the class GdbDebugger method addBreakpoint.

@Override
public void addBreakpoint(Breakpoint breakpoint) throws DebuggerException {
    try {
        Location location = breakpoint.getLocation();
        if (location.getTarget() == null) {
            gdb.breakpoint(location.getLineNumber());
        } else {
            gdb.breakpoint(location.getTarget(), location.getLineNumber());
        }
        debuggerCallback.onEvent(new BreakpointActivatedEventImpl(breakpoint));
    } catch (GdbTerminatedException e) {
        disconnect();
        throw e;
    } catch (IOException | GdbParseException | InterruptedException e) {
        throw new DebuggerException("Can't add breakpoint: " + breakpoint + ". " + e.getMessage(), e);
    }
}
Also used : DebuggerException(org.eclipse.che.api.debugger.server.exceptions.DebuggerException) BreakpointActivatedEventImpl(org.eclipse.che.api.debug.shared.model.impl.event.BreakpointActivatedEventImpl) GdbTerminatedException(org.eclipse.che.plugin.gdb.server.exception.GdbTerminatedException) IOException(java.io.IOException) GdbParseException(org.eclipse.che.plugin.gdb.server.exception.GdbParseException) Location(org.eclipse.che.api.debug.shared.model.Location)

Example 29 with DebuggerException

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

the class GdbDebugger method stepOver.

@Override
public void stepOver(StepOverAction action) throws DebuggerException {
    try {
        GdbInfoLine gdbInfoLine = gdb.next();
        if (gdbInfoLine == null) {
            disconnect();
            return;
        }
        currentLocation = gdbInfoLine.getLocation();
        debuggerCallback.onEvent(new SuspendEventImpl(gdbInfoLine.getLocation()));
    } catch (GdbTerminatedException e) {
        disconnect();
        throw e;
    } catch (IOException | GdbParseException | InterruptedException e) {
        throw new DebuggerException("Step into error. " + e.getMessage(), e);
    }
}
Also used : SuspendEventImpl(org.eclipse.che.api.debug.shared.model.impl.event.SuspendEventImpl) GdbInfoLine(org.eclipse.che.plugin.gdb.server.parser.GdbInfoLine) 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 30 with DebuggerException

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

the class GdbDebugger method suspend.

@Override
public void suspend() throws DebuggerException {
    try {
        currentLocation = gdb.suspend(file, isRemoteConnection());
        debuggerCallback.onEvent(new SuspendEventImpl(currentLocation));
    } catch (IOException | InterruptedException e) {
        throw new DebuggerException("Can not suspend debugger session. " + e.getMessage(), e);
    }
}
Also used : SuspendEventImpl(org.eclipse.che.api.debug.shared.model.impl.event.SuspendEventImpl) DebuggerException(org.eclipse.che.api.debugger.server.exceptions.DebuggerException) IOException(java.io.IOException)

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