Search in sources :

Example 6 with ObjectReference

use of com.sun.jdi.ObjectReference in project jdk8u_jdk by JetBrains.

the class OomDebugTest method test1.

/*
     * Test case: Object reference as method parameter.
     */
// called via reflection
@SuppressWarnings("unused")
private void test1() throws Exception {
    System.out.println("DEBUG: ------------> Running test1");
    try {
        Field field = targetClass.fieldByName("fooCls");
        ClassType clsType = (ClassType) field.type();
        Method constructor = getConstructorForClass(clsType);
        for (int i = 0; i < 15; i++) {
            @SuppressWarnings({ "rawtypes", "unchecked" }) ObjectReference objRef = clsType.newInstance(mainThread, constructor, new ArrayList(0), ObjectReference.INVOKE_NONVIRTUAL);
            if (objRef.isCollected()) {
                System.out.println("DEBUG: Object got GC'ed before we can use it. NO-OP.");
                continue;
            }
            invoke("testMethod", "(LOomDebugTestTarget$FooCls;)V", objRef);
        }
    } catch (InvocationException e) {
        handleFailure(e);
    }
}
Also used : Field(com.sun.jdi.Field) ObjectReference(com.sun.jdi.ObjectReference) InvocationException(com.sun.jdi.InvocationException) ArrayList(java.util.ArrayList) Method(com.sun.jdi.Method) ClassType(com.sun.jdi.ClassType)

Example 7 with ObjectReference

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

the class ShowInstancesByClassAction method isEnabled.

@Override
protected boolean isEnabled(@NotNull XValueNodeImpl node, @NotNull AnActionEvent e) {
    final ObjectReference ref = getObjectReference(node);
    final boolean enabled = ref != null && ref.virtualMachine().canGetInstanceInfo();
    if (enabled) {
        final String text = String.format("Show %s Objects...", StringUtil.getShortName(ref.referenceType().name()));
        e.getPresentation().setText(text);
    }
    return enabled;
}
Also used : ObjectReference(com.sun.jdi.ObjectReference)

Example 8 with ObjectReference

use of com.sun.jdi.ObjectReference 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 9 with ObjectReference

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

the class FilteringTask method run.

@Override
public void run() {
    myCallback.started(myReferences.size());
    int proceedCount;
    for (proceedCount = 0; proceedCount < myReferences.size() && !myIsCancelled; proceedCount++) {
        ObjectReference ref = myReferences.get(proceedCount);
        CheckingResult result = myChecker.check(ref);
        FilteringTaskCallback.Action action = FilteringTaskCallback.Action.CONTINUE;
        switch(result.getResult()) {
            case MATCH:
                action = myCallback.matched(ref);
                break;
            case NO_MATCH:
                action = myCallback.notMatched(ref);
                break;
            case ERROR:
                action = myCallback.error(ref, result.getFailureDescription());
                break;
        }
        if (action == FilteringTaskCallback.Action.STOP) {
            break;
        }
    }
    FilteringResult reason = myIsCancelled ? FilteringResult.INTERRUPTED : proceedCount == myReferences.size() ? FilteringResult.ALL_CHECKED : FilteringResult.LIMIT_REACHED;
    myCallback.completed(reason);
}
Also used : ObjectReference(com.sun.jdi.ObjectReference)

Example 10 with ObjectReference

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

the class LambdaAsyncMethodFilter method onReached.

@Override
public int onReached(SuspendContextImpl context, RequestHint hint) {
    try {
        StackFrameProxyImpl proxy = context.getFrameProxy();
        if (proxy != null) {
            Value lambdaReference = ContainerUtil.getOrElse(proxy.getArgumentValues(), myParamNo, null);
            if (lambdaReference instanceof ObjectReference) {
                final SourcePosition pos = myMethodFilter.getBreakpointPosition();
                if (pos != null) {
                    Project project = context.getDebugProcess().getProject();
                    long lambdaId = ((ObjectReference) lambdaReference).uniqueID();
                    StepIntoBreakpoint breakpoint = new LambdaInstanceBreakpoint(project, lambdaId, pos, myMethodFilter);
                    ClassInstanceMethodFilter.setUpStepIntoBreakpoint(context, breakpoint, hint);
                    return RequestHint.RESUME;
                }
            }
        }
    } catch (EvaluateException ignore) {
    }
    return RequestHint.STOP;
}
Also used : StackFrameProxyImpl(com.intellij.debugger.jdi.StackFrameProxyImpl) Project(com.intellij.openapi.project.Project) EvaluateException(com.intellij.debugger.engine.evaluation.EvaluateException) ObjectReference(com.sun.jdi.ObjectReference) SourcePosition(com.intellij.debugger.SourcePosition) Value(com.sun.jdi.Value) StepIntoBreakpoint(com.intellij.debugger.ui.breakpoints.StepIntoBreakpoint)

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