Search in sources :

Example 16 with ObjectReference

use of com.sun.jdi.ObjectReference in project intellij-community by JetBrains.

the class InstanceValueDescriptor method getDescriptorEvaluation.

@Override
public PsiExpression getDescriptorEvaluation(DebuggerContext debuggerContext) throws EvaluateException {
    PsiElementFactory elementFactory = JavaPsiFacade.getInstance(myProject).getElementFactory();
    ObjectReference ref = ((ObjectReference) getValue());
    String name = NamesUtils.getUniqueName(ref).replace("@", "");
    String presentation = String.format("%s_DebugLabel", name);
    return elementFactory.createExpressionFromText(presentation, ContextUtil.getContextElement(debuggerContext));
}
Also used : ObjectReference(com.sun.jdi.ObjectReference) PsiElementFactory(com.intellij.psi.PsiElementFactory)

Example 17 with ObjectReference

use of com.sun.jdi.ObjectReference in project intellij-community by JetBrains.

the class ClassInstanceMethodFilter method onReached.

@Override
public int onReached(SuspendContextImpl context, RequestHint hint) {
    StackFrameProxyImpl proxy = context.getFrameProxy();
    if (proxy != null) {
        try {
            ObjectReference reference = proxy.thisObject();
            if (reference != null) {
                StepIntoBreakpoint breakpoint = DebuggerManagerEx.getInstanceEx(context.getDebugProcess().getProject()).getBreakpointManager().addStepIntoBreakpoint(myMethodFilter);
                if (breakpoint != null) {
                    breakpoint.addInstanceFilter(reference.uniqueID());
                    breakpoint.setInstanceFiltersEnabled(true);
                    setUpStepIntoBreakpoint(context, breakpoint, hint);
                    return RequestHint.RESUME;
                }
            }
        } catch (EvaluateException ignored) {
        }
    }
    return RequestHint.STOP;
}
Also used : StackFrameProxyImpl(com.intellij.debugger.jdi.StackFrameProxyImpl) EvaluateException(com.intellij.debugger.engine.evaluation.EvaluateException) ObjectReference(com.sun.jdi.ObjectReference) StepIntoBreakpoint(com.intellij.debugger.ui.breakpoints.StepIntoBreakpoint)

Example 18 with ObjectReference

use of com.sun.jdi.ObjectReference in project intellij-community by JetBrains.

the class ConstructorInstancesTracker method obsolete.

public void obsolete() {
    if (myNewObjects != null) {
        myNewObjects.forEach(ObjectReference::enableCollection);
    }
    myNewObjects = null;
    if (!myIsBackgroundMode || myIsBackgroundTrackingEnabled) {
        myBreakpoint.enable();
    }
    final XDebugSession session = XDebuggerManager.getInstance(myProject).getCurrentSession();
    if (session != null) {
        final DebugProcess process = DebuggerManager.getInstance(myProject).getDebugProcess(session.getDebugProcess().getProcessHandler());
        final MemoryViewDebugProcessData data = process.getUserData(MemoryViewDebugProcessData.KEY);
        if (data != null) {
            data.getTrackedStacks().release();
        }
    }
}
Also used : MemoryViewDebugProcessData(com.intellij.debugger.memory.component.MemoryViewDebugProcessData) XDebugSession(com.intellij.xdebugger.XDebugSession) DebugProcess(com.intellij.debugger.engine.DebugProcess) ObjectReference(com.sun.jdi.ObjectReference)

Example 19 with ObjectReference

use of com.sun.jdi.ObjectReference in project intellij-community by JetBrains.

the class ShowInstancesByClassAction method perform.

@Override
protected void perform(XValueNodeImpl node, @NotNull String nodeName, AnActionEvent e) {
    final Project project = e.getProject();
    if (project != null) {
        final XDebugSession debugSession = XDebuggerManager.getInstance(project).getCurrentSession();
        final ObjectReference ref = getObjectReference(node);
        if (debugSession != null && ref != null) {
            final ReferenceType referenceType = ref.referenceType();
            new InstancesWindow(debugSession, l -> {
                final List<ObjectReference> instances = referenceType.instances(l);
                return instances == null ? Collections.emptyList() : instances;
            }, referenceType.name()).show();
        }
    }
}
Also used : List(java.util.List) XValueNodeImpl(com.intellij.xdebugger.impl.ui.tree.nodes.XValueNodeImpl) StringUtil(com.intellij.openapi.util.text.StringUtil) AnActionEvent(com.intellij.openapi.actionSystem.AnActionEvent) ReferenceType(com.sun.jdi.ReferenceType) Project(com.intellij.openapi.project.Project) XDebuggerManager(com.intellij.xdebugger.XDebuggerManager) InstancesWindow(com.intellij.debugger.memory.ui.InstancesWindow) ObjectReference(com.sun.jdi.ObjectReference) NotNull(org.jetbrains.annotations.NotNull) XDebugSession(com.intellij.xdebugger.XDebugSession) Collections(java.util.Collections) Project(com.intellij.openapi.project.Project) XDebugSession(com.intellij.xdebugger.XDebugSession) InstancesWindow(com.intellij.debugger.memory.ui.InstancesWindow) ObjectReference(com.sun.jdi.ObjectReference) List(java.util.List) ReferenceType(com.sun.jdi.ReferenceType)

Example 20 with ObjectReference

use of com.sun.jdi.ObjectReference in project intellij-community by JetBrains.

the class ThisEvaluator method evaluate.

public Object evaluate(EvaluationContextImpl context) throws EvaluateException {
    Value objRef = context.getThisObject();
    if (myIterations > 0) {
        ObjectReference thisRef = (ObjectReference) objRef;
        for (int idx = 0; idx < myIterations && thisRef != null; idx++) {
            thisRef = getOuterObject(thisRef);
        }
        objRef = thisRef;
    }
    if (objRef == null) {
        throw EvaluateExceptionUtil.createEvaluateException(DebuggerBundle.message("evaluation.error.this.not.avalilable"));
    }
    return objRef;
}
Also used : ObjectReference(com.sun.jdi.ObjectReference) Value(com.sun.jdi.Value)

Aggregations

ObjectReference (com.sun.jdi.ObjectReference)23 EvaluateException (com.intellij.debugger.engine.evaluation.EvaluateException)5 Project (com.intellij.openapi.project.Project)5 ReferenceType (com.sun.jdi.ReferenceType)5 Value (com.sun.jdi.Value)5 Field (com.sun.jdi.Field)4 StackFrameProxyImpl (com.intellij.debugger.jdi.StackFrameProxyImpl)3 XDebugSession (com.intellij.xdebugger.XDebugSession)3 XValueNodeImpl (com.intellij.xdebugger.impl.ui.tree.nodes.XValueNodeImpl)3 BooleanValue (com.sun.jdi.BooleanValue)3 Nullable (org.jetbrains.annotations.Nullable)3 SourcePosition (com.intellij.debugger.SourcePosition)2 MemoryViewDebugProcessData (com.intellij.debugger.memory.component.MemoryViewDebugProcessData)2 StepIntoBreakpoint (com.intellij.debugger.ui.breakpoints.StepIntoBreakpoint)2 IntegerValue (com.sun.jdi.IntegerValue)2 InvocationException (com.sun.jdi.InvocationException)2 Method (com.sun.jdi.Method)2 StringReference (com.sun.jdi.StringReference)2 ThreadReference (com.sun.jdi.ThreadReference)2 DebuggerManagerEx (com.intellij.debugger.DebuggerManagerEx)1