Search in sources :

Example 46 with XDebugSession

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

the class XAddToWatchesAction method getWatchesView.

private static XWatchesView getWatchesView(@NotNull AnActionEvent e) {
    XWatchesView view = e.getData(XWatchesView.DATA_KEY);
    Project project = e.getProject();
    if (view == null && project != null) {
        XDebugSession session = XDebuggerManager.getInstance(project).getCurrentSession();
        if (session != null) {
            XDebugSessionTab tab = ((XDebugSessionImpl) session).getSessionTab();
            if (tab != null) {
                return tab.getWatchesView();
            }
        }
    }
    return view;
}
Also used : Project(com.intellij.openapi.project.Project) XDebugSession(com.intellij.xdebugger.XDebugSession) XDebugSessionTab(com.intellij.xdebugger.impl.ui.XDebugSessionTab) XWatchesView(com.intellij.xdebugger.impl.frame.XWatchesView) XDebugSessionImpl(com.intellij.xdebugger.impl.XDebugSessionImpl)

Example 47 with XDebugSession

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

the class XsltBreakpointHandler method registerBreakpoint.

@Override
public void registerBreakpoint(@NotNull XLineBreakpoint<XBreakpointProperties> breakpoint) {
    final XSourcePosition sourcePosition = breakpoint.getSourcePosition();
    if (sourcePosition == null || !sourcePosition.getFile().exists() || !sourcePosition.getFile().isValid()) {
        // ???
        return;
    }
    final VirtualFile file = sourcePosition.getFile();
    final Project project = myXsltDebugProcess.getSession().getProject();
    final String fileURL = getFileURL(file);
    final int lineNumber = getActualLineNumber(breakpoint, project);
    if (lineNumber == -1) {
        final XDebugSession session = myXsltDebugProcess.getSession();
        session.updateBreakpointPresentation(breakpoint, AllIcons.Debugger.Db_invalid_breakpoint, "Unsupported breakpoint position");
        return;
    }
    try {
        final BreakpointManager manager = myXsltDebugProcess.getBreakpointManager();
        Breakpoint bp;
        if ((bp = manager.getBreakpoint(fileURL, lineNumber)) != null) {
            bp.setEnabled(true);
        } else {
            manager.setBreakpoint(fileURL, lineNumber);
        }
    } catch (DebuggerStoppedException ignore) {
    } catch (VMPausedException e) {
        final XDebugSession session = myXsltDebugProcess.getSession();
        session.reportMessage("Target VM is not responding. Breakpoint can not be set", MessageType.ERROR);
        session.updateBreakpointPresentation(breakpoint, AllIcons.Debugger.Db_invalid_breakpoint, "Target VM is not responding. Breakpoint can not be set");
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) Project(com.intellij.openapi.project.Project) XDebugSession(com.intellij.xdebugger.XDebugSession) Breakpoint(org.intellij.plugins.xsltDebugger.rt.engine.Breakpoint) XLineBreakpoint(com.intellij.xdebugger.breakpoints.XLineBreakpoint) XSourcePosition(com.intellij.xdebugger.XSourcePosition) VMPausedException(org.intellij.plugins.xsltDebugger.VMPausedException) BreakpointManager(org.intellij.plugins.xsltDebugger.rt.engine.BreakpointManager) Breakpoint(org.intellij.plugins.xsltDebugger.rt.engine.Breakpoint) XLineBreakpoint(com.intellij.xdebugger.breakpoints.XLineBreakpoint) DebuggerStoppedException(org.intellij.plugins.xsltDebugger.rt.engine.DebuggerStoppedException)

Example 48 with XDebugSession

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

the class PyExecuteSelectionAction method selectConsole.

private static void selectConsole(@NotNull DataContext dataContext, @NotNull Project project, final Consumer<PyCodeExecutor> consumer, Editor editor) {
    Collection<RunContentDescriptor> consoles = getConsoles(project);
    ExecutionHelper.selectContentDescriptor(dataContext, project, consoles, "Select console to execute in", descriptor -> {
        if (descriptor != null && descriptor.getExecutionConsole() instanceof PyCodeExecutor) {
            ExecutionConsole console = descriptor.getExecutionConsole();
            consumer.consume((PyCodeExecutor) console);
            if (console instanceof PythonDebugLanguageConsoleView) {
                XDebugSession currentSession = XDebuggerManager.getInstance(project).getCurrentSession();
                if (currentSession != null) {
                    ContentManager contentManager = currentSession.getUI().getContentManager();
                    Content content = contentManager.findContent("Console");
                    contentManager.setSelectedContent(content);
                    IdeFocusManager.findInstance().requestFocus(editor.getContentComponent(), true);
                }
            } else {
                PythonConsoleToolWindow consoleToolWindow = PythonConsoleToolWindow.getInstance(project);
                ToolWindow toolWindow = consoleToolWindow != null ? consoleToolWindow.getToolWindow() : null;
                if (toolWindow != null && !toolWindow.isVisible()) {
                    toolWindow.show(null);
                    ContentManager contentManager = toolWindow.getContentManager();
                    Content content = contentManager.findContent(descriptor.getDisplayName());
                    if (content != null) {
                        contentManager.setSelectedContent(content);
                    }
                }
            }
        }
    });
}
Also used : XDebugSession(com.intellij.xdebugger.XDebugSession) ToolWindow(com.intellij.openapi.wm.ToolWindow) RunContentDescriptor(com.intellij.execution.ui.RunContentDescriptor) Content(com.intellij.ui.content.Content) ContentManager(com.intellij.ui.content.ContentManager) ExecutionConsole(com.intellij.execution.ui.ExecutionConsole)

Example 49 with XDebugSession

use of com.intellij.xdebugger.XDebugSession 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 50 with XDebugSession

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

the class FlexRunner method doExecute.

@Override
protected RunContentDescriptor doExecute(@NotNull final RunProfileState state, @NotNull ExecutionEnvironment env) throws ExecutionException {
    final BCBasedRunnerParameters parameters = ((RemoteFlashRunConfiguration) env.getRunProfile()).getRunnerParameters();
    RunContentDescriptor runContentDescriptor = XDebuggerManager.getInstance(env.getProject()).startSession(env, new XDebugProcessStarter() {

        @Override
        @NotNull
        public XDebugProcess start(@NotNull final XDebugSession session) throws ExecutionException {
            try {
                return DebugPathManager.IS_DEV ? new MyFlexDebugProcessAbleToResolveFileDebugId(callback, session, buildConfiguration, parameters) : new MyFlexDebugProcess(callback, session, buildConfiguration, parameters);
            } catch (IOException e) {
                throw new ExecutionException(e.getMessage(), e);
            } finally {
                buildConfiguration = null;
            }
        }
    }).getRunContentDescriptor();
    ProcessHandler processHandler = runContentDescriptor.getProcessHandler();
    assert processHandler != null;
    //noinspection deprecation
    processHandler.putUserData(ProcessHandler.SILENTLY_DESTROY_ON_CLOSE, true);
    return runContentDescriptor;
}
Also used : XDebugSession(com.intellij.xdebugger.XDebugSession) BCBasedRunnerParameters(com.intellij.lang.javascript.flex.run.BCBasedRunnerParameters) RunContentDescriptor(com.intellij.execution.ui.RunContentDescriptor) XDebugProcessStarter(com.intellij.xdebugger.XDebugProcessStarter) RemoteFlashRunConfiguration(com.intellij.lang.javascript.flex.run.RemoteFlashRunConfiguration) ProcessHandler(com.intellij.execution.process.ProcessHandler) IOException(java.io.IOException) ExecutionException(com.intellij.execution.ExecutionException) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

XDebugSession (com.intellij.xdebugger.XDebugSession)50 Project (com.intellij.openapi.project.Project)15 NotNull (org.jetbrains.annotations.NotNull)13 XDebugProcessStarter (com.intellij.xdebugger.XDebugProcessStarter)9 XDebugSessionImpl (com.intellij.xdebugger.impl.XDebugSessionImpl)9 XDebugProcess (com.intellij.xdebugger.XDebugProcess)8 Nullable (org.jetbrains.annotations.Nullable)7 DebuggerSession (com.intellij.debugger.impl.DebuggerSession)6 IOException (java.io.IOException)5 DebugProcessImpl (com.intellij.debugger.engine.DebugProcessImpl)4 ExecutionException (com.intellij.execution.ExecutionException)4 XValueNodeImpl (com.intellij.xdebugger.impl.ui.tree.nodes.XValueNodeImpl)4 DebugEnvironment (com.intellij.debugger.DebugEnvironment)3 VirtualMachineProxyImpl (com.intellij.debugger.jdi.VirtualMachineProxyImpl)3 ExecutionResult (com.intellij.execution.ExecutionResult)3 RunContentDescriptor (com.intellij.execution.ui.RunContentDescriptor)3 XSourcePosition (com.intellij.xdebugger.XSourcePosition)3 ServerSocket (java.net.ServerSocket)3 List (java.util.List)3 DefaultDebugEnvironment (com.intellij.debugger.DefaultDebugEnvironment)2