protected void commandCancelled() { if (!DebuggerManagerThreadImpl.isManagerThread()) { return; } // context thread is not suspended final DebuggerContextImpl context = getDebuggerContext(); final SuspendContextImpl suspendContext = context.getSuspendContext(); if (suspendContext == null) { return; } final ThreadReferenceProxyImpl threadToSelect = context.getThreadProxy(); if (threadToSelect == null) { return; } if (!suspendContext.isResumed()) { final SuspendContextImpl threadContext = SuspendManagerUtil.getSuspendContextForThread(suspendContext, threadToSelect); context .getDebugProcess() .getManagerThread() .schedule(new RebuildFramesListCommand(context, threadContext)); refillThreadsCombo(threadToSelect); } }
public void threadAction() { if (myRefreshOnly && myThreadDescriptorsToUpdate.length != myThreadsCombo.getItemCount()) { // there is no sense in refreshing combobox if thread list has changed since creation of // this command return; } final DebuggerContextImpl context = getDebuggerContext(); final ThreadReferenceProxyImpl threadToSelect = context.getThreadProxy(); if (threadToSelect == null) { return; } final SuspendContextImpl threadContext = SuspendManagerUtil.getSuspendContextForThread( context.getSuspendContext(), threadToSelect); final ThreadDescriptorImpl currentThreadDescriptor = (ThreadDescriptorImpl) myThreadsCombo.getSelectedItem(); final ThreadReferenceProxyImpl currentThread = currentThreadDescriptor != null ? currentThreadDescriptor.getThreadReference() : null; if (myRefreshOnly && threadToSelect.equals(currentThread)) { context .getDebugProcess() .getManagerThread() .schedule(new UpdateFramesListCommand(context, threadContext)); } else { context .getDebugProcess() .getManagerThread() .schedule(new RebuildFramesListCommand(context, threadContext)); } if (myRefreshOnly) { final EvaluationContextImpl evaluationContext = context.createEvaluationContext(); for (ThreadDescriptorImpl descriptor : myThreadDescriptorsToUpdate) { descriptor.setContext(evaluationContext); descriptor.updateRepresentation( evaluationContext, DescriptorLabelListener.DUMMY_LISTENER); } DebuggerInvocationUtil.swingInvokeLater( getProject(), new Runnable() { public void run() { try { myThreadsListener.setEnabled(false); selectThread(threadToSelect); myFramesList.repaint(); } finally { myThreadsListener.setEnabled(true); } } }); } else { // full rebuild refillThreadsCombo(threadToSelect); } }
private boolean shouldApplyContext(DebuggerContextImpl context) { SuspendContextImpl suspendContext = context.getSuspendContext(); SuspendContextImpl currentContext = (SuspendContextImpl) getSession().getSuspendContext(); if (suspendContext != null && !suspendContext.equals(currentContext)) return true; JavaExecutionStack currentExecutionStack = currentContext != null ? currentContext.getActiveExecutionStack() : null; return currentExecutionStack == null || !Comparing.equal(context.getThreadProxy(), currentExecutionStack.getThreadProxy()); }
public SourcePositionCommand( final DebuggerContextImpl debuggerContext, final ValueDescriptor descriptor, final DebugProcessImpl debugProcess, final AnActionEvent actionEvent) { super(debuggerContext.getSuspendContext()); myDebuggerContext = debuggerContext; myDescriptor = descriptor; myDebugProcess = debugProcess; myActionEvent = actionEvent; }
DebuggerContextImpl getFrameDebuggerContext() { DebuggerManagerThreadImpl.assertIsManagerThread(); DebuggerContextImpl context = myDebugProcess.getDebuggerContext(); if (context.getFrameProxy() != getStackFrameProxy()) { SuspendContextImpl threadSuspendContext = SuspendManagerUtil.getSuspendContextForThread( context.getSuspendContext(), getStackFrameProxy().threadProxy()); context = DebuggerContextImpl.createDebuggerContext( myDebugProcess.mySession, threadSuspendContext, getStackFrameProxy().threadProxy(), getStackFrameProxy()); context.setPositionCache(myDescriptor.getSourcePosition()); context.initCaches(); } return context; }
private void unsetPausedIfNeeded(DebuggerContextImpl context) { SuspendContextImpl suspendContext = context.getSuspendContext(); if (suspendContext != null && context.getThreadProxy() != suspendContext.getThread()) { ((XDebugSessionImpl) getSession()).unsetPaused(); } }
// 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) { ValueDescriptorImpl returnValueDescriptor = myNodeManager.getMethodReturnValueDescriptor( myDescriptor, methodValuePair.getFirst(), methodValuePair.getSecond()); children.add(JavaValue.create(returnValueDescriptor, evaluationContext, myNodeManager)); } // add context exceptions for (Pair<Breakpoint, Event> pair : DebuggerUtilsEx.getEventDescriptors(debuggerContext.getSuspendContext())) { final Event debugEvent = pair.getSecond(); if (debugEvent instanceof ExceptionEvent) { final ObjectReference exception = ((ExceptionEvent) debugEvent).exception(); if (exception != null) { final ValueDescriptorImpl exceptionDescriptor = myNodeManager.getThrownExceptionObjectDescriptor(myDescriptor, exception); children.add(JavaValue.create(exceptionDescriptor, 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; } } }