Search in sources :

Example 1 with ExceptionEvent

use of com.sun.jdi.event.ExceptionEvent in project intellij-community by JetBrains.

the class JavaStackFrame method buildVariablesThreadAction.

// copied from DebuggerTree
private void buildVariablesThreadAction(DebuggerContextImpl debuggerContext, XValueChildrenList children, XCompositeNode node) {
    try {
        final EvaluationContextImpl evaluationContext = debuggerContext.createEvaluationContext();
        if (evaluationContext == null) {
            return;
        }
        if (!debuggerContext.isEvaluationPossible()) {
            node.setErrorMessage(MessageDescriptor.EVALUATION_NOT_POSSIBLE.getLabel());
        //myChildren.add(myNodeManager.createNode(MessageDescriptor.EVALUATION_NOT_POSSIBLE, evaluationContext));
        }
        final Location location = myDescriptor.getLocation();
        final ObjectReference thisObjectReference = myDescriptor.getThisObject();
        if (thisObjectReference != null) {
            ValueDescriptorImpl thisDescriptor = myNodeManager.getThisDescriptor(null, thisObjectReference);
            children.add(JavaValue.create(thisDescriptor, evaluationContext, myNodeManager));
        } else if (location != null) {
            StaticDescriptorImpl staticDecriptor = myNodeManager.getStaticDescriptor(myDescriptor, location.declaringType());
            if (staticDecriptor.isExpandable()) {
                children.addTopGroup(new JavaStaticGroup(staticDecriptor, evaluationContext, myNodeManager));
            }
        }
        DebugProcessImpl debugProcess = debuggerContext.getDebugProcess();
        if (debugProcess == null) {
            return;
        }
        // add last method return value if any
        final Pair<Method, Value> methodValuePair = debugProcess.getLastExecutedMethod();
        if (methodValuePair != null && myDescriptor.getUiIndex() == 0) {
            ValueDescriptorImpl returnValueDescriptor = myNodeManager.getMethodReturnValueDescriptor(myDescriptor, methodValuePair.getFirst(), methodValuePair.getSecond());
            children.add(JavaValue.create(returnValueDescriptor, evaluationContext, myNodeManager));
        }
        // add context exceptions
        Set<ObjectReference> exceptions = new HashSet<>();
        for (Pair<Breakpoint, Event> pair : DebuggerUtilsEx.getEventDescriptors(debuggerContext.getSuspendContext())) {
            Event debugEvent = pair.getSecond();
            if (debugEvent instanceof ExceptionEvent) {
                ObjectReference exception = ((ExceptionEvent) debugEvent).exception();
                if (exception != null) {
                    exceptions.add(exception);
                }
            }
        }
        exceptions.forEach(e -> children.add(JavaValue.create(myNodeManager.getThrownExceptionObjectDescriptor(myDescriptor, e), evaluationContext, myNodeManager)));
        try {
            buildVariables(debuggerContext, evaluationContext, debugProcess, children, thisObjectReference, location);
        //if (classRenderer.SORT_ASCENDING) {
        //  Collections.sort(myChildren, NodeManagerImpl.getNodeComparator());
        //}
        } catch (EvaluateException e) {
            node.setErrorMessage(e.getMessage());
        //myChildren.add(myNodeManager.createMessageNode(new MessageDescriptor(e.getMessage())));
        }
    } catch (InvalidStackFrameException e) {
        LOG.info(e);
    //myChildren.clear();
    //notifyCancelled();
    } catch (InternalException e) {
        if (e.errorCode() == 35) {
            node.setErrorMessage(DebuggerBundle.message("error.corrupt.debug.info", e.getMessage()));
        //myChildren.add(
        //  myNodeManager.createMessageNode(new MessageDescriptor(DebuggerBundle.message("error.corrupt.debug.info", e.getMessage()))));
        } else {
            throw e;
        }
    }
}
Also used : ExceptionEvent(com.sun.jdi.event.ExceptionEvent) Breakpoint(com.intellij.debugger.ui.breakpoints.Breakpoint) EvaluateException(com.intellij.debugger.engine.evaluation.EvaluateException) EvaluationContextImpl(com.intellij.debugger.engine.evaluation.EvaluationContextImpl) Event(com.sun.jdi.event.Event) ExceptionEvent(com.sun.jdi.event.ExceptionEvent)

Example 2 with ExceptionEvent

use of com.sun.jdi.event.ExceptionEvent in project gravel by gravel-st.

the class VMRemoteTarget method eventLoop.

private void eventLoop() throws InterruptedException {
    System.out.println("eventLoop started");
    EventQueue eventQueue = vm.eventQueue();
    boolean isRunning = true;
    while (isRunning) {
        EventSet eventSet = eventQueue.remove();
        boolean mayResume = true;
        for (Event event : eventSet) {
            System.out.println(event);
            if (event instanceof VMDeathEvent || event instanceof VMDisconnectEvent) {
                isRunning = false;
            } else if (event instanceof ExceptionEvent) {
                mayResume = false;
            }
        }
        if (mayResume)
            eventSet.resume();
    }
}
Also used : ExceptionEvent(com.sun.jdi.event.ExceptionEvent) VMDisconnectEvent(com.sun.jdi.event.VMDisconnectEvent) VMDeathEvent(com.sun.jdi.event.VMDeathEvent) EventSet(com.sun.jdi.event.EventSet) Event(com.sun.jdi.event.Event) VMDisconnectEvent(com.sun.jdi.event.VMDisconnectEvent) VMDeathEvent(com.sun.jdi.event.VMDeathEvent) ExceptionEvent(com.sun.jdi.event.ExceptionEvent) EventQueue(com.sun.jdi.event.EventQueue)

Example 3 with ExceptionEvent

use of com.sun.jdi.event.ExceptionEvent in project intellij-community by JetBrains.

the class ExceptionBreakpoint method getEventMessage.

public String getEventMessage(LocatableEvent event) {
    String exceptionName = (getQualifiedName() != null) ? getQualifiedName() : CommonClassNames.JAVA_LANG_THROWABLE;
    String threadName = null;
    if (event instanceof ExceptionEvent) {
        ExceptionEvent exceptionEvent = (ExceptionEvent) event;
        try {
            exceptionName = exceptionEvent.exception().type().name();
            threadName = exceptionEvent.thread().name();
        } catch (Exception ignore) {
        }
    }
    final Location location = event.location();
    final String locationQName = DebuggerUtilsEx.getLocationMethodQName(location);
    String locationFileName;
    try {
        locationFileName = location.sourceName();
    } catch (AbsentInformationException e) {
        locationFileName = "";
    }
    final int locationLine = Math.max(0, location.lineNumber());
    if (threadName != null) {
        return DebuggerBundle.message("exception.breakpoint.console.message.with.thread.info", exceptionName, threadName, locationQName, locationFileName, locationLine);
    } else {
        return DebuggerBundle.message("exception.breakpoint.console.message", exceptionName, locationQName, locationFileName, locationLine);
    }
}
Also used : ExceptionEvent(com.sun.jdi.event.ExceptionEvent) AbsentInformationException(com.sun.jdi.AbsentInformationException) InvalidDataException(com.intellij.openapi.util.InvalidDataException) EvaluateException(com.intellij.debugger.engine.evaluation.EvaluateException) AbsentInformationException(com.sun.jdi.AbsentInformationException) XBreakpoint(com.intellij.xdebugger.breakpoints.XBreakpoint) Location(com.sun.jdi.Location)

Example 4 with ExceptionEvent

use of com.sun.jdi.event.ExceptionEvent in project jdk8u_jdk by JetBrains.

the class OomDebugTest method runTests.

@Override
protected void runTests() throws Exception {
    try {
        addListener(new TargetAdapter() {

            @Override
            public void exceptionThrown(ExceptionEvent event) {
                String name = event.exception().referenceType().name();
                System.err.println("DEBUG: Exception thrown in debuggee was: " + name);
            }
        });
        /*
             * Get to the top of entry()
             * to determine targetClass and mainThread
             */
        BreakpointEvent bpe = startTo("OomDebugTestTarget", "entry", "()V");
        targetClass = bpe.location().declaringType();
        mainThread = bpe.thread();
        StackFrame frame = mainThread.frame(0);
        thisObject = frame.thisObject();
        java.lang.reflect.Method m = findTestMethod();
        m.invoke(this);
    } catch (NoSuchMethodException e) {
        e.printStackTrace();
        failure();
    } catch (SecurityException e) {
        e.printStackTrace();
        failure();
    }
    /*
         * resume the target, listening for events
         */
    listenUntilVMDisconnect();
}
Also used : ExceptionEvent(com.sun.jdi.event.ExceptionEvent) BreakpointEvent(com.sun.jdi.event.BreakpointEvent) StackFrame(com.sun.jdi.StackFrame)

Aggregations

ExceptionEvent (com.sun.jdi.event.ExceptionEvent)4 EvaluateException (com.intellij.debugger.engine.evaluation.EvaluateException)2 Event (com.sun.jdi.event.Event)2 EvaluationContextImpl (com.intellij.debugger.engine.evaluation.EvaluationContextImpl)1 Breakpoint (com.intellij.debugger.ui.breakpoints.Breakpoint)1 InvalidDataException (com.intellij.openapi.util.InvalidDataException)1 XBreakpoint (com.intellij.xdebugger.breakpoints.XBreakpoint)1 AbsentInformationException (com.sun.jdi.AbsentInformationException)1 Location (com.sun.jdi.Location)1 StackFrame (com.sun.jdi.StackFrame)1 BreakpointEvent (com.sun.jdi.event.BreakpointEvent)1 EventQueue (com.sun.jdi.event.EventQueue)1 EventSet (com.sun.jdi.event.EventSet)1 VMDeathEvent (com.sun.jdi.event.VMDeathEvent)1 VMDisconnectEvent (com.sun.jdi.event.VMDisconnectEvent)1