Search in sources :

Example 11 with XDebugSession

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

the class JumpToAllocationSourceAction method getStack.

@Nullable
private List<StackFrameItem> getStack(AnActionEvent e) {
    final Project project = e.getProject();
    final XValueNodeImpl selectedNode = getSelectedNode(e.getDataContext());
    final ObjectReference ref = selectedNode != null ? getObjectReference(selectedNode) : null;
    if (project == null || ref == null) {
        return null;
    }
    final XDebugSession session = XDebuggerManager.getInstance(project).getCurrentSession();
    if (session != null) {
        final MemoryViewDebugProcessData data = DebuggerManager.getInstance(project).getDebugProcess(session.getDebugProcess().getProcessHandler()).getUserData(MemoryViewDebugProcessData.KEY);
        return data != null ? data.getTrackedStacks().getStack(ref) : null;
    }
    return null;
}
Also used : MemoryViewDebugProcessData(com.intellij.debugger.memory.component.MemoryViewDebugProcessData) Project(com.intellij.openapi.project.Project) XDebugSession(com.intellij.xdebugger.XDebugSession) ObjectReference(com.sun.jdi.ObjectReference) XValueNodeImpl(com.intellij.xdebugger.impl.ui.tree.nodes.XValueNodeImpl) Nullable(org.jetbrains.annotations.Nullable)

Example 12 with XDebugSession

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

the class GenericDebuggerRunner method attachVirtualMachine.

@Nullable
protected RunContentDescriptor attachVirtualMachine(RunProfileState state, @NotNull ExecutionEnvironment env, RemoteConnection connection, long pollTimeout) throws ExecutionException {
    DebugEnvironment environment = new DefaultDebugEnvironment(env, state, connection, pollTimeout);
    final DebuggerSession debuggerSession = DebuggerManagerEx.getInstanceEx(env.getProject()).attachVirtualMachine(environment);
    if (debuggerSession == null) {
        return null;
    }
    final DebugProcessImpl debugProcess = debuggerSession.getProcess();
    return XDebuggerManager.getInstance(env.getProject()).startSession(env, new XDebugProcessStarter() {

        @Override
        @NotNull
        public XDebugProcess start(@NotNull XDebugSession session) {
            XDebugSessionImpl sessionImpl = (XDebugSessionImpl) session;
            ExecutionResult executionResult = debugProcess.getExecutionResult();
            sessionImpl.addExtraActions(executionResult.getActions());
            if (executionResult instanceof DefaultExecutionResult) {
                sessionImpl.addRestartActions(((DefaultExecutionResult) executionResult).getRestartActions());
            }
            return JavaDebugProcess.create(session, debuggerSession);
        }
    }).getRunContentDescriptor();
}
Also used : XDebugSession(com.intellij.xdebugger.XDebugSession) DefaultDebugEnvironment(com.intellij.debugger.DefaultDebugEnvironment) DefaultExecutionResult(com.intellij.execution.DefaultExecutionResult) DebugProcessImpl(com.intellij.debugger.engine.DebugProcessImpl) XDebugProcessStarter(com.intellij.xdebugger.XDebugProcessStarter) ExecutionResult(com.intellij.execution.ExecutionResult) DefaultExecutionResult(com.intellij.execution.DefaultExecutionResult) DefaultDebugEnvironment(com.intellij.debugger.DefaultDebugEnvironment) DebugEnvironment(com.intellij.debugger.DebugEnvironment) NotNull(org.jetbrains.annotations.NotNull) XDebugSessionImpl(com.intellij.xdebugger.impl.XDebugSessionImpl) Nullable(org.jetbrains.annotations.Nullable)

Example 13 with XDebugSession

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

the class DebuggerTreeRenderer method getValueIcon.

public static Icon getValueIcon(ValueDescriptorImpl valueDescriptor) {
    Icon nodeIcon;
    if (valueDescriptor instanceof FieldDescriptorImpl) {
        FieldDescriptorImpl fieldDescriptor = (FieldDescriptorImpl) valueDescriptor;
        nodeIcon = PlatformIcons.FIELD_ICON;
        if (fieldDescriptor.getField().isFinal()) {
            nodeIcon = new LayeredIcon(nodeIcon, AllIcons.Nodes.FinalMark);
        }
        if (fieldDescriptor.isStatic()) {
            nodeIcon = new LayeredIcon(nodeIcon, AllIcons.Nodes.StaticMark);
        }
    } else if (valueDescriptor instanceof ThrownExceptionValueDescriptorImpl) {
        nodeIcon = AllIcons.Nodes.ExceptionClass;
    } else if (valueDescriptor instanceof MethodReturnValueDescriptorImpl) {
        nodeIcon = AllIcons.Debugger.WatchLastReturnValue;
    } else if (isParameter(valueDescriptor)) {
        nodeIcon = PlatformIcons.PARAMETER_ICON;
    } else if (valueDescriptor.isEnumConstant()) {
        nodeIcon = PlatformIcons.ENUM_ICON;
    } else if (valueDescriptor.isArray()) {
        nodeIcon = AllIcons.Debugger.Db_array;
    } else if (valueDescriptor.isPrimitive()) {
        nodeIcon = AllIcons.Debugger.Db_primitive;
    } else if (valueDescriptor instanceof WatchItemDescriptor) {
        nodeIcon = AllIcons.Debugger.Watch;
    } else {
        nodeIcon = AllIcons.Debugger.Value;
    }
    if (valueDescriptor instanceof UserExpressionDescriptorImpl) {
        EnumerationChildrenRenderer enumerationChildrenRenderer = EnumerationChildrenRenderer.getCurrent(((UserExpressionDescriptorImpl) valueDescriptor).getParentDescriptor());
        if (enumerationChildrenRenderer != null && enumerationChildrenRenderer.isAppendDefaultChildren()) {
            nodeIcon = AllIcons.Debugger.Watch;
        }
    }
    // if watches in variables enabled, always use watch icon
    if (valueDescriptor instanceof WatchItemDescriptor && nodeIcon != AllIcons.Debugger.Watch) {
        XDebugSession session = XDebuggerManager.getInstance(valueDescriptor.getProject()).getCurrentSession();
        if (session != null) {
            XDebugSessionTab tab = ((XDebugSessionImpl) session).getSessionTab();
            if (tab != null && tab.isWatchesInVariables()) {
                nodeIcon = AllIcons.Debugger.Watch;
            }
        }
    }
    final Icon valueIcon = valueDescriptor.getValueIcon();
    if (nodeIcon != null && valueIcon != null) {
        nodeIcon = new RowIcon(nodeIcon, valueIcon);
    }
    return nodeIcon;
}
Also used : EnumerationChildrenRenderer(com.intellij.debugger.ui.tree.render.EnumerationChildrenRenderer) XDebugSession(com.intellij.xdebugger.XDebugSession) XDebugSessionTab(com.intellij.xdebugger.impl.ui.XDebugSessionTab) XDebugSessionImpl(com.intellij.xdebugger.impl.XDebugSessionImpl)

Example 14 with XDebugSession

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

the class XQuickEvaluateHandler method createValueHintAsync.

@NotNull
@Override
public Promise<AbstractValueHint> createValueHintAsync(@NotNull final Project project, @NotNull final Editor editor, @NotNull final Point point, final ValueHintType type) {
    final XDebugSession session = XDebuggerManager.getInstance(project).getCurrentSession();
    if (session == null) {
        return Promise.resolve(null);
    }
    final XDebuggerEvaluator evaluator = session.getDebugProcess().getEvaluator();
    if (evaluator == null) {
        return Promise.resolve(null);
    }
    int offset = AbstractValueHint.calculateOffset(editor, point);
    return getExpressionInfo(evaluator, project, type, editor, offset).thenAsync(expressionInfo -> {
        AsyncPromise<AbstractValueHint> resultPromise = new AsyncPromise<>();
        UIUtil.invokeLaterIfNeeded(() -> {
            int textLength = editor.getDocument().getTextLength();
            if (expressionInfo == null) {
                resultPromise.setResult(null);
                return;
            }
            TextRange range = expressionInfo.getTextRange();
            if (range.getStartOffset() > range.getEndOffset() || range.getStartOffset() < 0 || range.getEndOffset() > textLength) {
                LOG.error("invalid range: " + range + ", text length = " + textLength + ", evaluator: " + evaluator);
                resultPromise.setResult(null);
                return;
            }
            resultPromise.setResult(new XValueHint(project, editor, point, type, expressionInfo, evaluator, session));
        });
        return resultPromise;
    });
}
Also used : XDebugSession(com.intellij.xdebugger.XDebugSession) AbstractValueHint(com.intellij.xdebugger.impl.evaluate.quick.common.AbstractValueHint) XDebuggerEvaluator(com.intellij.xdebugger.evaluation.XDebuggerEvaluator) TextRange(com.intellij.openapi.util.TextRange) AsyncPromise(org.jetbrains.concurrency.AsyncPromise) AbstractValueHint(com.intellij.xdebugger.impl.evaluate.quick.common.AbstractValueHint) NotNull(org.jetbrains.annotations.NotNull)

Example 15 with XDebugSession

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

the class XDebuggerToggleActionHandler method setSelected.

@Override
public void setSelected(@NotNull final Project project, final AnActionEvent event, final boolean state) {
    XDebugSession session = XDebuggerManager.getInstance(project).getCurrentSession();
    setSelected(session, event, state);
}
Also used : XDebugSession(com.intellij.xdebugger.XDebugSession)

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