Search in sources :

Example 21 with DebuggerException

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

the class GdbTargetRemote method parse.

/**
     * Factory method.
     */
public static GdbTargetRemote parse(GdbOutput gdbOutput) throws GdbParseException, DebuggerException {
    String output = gdbOutput.getOutput();
    Matcher matcher = GDB_TARGET_REMOTE.matcher(output);
    if (matcher.find()) {
        String host = matcher.group(1);
        String port = matcher.group(2);
        return new GdbTargetRemote(host, port);
    } else if (CONNECTION_TIMED_OUT.matcher(output).find()) {
        throw new DebuggerException(output);
    }
    throw new GdbParseException(GdbTargetRemote.class, output);
}
Also used : Matcher(java.util.regex.Matcher) DebuggerException(org.eclipse.che.api.debugger.server.exceptions.DebuggerException) GdbParseException(org.eclipse.che.plugin.gdb.server.exception.GdbParseException)

Example 22 with DebuggerException

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

the class GdbDebuggerTest method stepOut.

private void stepOut() throws DebuggerException, InterruptedException {
    try {
        gdbDebugger.stepOut(new StepOutActionImpl());
    } catch (DebuggerException e) {
    // ignore
    }
    DebuggerEvent debuggerEvent = events.take();
    assertTrue(debuggerEvent instanceof SuspendEvent);
}
Also used : SuspendEvent(org.eclipse.che.api.debug.shared.model.event.SuspendEvent) DebuggerException(org.eclipse.che.api.debugger.server.exceptions.DebuggerException) StepOutActionImpl(org.eclipse.che.api.debug.shared.model.impl.action.StepOutActionImpl) DebuggerEvent(org.eclipse.che.api.debug.shared.model.event.DebuggerEvent)

Example 23 with DebuggerException

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

the class JavaDebugger method evaluate.

private com.sun.jdi.Value evaluate(ExpressionParser parser) throws DebuggerException {
    final long startTime = System.currentTimeMillis();
    try {
        return parser.evaluate(new Evaluator(vm, getCurrentThread()));
    } catch (ExpressionException e) {
        throw new DebuggerException(e.getMessage(), e);
    } finally {
        final long endTime = System.currentTimeMillis();
        LOG.debug("==>> Evaluate time: {} ms", (endTime - startTime));
        // Evaluation of expression may update state of frame.
        invalidateCurrentFrame();
    }
}
Also used : DebuggerException(org.eclipse.che.api.debugger.server.exceptions.DebuggerException) Evaluator(org.eclipse.che.plugin.jdb.server.expression.Evaluator) ExpressionException(org.eclipse.che.plugin.jdb.server.expression.ExpressionException)

Example 24 with DebuggerException

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

the class JavaDebugger method processBreakPointEvent.

private boolean processBreakPointEvent(com.sun.jdi.event.BreakpointEvent event) throws DebuggerException {
    setCurrentThread(event.thread());
    boolean hitBreakpoint;
    ExpressionParser parser = (ExpressionParser) event.request().getProperty("org.eclipse.che.ide.java.debug.condition.expression.parser");
    if (parser != null) {
        com.sun.jdi.Value result = evaluate(parser);
        hitBreakpoint = result instanceof com.sun.jdi.BooleanValue && ((com.sun.jdi.BooleanValue) result).value();
    } else {
        // If there is no expression.
        hitBreakpoint = true;
    }
    if (hitBreakpoint) {
        com.sun.jdi.Location jdiLocation = event.location();
        Location location;
        try {
            location = debuggerUtil.getLocation(jdiLocation);
        } catch (DebuggerException e) {
            location = new LocationImpl(jdiLocation.declaringType().name(), jdiLocation.lineNumber());
        }
        debuggerCallback.onEvent(new SuspendEventImpl(location));
    }
    // or if condition expression is not set.
    return !hitBreakpoint;
}
Also used : SuspendEventImpl(org.eclipse.che.api.debug.shared.model.impl.event.SuspendEventImpl) DebuggerException(org.eclipse.che.api.debugger.server.exceptions.DebuggerException) LocationImpl(org.eclipse.che.api.debug.shared.model.impl.LocationImpl) ExpressionParser(org.eclipse.che.plugin.jdb.server.expression.ExpressionParser) Location(org.eclipse.che.api.debug.shared.model.Location)

Example 25 with DebuggerException

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

the class JavaDebugger method getAllBreakpoints.

@Override
public List<Breakpoint> getAllBreakpoints() throws DebuggerException {
    List<BreakpointRequest> breakpointRequests;
    try {
        breakpointRequests = getEventManager().breakpointRequests();
    } catch (DebuggerException e) {
        Throwable cause = e.getCause();
        if (cause instanceof VMCannotBeModifiedException) {
            // If target VM in read-only state then list of break point always empty.
            return Collections.emptyList();
        }
        throw e;
    }
    List<Breakpoint> breakPoints = new ArrayList<>(breakpointRequests.size());
    for (BreakpointRequest breakpointRequest : breakpointRequests) {
        com.sun.jdi.Location location = breakpointRequest.location();
        // Breakpoint always enabled at the moment. Managing states of breakpoint is not supported for now.
        breakPoints.add(newDto(BreakpointDto.class).withEnabled(true).withLocation(newDto(LocationDto.class).withTarget(location.declaringType().name()).withLineNumber(location.lineNumber())));
    }
    Collections.sort(breakPoints, BREAKPOINT_COMPARATOR);
    return breakPoints;
}
Also used : Breakpoint(org.eclipse.che.api.debug.shared.model.Breakpoint) DebuggerException(org.eclipse.che.api.debugger.server.exceptions.DebuggerException) BreakpointRequest(com.sun.jdi.request.BreakpointRequest) ArrayList(java.util.ArrayList) VMCannotBeModifiedException(com.sun.jdi.VMCannotBeModifiedException) BreakpointDto(org.eclipse.che.api.debug.shared.dto.BreakpointDto)

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