Search in sources :

Example 6 with XStackFrame

use of com.intellij.xdebugger.frame.XStackFrame in project intellij-plugins by JetBrains.

the class DartVmServiceListener method onIsolatePaused.

void onIsolatePaused(@NotNull final IsolateRef isolateRef, @Nullable final ElementList<Breakpoint> vmBreakpoints, @Nullable final InstanceRef exception, @Nullable final Frame vmTopFrame, boolean atAsyncSuspension) {
    if (vmTopFrame == null) {
        myDebugProcess.getSession().positionReached(new XSuspendContext() {
        });
        return;
    }
    final DartVmServiceSuspendContext suspendContext = new DartVmServiceSuspendContext(myDebugProcess, isolateRef, vmTopFrame, exception, atAsyncSuspension);
    final XStackFrame xTopFrame = suspendContext.getActiveExecutionStack().getTopFrame();
    final XSourcePosition sourcePosition = xTopFrame == null ? null : xTopFrame.getSourcePosition();
    if (vmBreakpoints == null || vmBreakpoints.isEmpty()) {
        final StepOption latestStep = myDebugProcess.getVmServiceWrapper().getLatestStep();
        if (latestStep == StepOption.Over && equalSourcePositions(myLatestSourcePosition, sourcePosition)) {
            // continue stepping to change current line
            myDebugProcess.getVmServiceWrapper().resumeIsolate(isolateRef.getId(), latestStep);
        } else {
            myLatestSourcePosition = sourcePosition;
            myDebugProcess.getSession().positionReached(suspendContext);
        }
    } else {
        if (vmBreakpoints.size() > 1) {
            // Shouldn't happen. IDE doesn't allow to set 2 breakpoints on one line.
            LOG.error(vmBreakpoints.size() + " breakpoints hit in one shot.");
        }
        // Remove any temporary (run to cursor) breakpoints.
        myBreakpointHandler.removeTemporaryBreakpoints(isolateRef.getId());
        final XLineBreakpoint<XBreakpointProperties> xBreakpoint = myBreakpointHandler.getXBreakpoint(vmBreakpoints.get(0));
        if (xBreakpoint == null) {
            // breakpoint could be set in the Observatory
            myLatestSourcePosition = sourcePosition;
            myDebugProcess.getSession().positionReached(suspendContext);
            return;
        }
        if ("false".equals(evaluateExpression(isolateRef.getId(), vmTopFrame, xBreakpoint.getConditionExpression()))) {
            myDebugProcess.getVmServiceWrapper().resumeIsolate(isolateRef.getId(), null);
            return;
        }
        myLatestSourcePosition = sourcePosition;
        final String logExpression = evaluateExpression(isolateRef.getId(), vmTopFrame, xBreakpoint.getLogExpressionObject());
        final boolean suspend = myDebugProcess.getSession().breakpointReached(xBreakpoint, logExpression, suspendContext);
        if (!suspend) {
            myDebugProcess.getVmServiceWrapper().resumeIsolate(isolateRef.getId(), null);
        }
    }
}
Also used : XBreakpointProperties(com.intellij.xdebugger.breakpoints.XBreakpointProperties) DartVmServiceSuspendContext(com.jetbrains.lang.dart.ide.runner.server.vmService.frame.DartVmServiceSuspendContext) XSuspendContext(com.intellij.xdebugger.frame.XSuspendContext) XSourcePosition(com.intellij.xdebugger.XSourcePosition) XStackFrame(com.intellij.xdebugger.frame.XStackFrame)

Example 7 with XStackFrame

use of com.intellij.xdebugger.frame.XStackFrame in project intellij-community by JetBrains.

the class XDebuggerEvaluateActionHandler method perform.

@Override
protected void perform(@NotNull final XDebugSession session, final DataContext dataContext) {
    final XDebuggerEditorsProvider editorsProvider = session.getDebugProcess().getEditorsProvider();
    final XStackFrame stackFrame = session.getCurrentStackFrame();
    final XDebuggerEvaluator evaluator = session.getDebugProcess().getEvaluator();
    if (evaluator == null) {
        return;
    }
    Editor editor = CommonDataKeys.EDITOR.getData(dataContext);
    EvaluationMode mode = EvaluationMode.EXPRESSION;
    String selectedText = editor != null ? editor.getSelectionModel().getSelectedText() : null;
    if (selectedText != null) {
        selectedText = evaluator.formatTextForEvaluation(selectedText);
        mode = evaluator.getEvaluationMode(selectedText, editor.getSelectionModel().getSelectionStart(), editor.getSelectionModel().getSelectionEnd(), CommonDataKeys.PSI_FILE.getData(dataContext));
    }
    Promise<String> expressionTextPromise = Promise.resolve(selectedText);
    if (selectedText == null && editor != null) {
        expressionTextPromise = getExpressionText(evaluator, CommonDataKeys.PROJECT.getData(dataContext), editor);
    }
    final VirtualFile file = CommonDataKeys.VIRTUAL_FILE.getData(dataContext);
    EvaluationMode finalMode = mode;
    XValue value = XDebuggerTreeActionBase.getSelectedValue(dataContext);
    expressionTextPromise.done(expressionText -> {
        if (expressionText == null && value != null) {
            value.calculateEvaluationExpression().done(expression -> {
                if (expression != null) {
                    AppUIUtil.invokeOnEdt(() -> showDialog(session, file, editorsProvider, stackFrame, evaluator, expression));
                }
            });
        } else {
            XExpression expression = XExpressionImpl.fromText(StringUtil.notNullize(expressionText), finalMode);
            AppUIUtil.invokeOnEdt(() -> showDialog(session, file, editorsProvider, stackFrame, evaluator, expression));
        }
    });
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) XDebuggerEvaluator(com.intellij.xdebugger.evaluation.XDebuggerEvaluator) EvaluationMode(com.intellij.xdebugger.evaluation.EvaluationMode) XExpression(com.intellij.xdebugger.XExpression) Editor(com.intellij.openapi.editor.Editor) XDebuggerEditorsProvider(com.intellij.xdebugger.evaluation.XDebuggerEditorsProvider) XStackFrame(com.intellij.xdebugger.frame.XStackFrame) XValue(com.intellij.xdebugger.frame.XValue)

Example 8 with XStackFrame

use of com.intellij.xdebugger.frame.XStackFrame in project intellij-community by JetBrains.

the class XDebugSessionImpl method showExecutionPoint.

@Override
public void showExecutionPoint() {
    if (mySuspendContext != null) {
        XExecutionStack executionStack = mySuspendContext.getActiveExecutionStack();
        if (executionStack != null) {
            XStackFrame topFrame = executionStack.getTopFrame();
            if (topFrame != null) {
                setCurrentStackFrame(executionStack, topFrame, true);
                myDebuggerManager.showExecutionPosition();
            }
        }
    }
}
Also used : XExecutionStack(com.intellij.xdebugger.frame.XExecutionStack) XStackFrame(com.intellij.xdebugger.frame.XStackFrame)

Example 9 with XStackFrame

use of com.intellij.xdebugger.frame.XStackFrame in project intellij-community by JetBrains.

the class XVariablesView method processSessionEvent.

@Override
public void processSessionEvent(@NotNull SessionEvent event, @NotNull XDebugSession session) {
    if (ApplicationManager.getApplication().isDispatchThread()) {
        // mark nodes obsolete asap
        getTree().markNodesObsolete();
    }
    XStackFrame stackFrame = session.getCurrentStackFrame();
    DebuggerUIUtil.invokeLater(() -> {
        XDebuggerTree tree = getTree();
        if (event == SessionEvent.BEFORE_RESUME || event == SessionEvent.SETTINGS_CHANGED) {
            saveCurrentTreeState(stackFrame);
            if (event == SessionEvent.BEFORE_RESUME) {
                return;
            }
        }
        tree.markNodesObsolete();
        if (stackFrame != null) {
            cancelClear();
            buildTreeAndRestoreState(stackFrame);
        } else {
            requestClear();
        }
    });
}
Also used : XDebuggerTree(com.intellij.xdebugger.impl.ui.tree.XDebuggerTree) XStackFrame(com.intellij.xdebugger.frame.XStackFrame)

Aggregations

XStackFrame (com.intellij.xdebugger.frame.XStackFrame)9 XExecutionStack (com.intellij.xdebugger.frame.XExecutionStack)3 XDebugSession (com.intellij.xdebugger.XDebugSession)2 XSourcePosition (com.intellij.xdebugger.XSourcePosition)2 XSuspendContext (com.intellij.xdebugger.frame.XSuspendContext)2 DartVmServiceStackFrame (com.jetbrains.lang.dart.ide.runner.server.vmService.frame.DartVmServiceStackFrame)2 Location (com.sun.jdi.Location)2 Nullable (org.jetbrains.annotations.Nullable)2 JavaStackFrame (com.intellij.debugger.engine.JavaStackFrame)1 StackFrameDescriptorImpl (com.intellij.debugger.ui.impl.watch.StackFrameDescriptorImpl)1 Editor (com.intellij.openapi.editor.Editor)1 Project (com.intellij.openapi.project.Project)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 XExpression (com.intellij.xdebugger.XExpression)1 XBreakpointProperties (com.intellij.xdebugger.breakpoints.XBreakpointProperties)1 EvaluationMode (com.intellij.xdebugger.evaluation.EvaluationMode)1 XDebuggerEditorsProvider (com.intellij.xdebugger.evaluation.XDebuggerEditorsProvider)1 XDebuggerEvaluator (com.intellij.xdebugger.evaluation.XDebuggerEvaluator)1 XValue (com.intellij.xdebugger.frame.XValue)1 XDebuggerTree (com.intellij.xdebugger.impl.ui.tree.XDebuggerTree)1