Search in sources :

Example 11 with ObjectReference

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

the class DebuggerContextImpl method createEvaluationContext.

@Nullable
public EvaluationContextImpl createEvaluationContext() {
    DebuggerManagerThreadImpl.assertIsManagerThread();
    StackFrameProxyImpl frameProxy = getFrameProxy();
    ObjectReference objectReference;
    try {
        objectReference = frameProxy != null ? frameProxy.thisObject() : null;
    } catch (EvaluateException e) {
        LOG.info(e);
        objectReference = null;
    }
    SuspendContextImpl context = getSuspendContext();
    return context != null ? new EvaluationContextImpl(context, frameProxy, objectReference) : null;
}
Also used : StackFrameProxyImpl(com.intellij.debugger.jdi.StackFrameProxyImpl) EvaluateException(com.intellij.debugger.engine.evaluation.EvaluateException) EvaluationContextImpl(com.intellij.debugger.engine.evaluation.EvaluationContextImpl) ObjectReference(com.sun.jdi.ObjectReference) SuspendContextImpl(com.intellij.debugger.engine.SuspendContextImpl) Nullable(org.jetbrains.annotations.Nullable)

Example 12 with ObjectReference

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

the class ToggleFieldBreakpointAction method actionPerformed.

@Override
public void actionPerformed(AnActionEvent e) {
    Project project = e.getData(CommonDataKeys.PROJECT);
    if (project == null) {
        return;
    }
    final SourcePosition place = getPlace(e);
    if (place != null) {
        Document document = PsiDocumentManager.getInstance(project).getDocument(place.getFile());
        if (document != null) {
            DebuggerManagerEx debuggerManager = DebuggerManagerEx.getInstanceEx(project);
            BreakpointManager manager = debuggerManager.getBreakpointManager();
            final int offset = place.getOffset();
            final Breakpoint breakpoint = offset >= 0 ? manager.findBreakpoint(document, offset, FieldBreakpoint.CATEGORY) : null;
            if (breakpoint == null) {
                FieldBreakpoint fieldBreakpoint = manager.addFieldBreakpoint(document, offset);
                if (fieldBreakpoint != null) {
                    if (DebuggerAction.isContextView(e)) {
                        final DebuggerTreeNodeImpl selectedNode = DebuggerAction.getSelectedNode(e.getDataContext());
                        if (selectedNode != null && selectedNode.getDescriptor() instanceof FieldDescriptorImpl) {
                            ObjectReference object = ((FieldDescriptorImpl) selectedNode.getDescriptor()).getObject();
                            if (object != null) {
                                long id = object.uniqueID();
                                InstanceFilter[] instanceFilters = new InstanceFilter[] { InstanceFilter.create(Long.toString(id)) };
                                fieldBreakpoint.setInstanceFilters(instanceFilters);
                                fieldBreakpoint.setInstanceFiltersEnabled(true);
                            }
                        }
                    }
                    final Editor editor = CommonDataKeys.EDITOR.getData(e.getDataContext());
                    if (editor != null) {
                        manager.editBreakpoint(fieldBreakpoint, editor);
                    }
                }
            } else {
                manager.removeBreakpoint(breakpoint);
            }
        }
    }
}
Also used : FieldBreakpoint(com.intellij.debugger.ui.breakpoints.FieldBreakpoint) Breakpoint(com.intellij.debugger.ui.breakpoints.Breakpoint) InstanceFilter(com.intellij.debugger.InstanceFilter) DebuggerManagerEx(com.intellij.debugger.DebuggerManagerEx) DebuggerTreeNodeImpl(com.intellij.debugger.ui.impl.watch.DebuggerTreeNodeImpl) FieldBreakpoint(com.intellij.debugger.ui.breakpoints.FieldBreakpoint) Document(com.intellij.openapi.editor.Document) BreakpointManager(com.intellij.debugger.ui.breakpoints.BreakpointManager) FieldBreakpoint(com.intellij.debugger.ui.breakpoints.FieldBreakpoint) Breakpoint(com.intellij.debugger.ui.breakpoints.Breakpoint) FieldDescriptorImpl(com.intellij.debugger.ui.impl.watch.FieldDescriptorImpl) Project(com.intellij.openapi.project.Project) ObjectReference(com.sun.jdi.ObjectReference) SourcePosition(com.intellij.debugger.SourcePosition) Editor(com.intellij.openapi.editor.Editor)

Example 13 with ObjectReference

use of com.sun.jdi.ObjectReference in project che by eclipse.

the class JdiValueImpl method getVariables.

@Override
public JdiVariable[] getVariables() {
    if (variables == null) {
        if (isPrimitive()) {
            variables = new JdiVariable[0];
        } else {
            if (isArray()) {
                ArrayReference array = (ArrayReference) value;
                int length = array.length();
                variables = new JdiVariable[length];
                for (int i = 0; i < length; i++) {
                    variables[i] = new JdiArrayElementImpl(i, array.getValue(i));
                }
            } else {
                ObjectReference object = (ObjectReference) value;
                ReferenceType type = object.referenceType();
                List<Field> fields = type.allFields();
                variables = new JdiVariable[fields.size()];
                int i = 0;
                for (Field f : fields) {
                    variables[i++] = new JdiFieldImpl(f, object);
                }
                // See JdiFieldImpl#compareTo(JdiFieldImpl).
                Arrays.sort(variables);
            }
        }
    }
    return variables;
}
Also used : Field(com.sun.jdi.Field) ArrayReference(com.sun.jdi.ArrayReference) ObjectReference(com.sun.jdi.ObjectReference) ReferenceType(com.sun.jdi.ReferenceType)

Example 14 with ObjectReference

use of com.sun.jdi.ObjectReference in project gravel by gravel-st.

the class VMTargetRemoteTest method testDNU.

@Test
public void testDNU() throws Throwable {
    ObjectReference promise = remote.evaluateForked("3 fromage");
    ThreadReference thread = ((ThreadReference) remote.invokeMethod(promise, "thread"));
    remote.invokeMethod(thread, "start");
    ObjectReference state = (ObjectReference) remote.invokeMethod(thread, "getState");
    StringReference str = (StringReference) remote.invokeMethod(state, "toString");
    System.out.println(str.value());
    printStack(thread);
    //		assertFalse(thread.isSuspended());
    printThreadState();
    System.out.println("VMTargetStarter.sleep(1000)");
    VMTargetStarter.sleep(1000);
    printStack(thread);
    printThreadState();
    boolean isFinished = ((BooleanValue) remote.invokeMethod(promise, "isFinished")).booleanValue();
    assertFalse(isFinished);
    printThreadState();
    printStack(thread);
    assertTrue(thread.isAtBreakpoint());
}
Also used : ObjectReference(com.sun.jdi.ObjectReference) BooleanValue(com.sun.jdi.BooleanValue) ThreadReference(com.sun.jdi.ThreadReference) StringReference(com.sun.jdi.StringReference) Test(org.junit.Test)

Example 15 with ObjectReference

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

the class InstancesTree method getSelectedReference.

@Nullable
ObjectReference getSelectedReference() {
    TreePath selectionPath = getSelectionPath();
    Object selectedItem = selectionPath != null ? selectionPath.getLastPathComponent() : null;
    if (selectedItem instanceof XValueNodeImpl) {
        XValueNodeImpl xValueNode = (XValueNodeImpl) selectedItem;
        XValue valueContainer = xValueNode.getValueContainer();
        if (valueContainer instanceof NodeDescriptorProvider) {
            NodeDescriptor descriptor = ((NodeDescriptorProvider) valueContainer).getDescriptor();
            if (descriptor instanceof ValueDescriptor) {
                Value value = ((ValueDescriptor) descriptor).getValue();
                if (value instanceof ObjectReference)
                    return (ObjectReference) value;
            }
        }
    }
    return null;
}
Also used : NodeDescriptorProvider(com.intellij.debugger.ui.impl.watch.NodeDescriptorProvider) TreePath(javax.swing.tree.TreePath) ObjectReference(com.sun.jdi.ObjectReference) ValueDescriptor(com.intellij.debugger.ui.tree.ValueDescriptor) XValueNodeImpl(com.intellij.xdebugger.impl.ui.tree.nodes.XValueNodeImpl) NodeDescriptor(com.intellij.debugger.ui.tree.NodeDescriptor) Value(com.sun.jdi.Value) Nullable(org.jetbrains.annotations.Nullable)

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