Search in sources :

Example 36 with DebugProcessImpl

use of com.intellij.debugger.engine.DebugProcessImpl in project intellij-community by JetBrains.

the class InterruptThreadAction method actionPerformed.

public void actionPerformed(final AnActionEvent e) {
    final DebuggerTreeNodeImpl[] nodes = getSelectedNodes(e.getDataContext());
    if (nodes == null) {
        return;
    }
    //noinspection ConstantConditions
    final List<ThreadReferenceProxyImpl> threadsToInterrupt = new ArrayList<>();
    for (final DebuggerTreeNodeImpl debuggerTreeNode : nodes) {
        final NodeDescriptorImpl descriptor = debuggerTreeNode.getDescriptor();
        if (descriptor instanceof ThreadDescriptorImpl) {
            threadsToInterrupt.add(((ThreadDescriptorImpl) descriptor).getThreadReference());
        }
    }
    if (!threadsToInterrupt.isEmpty()) {
        final DebuggerContextImpl debuggerContext = getDebuggerContext(e.getDataContext());
        final DebugProcessImpl debugProcess = debuggerContext.getDebugProcess();
        if (debugProcess != null) {
            debugProcess.getManagerThread().schedule(new DebuggerCommandImpl() {

                protected void action() throws Exception {
                    boolean unsupported = false;
                    for (ThreadReferenceProxyImpl thread : threadsToInterrupt) {
                        try {
                            thread.getThreadReference().interrupt();
                        } catch (UnsupportedOperationException ignored) {
                            unsupported = true;
                        }
                    }
                    if (unsupported) {
                        final Project project = debugProcess.getProject();
                        XDebugSessionImpl.NOTIFICATION_GROUP.createNotification("Thread operation 'interrupt' is not supported by VM", MessageType.INFO).notify(project);
                    }
                }
            });
        }
    }
}
Also used : DebuggerTreeNodeImpl(com.intellij.debugger.ui.impl.watch.DebuggerTreeNodeImpl) ArrayList(java.util.ArrayList) ThreadDescriptorImpl(com.intellij.debugger.ui.impl.watch.ThreadDescriptorImpl) ThreadReferenceProxyImpl(com.intellij.debugger.jdi.ThreadReferenceProxyImpl) Project(com.intellij.openapi.project.Project) DebuggerCommandImpl(com.intellij.debugger.engine.events.DebuggerCommandImpl) DebugProcessImpl(com.intellij.debugger.engine.DebugProcessImpl) DebuggerContextImpl(com.intellij.debugger.impl.DebuggerContextImpl) NodeDescriptorImpl(com.intellij.debugger.ui.impl.watch.NodeDescriptorImpl)

Example 37 with DebugProcessImpl

use of com.intellij.debugger.engine.DebugProcessImpl in project intellij-community by JetBrains.

the class AddSteppingFilterAction method actionPerformed.

public void actionPerformed(final AnActionEvent e) {
    final DebuggerContextImpl debuggerContext = DebuggerAction.getDebuggerContext(e.getDataContext());
    DebugProcessImpl process = debuggerContext.getDebugProcess();
    if (process == null) {
        return;
    }
    final StackFrameProxyImpl proxy = PopFrameAction.getStackFrameProxy(e);
    process.getManagerThread().schedule(new DebuggerCommandImpl() {

        protected void action() throws Exception {
            final String name = getClassName(proxy != null ? proxy : debuggerContext.getFrameProxy());
            if (name == null) {
                return;
            }
            final Project project = e.getData(CommonDataKeys.PROJECT);
            ApplicationManager.getApplication().invokeLater(() -> {
                String filter = Messages.showInputDialog(project, "", "Add Stepping Filter", null, name, null);
                if (filter != null) {
                    ClassFilter[] newFilters = ArrayUtil.append(DebuggerSettings.getInstance().getSteppingFilters(), new ClassFilter(filter));
                    DebuggerSettings.getInstance().setSteppingFilters(newFilters);
                }
            });
        }
    });
}
Also used : StackFrameProxyImpl(com.intellij.debugger.jdi.StackFrameProxyImpl) Project(com.intellij.openapi.project.Project) DebuggerCommandImpl(com.intellij.debugger.engine.events.DebuggerCommandImpl) DebugProcessImpl(com.intellij.debugger.engine.DebugProcessImpl) ClassFilter(com.intellij.ui.classFilter.ClassFilter) DebuggerContextImpl(com.intellij.debugger.impl.DebuggerContextImpl) EvaluateException(com.intellij.debugger.engine.evaluation.EvaluateException)

Example 38 with DebugProcessImpl

use of com.intellij.debugger.engine.DebugProcessImpl in project intellij-community by JetBrains.

the class AutoRendererAction method actionPerformed.

public void actionPerformed(@NotNull final AnActionEvent e) {
    final DebuggerContextImpl debuggerContext = DebuggerAction.getDebuggerContext(e.getDataContext());
    final DebugProcessImpl debugProcess = debuggerContext.getDebugProcess();
    if (debugProcess != null) {
        final List<JavaValue> selectedValues = ViewAsGroup.getSelectedValues(e);
        if (!selectedValues.isEmpty()) {
            debugProcess.getManagerThread().schedule(new DebuggerContextCommandImpl(debuggerContext) {

                public void threadAction() {
                    for (JavaValue selectedValue : selectedValues) {
                        selectedValue.getDescriptor().setRenderer(null);
                    }
                    DebuggerAction.refreshViews(e);
                }
            });
        }
    }
}
Also used : DebugProcessImpl(com.intellij.debugger.engine.DebugProcessImpl) JavaValue(com.intellij.debugger.engine.JavaValue) DebuggerContextImpl(com.intellij.debugger.impl.DebuggerContextImpl) DebuggerContextCommandImpl(com.intellij.debugger.engine.events.DebuggerContextCommandImpl)

Example 39 with DebugProcessImpl

use of com.intellij.debugger.engine.DebugProcessImpl in project intellij-community by JetBrains.

the class NewArrayInstanceEvaluator method evaluate.

public Object evaluate(EvaluationContextImpl context) throws EvaluateException {
    //    throw new EvaluateException("Creating new array instances is not supported yet", true);
    DebugProcessImpl debugProcess = context.getDebugProcess();
    Object obj = myArrayTypeEvaluator.evaluate(context);
    if (!(obj instanceof ArrayType)) {
        throw EvaluateExceptionUtil.createEvaluateException(DebuggerBundle.message("evaluation.error.array.type.expected"));
    }
    ArrayType arrayType = (ArrayType) obj;
    int dimension;
    Object[] initialValues = null;
    if (myDimensionEvaluator != null) {
        Object o = myDimensionEvaluator.evaluate(context);
        if (!(o instanceof Value && DebuggerUtils.isNumeric((Value) o))) {
            throw EvaluateExceptionUtil.createEvaluateException(DebuggerBundle.message("evaluation.error.array.dimention.numeric.value.expected"));
        }
        PrimitiveValue value = (PrimitiveValue) o;
        dimension = value.intValue();
    } else {
        // myInitializerEvaluator must not be null
        Object o = myInitializerEvaluator.evaluate(context);
        if (!(o instanceof Object[])) {
            throw EvaluateExceptionUtil.createEvaluateException(DebuggerBundle.message("evaluation.error.cannot.evaluate.array.initializer"));
        }
        initialValues = (Object[]) o;
        dimension = initialValues.length;
    }
    ArrayReference arrayReference = debugProcess.newInstance(arrayType, dimension);
    if (initialValues != null && initialValues.length > 0) {
        if (LOG.isDebugEnabled()) {
            LOG.debug("Setting initial values: dimension = " + dimension + "; array size is " + initialValues.length);
        }
        setInitialValues(arrayReference, initialValues, context);
    }
    return arrayReference;
}
Also used : DebugProcessImpl(com.intellij.debugger.engine.DebugProcessImpl)

Example 40 with DebugProcessImpl

use of com.intellij.debugger.engine.DebugProcessImpl in project intellij-community by JetBrains.

the class NewArrayInstanceEvaluator method setInitialValues.

private static void setInitialValues(ArrayReference arrayReference, Object[] values, EvaluationContextImpl context) throws EvaluateException {
    ArrayType type = (ArrayType) arrayReference.referenceType();
    DebugProcessImpl debugProcess = context.getDebugProcess();
    try {
        if (type.componentType() instanceof ArrayType) {
            ArrayType componentType = (ArrayType) type.componentType();
            int length = arrayReference.length();
            for (int idx = 0; idx < length; idx++) {
                ArrayReference componentArray = (ArrayReference) arrayReference.getValue(idx);
                Object value = values[idx];
                if (value instanceof Value) {
                    arrayReference.setValue(idx, (Value) value);
                } else {
                    Object[] componentArrayValues = (Object[]) value;
                    if (componentArray == null) {
                        componentArray = debugProcess.newInstance(componentType, componentArrayValues.length);
                        arrayReference.setValue(idx, componentArray);
                    }
                    setInitialValues(componentArray, componentArrayValues, context);
                }
            }
        } else {
            if (values.length > 0) {
                arrayReference.setValues(new ArrayList(Arrays.asList(values)));
            }
        }
    } catch (ClassNotLoadedException ex) {
        final ReferenceType referenceType;
        try {
            referenceType = context.isAutoLoadClasses() ? debugProcess.loadClass(context, ex.className(), type.classLoader()) : null;
        } catch (InvocationException | InvalidTypeException | IncompatibleThreadStateException | ClassNotLoadedException e) {
            throw EvaluateExceptionUtil.createEvaluateException(e);
        }
        if (referenceType != null) {
            setInitialValues(arrayReference, values, context);
        } else {
            throw EvaluateExceptionUtil.createEvaluateException(DebuggerBundle.message("error.class.not.loaded", ex.className()));
        }
    } catch (InvalidTypeException ex) {
        throw EvaluateExceptionUtil.createEvaluateException(DebuggerBundle.message("evaluation.error.incompatible.array.initializer.type"));
    } catch (IndexOutOfBoundsException ex) {
        throw EvaluateExceptionUtil.createEvaluateException(DebuggerBundle.message("evaluation.error.invalid.array.size"));
    } catch (ClassCastException ex) {
        throw EvaluateExceptionUtil.createEvaluateException(DebuggerBundle.message("evaluation.error.cannot.initialize.array"));
    }
}
Also used : ArrayList(java.util.ArrayList) DebugProcessImpl(com.intellij.debugger.engine.DebugProcessImpl)

Aggregations

DebugProcessImpl (com.intellij.debugger.engine.DebugProcessImpl)55 DebuggerContextImpl (com.intellij.debugger.impl.DebuggerContextImpl)20 EvaluateException (com.intellij.debugger.engine.evaluation.EvaluateException)15 Project (com.intellij.openapi.project.Project)15 Nullable (org.jetbrains.annotations.Nullable)11 DebuggerCommandImpl (com.intellij.debugger.engine.events.DebuggerCommandImpl)9 DebuggerTreeNodeImpl (com.intellij.debugger.ui.impl.watch.DebuggerTreeNodeImpl)9 DebuggerContextCommandImpl (com.intellij.debugger.engine.events.DebuggerContextCommandImpl)7 List (java.util.List)7 SourcePosition (com.intellij.debugger.SourcePosition)5 JavaValue (com.intellij.debugger.engine.JavaValue)5 StackFrameProxyImpl (com.intellij.debugger.jdi.StackFrameProxyImpl)5 ThreadReferenceProxyImpl (com.intellij.debugger.jdi.ThreadReferenceProxyImpl)5 VirtualMachineProxyImpl (com.intellij.debugger.jdi.VirtualMachineProxyImpl)5 DebuggerSession (com.intellij.debugger.impl.DebuggerSession)4 NodeDescriptorImpl (com.intellij.debugger.ui.impl.watch.NodeDescriptorImpl)4 ThreadDescriptorImpl (com.intellij.debugger.ui.impl.watch.ThreadDescriptorImpl)4 XDebugSession (com.intellij.xdebugger.XDebugSession)4 ArrayList (java.util.ArrayList)4 NotNull (org.jetbrains.annotations.NotNull)4