Search in sources :

Example 1 with XExecutionStack

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

the class XFramesView method processSessionEvent.

@Override
public void processSessionEvent(@NotNull SessionEvent event, @NotNull XDebugSession session) {
    myRefresh = event == SessionEvent.SETTINGS_CHANGED;
    if (event == SessionEvent.BEFORE_RESUME) {
        return;
    }
    XStackFrame currentStackFrame = session.getCurrentStackFrame();
    XSuspendContext suspendContext = session.getSuspendContext();
    if (event == SessionEvent.FRAME_CHANGED) {
        ApplicationManager.getApplication().assertIsDispatchThread();
        if (currentStackFrame != null) {
            myFramesList.setSelectedValue(currentStackFrame, true);
            mySelectedFrameIndex = myFramesList.getSelectedIndex();
            myExecutionStacksWithSelection.put(mySelectedStack, mySelectedFrameIndex);
        }
        return;
    }
    myLaterInvocator.offer(() -> {
        if (event != SessionEvent.SETTINGS_CHANGED) {
            mySelectedFrameIndex = 0;
            mySelectedStack = null;
            myVisibleRect = null;
        } else {
            myVisibleRect = myFramesList.getVisibleRect();
        }
        myListenersEnabled = false;
        myBuilders.values().forEach(StackFramesListBuilder::dispose);
        myBuilders.clear();
        if (suspendContext == null) {
            requestClear();
            return;
        }
        if (event == SessionEvent.PAUSED) {
            // clear immediately
            cancelClear();
            clear();
        }
        XExecutionStack[] executionStacks = suspendContext.getExecutionStacks();
        addExecutionStacks(Arrays.asList(executionStacks));
        XExecutionStack activeExecutionStack = mySelectedStack != null ? mySelectedStack : suspendContext.getActiveExecutionStack();
        myThreadComboBox.setSelectedItem(activeExecutionStack);
        myThreadsPanel.removeAll();
        myThreadsPanel.add(myToolbar.getComponent(), BorderLayout.EAST);
        final boolean invisible = executionStacks.length == 1 && StringUtil.isEmpty(executionStacks[0].getDisplayName());
        if (!invisible) {
            myThreadsPanel.add(myThreadComboBox, BorderLayout.CENTER);
        }
        myToolbar.setAddSeparatorFirst(!invisible);
        updateFrames(activeExecutionStack, session);
    });
}
Also used : XSuspendContext(com.intellij.xdebugger.frame.XSuspendContext) XStackFrame(com.intellij.xdebugger.frame.XStackFrame) XExecutionStack(com.intellij.xdebugger.frame.XExecutionStack)

Example 2 with XExecutionStack

use of com.intellij.xdebugger.frame.XExecutionStack in project ballerina by ballerina-lang.

the class BallerinaDebugProcess method getWorkerID.

@Nullable
private String getWorkerID(@Nullable XSuspendContext context) {
    if (context != null) {
        XExecutionStack activeExecutionStack = context.getActiveExecutionStack();
        if (activeExecutionStack instanceof BallerinaSuspendContext.BallerinaExecutionStack) {
            return ((BallerinaSuspendContext.BallerinaExecutionStack) activeExecutionStack).getMyWorkerID();
        }
    }
    getSession().getConsoleView().print("Error occurred while getting the thread ID.", ConsoleViewContentType.ERROR_OUTPUT);
    getSession().stop();
    return null;
}
Also used : XExecutionStack(com.intellij.xdebugger.frame.XExecutionStack) Nullable(org.jetbrains.annotations.Nullable)

Example 3 with XExecutionStack

use of com.intellij.xdebugger.frame.XExecutionStack in project android by JetBrains.

the class InstantRunManager method refreshDebugger.

private void refreshDebugger(@NotNull String packageName) {
    // First we reapply the breakpoints on the new code, otherwise the breakpoints
    // remain set on the old classes and will never be hit again.
    ApplicationManager.getApplication().runReadAction(new Runnable() {

        @Override
        public void run() {
            DebuggerManagerEx debugger = DebuggerManagerEx.getInstanceEx(myProject);
            if (!debugger.getSessions().isEmpty()) {
                List<Breakpoint> breakpoints = debugger.getBreakpointManager().getBreakpoints();
                for (Breakpoint breakpoint : breakpoints) {
                    if (breakpoint.isEnabled()) {
                        breakpoint.setEnabled(false);
                        breakpoint.setEnabled(true);
                    }
                }
            }
        }
    });
    // Now we refresh the call-stacks and the variable panes.
    DebuggerManagerEx debugger = DebuggerManagerEx.getInstanceEx(myProject);
    for (final DebuggerSession session : debugger.getSessions()) {
        Client client = session.getProcess().getProcessHandler().getUserData(AndroidSessionInfo.ANDROID_DEBUG_CLIENT);
        if (client != null && client.isValid() && StringUtil.equals(packageName, client.getClientData().getClientDescription())) {
            session.getProcess().getManagerThread().invoke(new DebuggerCommandImpl() {

                @Override
                protected void action() throws Exception {
                    DebuggerContextImpl context = session.getContextManager().getContext();
                    SuspendContextImpl suspendContext = context.getSuspendContext();
                    if (suspendContext != null) {
                        XExecutionStack stack = suspendContext.getActiveExecutionStack();
                        if (stack != null) {
                            ((JavaExecutionStack) stack).initTopFrame();
                        }
                    }
                    ApplicationManager.getApplication().invokeLater(new Runnable() {

                        @Override
                        public void run() {
                            session.refresh(false);
                            XDebugSession xSession = session.getXDebugSession();
                            if (xSession != null) {
                                xSession.resume();
                            }
                        }
                    });
                }
            });
        }
    }
}
Also used : Breakpoint(com.intellij.debugger.ui.breakpoints.Breakpoint) XDebugSession(com.intellij.xdebugger.XDebugSession) DebuggerManagerEx(com.intellij.debugger.DebuggerManagerEx) XExecutionStack(com.intellij.xdebugger.frame.XExecutionStack) InstantRunPushFailedException(com.android.tools.fd.client.InstantRunPushFailedException) IOException(java.io.IOException) DebuggerSession(com.intellij.debugger.impl.DebuggerSession) DebuggerCommandImpl(com.intellij.debugger.engine.events.DebuggerCommandImpl) List(java.util.List) SuspendContextImpl(com.intellij.debugger.engine.SuspendContextImpl) DebuggerContextImpl(com.intellij.debugger.impl.DebuggerContextImpl) InstantRunClient(com.android.tools.fd.client.InstantRunClient) Client(com.android.ddmlib.Client)

Example 4 with XExecutionStack

use of com.intellij.xdebugger.frame.XExecutionStack 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 5 with XExecutionStack

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

the class XFramesView method addExecutionStacks.

private void addExecutionStacks(List<? extends XExecutionStack> executionStacks) {
    for (XExecutionStack executionStack : executionStacks) {
        if (!myExecutionStacksWithSelection.contains(executionStack)) {
            //noinspection unchecked
            myThreadComboBox.addItem(executionStack);
            myExecutionStacksWithSelection.put(executionStack, 0);
        }
    }
}
Also used : XExecutionStack(com.intellij.xdebugger.frame.XExecutionStack)

Aggregations

XExecutionStack (com.intellij.xdebugger.frame.XExecutionStack)7 XDebugSession (com.intellij.xdebugger.XDebugSession)3 SuspendContextImpl (com.intellij.debugger.engine.SuspendContextImpl)2 XStackFrame (com.intellij.xdebugger.frame.XStackFrame)2 XSuspendContext (com.intellij.xdebugger.frame.XSuspendContext)2 IOException (java.io.IOException)2 Client (com.android.ddmlib.Client)1 InstantRunClient (com.android.tools.fd.client.InstantRunClient)1 InstantRunPushFailedException (com.android.tools.fd.client.InstantRunPushFailedException)1 DebuggerManagerEx (com.intellij.debugger.DebuggerManagerEx)1 DebugProcessImpl (com.intellij.debugger.engine.DebugProcessImpl)1 JavaExecutionStack (com.intellij.debugger.engine.JavaExecutionStack)1 DebuggerCommandImpl (com.intellij.debugger.engine.events.DebuggerCommandImpl)1 DebuggerContextImpl (com.intellij.debugger.impl.DebuggerContextImpl)1 DebuggerSession (com.intellij.debugger.impl.DebuggerSession)1 VirtualMachineProxyImpl (com.intellij.debugger.jdi.VirtualMachineProxyImpl)1 Breakpoint (com.intellij.debugger.ui.breakpoints.Breakpoint)1 BreakpointManager (com.intellij.debugger.ui.breakpoints.BreakpointManager)1 ProcessCanceledException (com.intellij.openapi.progress.ProcessCanceledException)1 Project (com.intellij.openapi.project.Project)1