Search in sources :

Example 6 with VirtualMachineProxyImpl

use of com.intellij.debugger.jdi.VirtualMachineProxyImpl in project intellij-community by JetBrains.

the class ClassLoadingUtils method createURLArray.

private static ArrayReference createURLArray(EvaluationContext context) throws EvaluateException, InvalidTypeException, ClassNotLoadedException {
    DebugProcess process = context.getDebugProcess();
    ArrayType arrayType = (ArrayType) process.findClass(context, "java.net.URL[]", context.getClassLoader());
    ArrayReference arrayRef = arrayType.newInstance(1);
    DebuggerUtilsEx.keep(arrayRef, context);
    ClassType classType = (ClassType) process.findClass(context, "java.net.URL", context.getClassLoader());
    VirtualMachineProxyImpl proxy = (VirtualMachineProxyImpl) process.getVirtualMachineProxy();
    StringReference url = proxy.mirrorOf("file:a");
    DebuggerUtilsEx.keep(url, context);
    ObjectReference reference = process.newInstance(context, classType, classType.concreteMethodByName(JVMNameUtil.CONSTRUCTOR_NAME, "(Ljava/lang/String;)V"), Collections.singletonList(url));
    DebuggerUtilsEx.keep(reference, context);
    arrayRef.setValues(Collections.singletonList(reference));
    return arrayRef;
}
Also used : DebugProcess(com.intellij.debugger.engine.DebugProcess) VirtualMachineProxyImpl(com.intellij.debugger.jdi.VirtualMachineProxyImpl)

Example 7 with VirtualMachineProxyImpl

use of com.intellij.debugger.jdi.VirtualMachineProxyImpl in project intellij-community by JetBrains.

the class TypeCastEvaluator method evaluate.

public Object evaluate(EvaluationContextImpl context) throws EvaluateException {
    Value value = (Value) myOperandEvaluator.evaluate(context);
    if (value == null) {
        if (myIsPrimitive) {
            throw EvaluateExceptionUtil.createEvaluateException(DebuggerBundle.message("evaluation.error.cannot.cast.null", myCastType));
        }
        return null;
    }
    VirtualMachineProxyImpl vm = context.getDebugProcess().getVirtualMachineProxy();
    if (DebuggerUtils.isInteger(value)) {
        value = DebuggerUtilsEx.createValue(vm, myCastType, ((PrimitiveValue) value).longValue());
        if (value == null) {
            throw EvaluateExceptionUtil.createEvaluateException(DebuggerBundle.message("evaluation.error.cannot.cast.numeric", myCastType));
        }
    } else if (DebuggerUtils.isNumeric(value)) {
        value = DebuggerUtilsEx.createValue(vm, myCastType, ((PrimitiveValue) value).doubleValue());
        if (value == null) {
            throw EvaluateExceptionUtil.createEvaluateException(DebuggerBundle.message("evaluation.error.cannot.cast.numeric", myCastType));
        }
    } else if (value instanceof BooleanValue) {
        value = DebuggerUtilsEx.createValue(vm, myCastType, ((BooleanValue) value).booleanValue());
        if (value == null) {
            throw EvaluateExceptionUtil.createEvaluateException(DebuggerBundle.message("evaluation.error.cannot.cast.boolean", myCastType));
        }
    } else if (value instanceof CharValue) {
        value = DebuggerUtilsEx.createValue(vm, myCastType, ((CharValue) value).charValue());
        if (value == null) {
            throw EvaluateExceptionUtil.createEvaluateException(DebuggerBundle.message("evaluation.error.cannot.cast.char", myCastType));
        }
    } else if (value instanceof ObjectReference) {
        Type type = value.type();
        if (!DebuggerUtils.instanceOf(type, myCastType)) {
            throw EvaluateExceptionUtil.createEvaluateException(DebuggerBundle.message("evaluation.error.cannot.cast.object", type.name(), myCastType));
        }
    }
    return value;
}
Also used : VirtualMachineProxyImpl(com.intellij.debugger.jdi.VirtualMachineProxyImpl)

Example 8 with VirtualMachineProxyImpl

use of com.intellij.debugger.jdi.VirtualMachineProxyImpl in project intellij-community by JetBrains.

the class DebugProcessImpl method loadClass.

@SuppressWarnings({ "HardCodedStringLiteral", "SpellCheckingInspection" })
public ReferenceType loadClass(EvaluationContextImpl evaluationContext, String qName, ClassLoaderReference classLoader) throws InvocationException, ClassNotLoadedException, IncompatibleThreadStateException, InvalidTypeException, EvaluateException {
    DebuggerManagerThreadImpl.assertIsManagerThread();
    qName = reformatArrayName(qName);
    ReferenceType refType = null;
    VirtualMachineProxyImpl virtualMachine = getVirtualMachineProxy();
    ClassType classClassType = (ClassType) ContainerUtil.getFirstItem(virtualMachine.classesByName(CommonClassNames.JAVA_LANG_CLASS));
    if (classClassType != null) {
        final Method forNameMethod;
        // do not use unmodifiable lists because the list is modified by JPDA
        List<Value> args = new ArrayList<>();
        args.add(virtualMachine.mirrorOf(qName));
        if (classLoader != null) {
            //forNameMethod = classClassType.concreteMethodByName("forName", "(Ljava/lang/String;ZLjava/lang/ClassLoader;)Ljava/lang/Class;");
            forNameMethod = DebuggerUtils.findMethod(classClassType, "forName", "(Ljava/lang/String;ZLjava/lang/ClassLoader;)Ljava/lang/Class;");
            args.add(virtualMachine.mirrorOf(true));
            args.add(classLoader);
        } else {
            //forNameMethod = classClassType.concreteMethodByName("forName", "(Ljava/lang/String;)Ljava/lang/Class;");
            forNameMethod = DebuggerUtils.findMethod(classClassType, "forName", "(Ljava/lang/String;)Ljava/lang/Class;");
        }
        Value classReference = invokeMethod(evaluationContext, classClassType, forNameMethod, args);
        if (classReference instanceof ClassObjectReference) {
            refType = ((ClassObjectReference) classReference).reflectedType();
        }
    }
    return refType;
}
Also used : VirtualMachineProxyImpl(com.intellij.debugger.jdi.VirtualMachineProxyImpl)

Example 9 with VirtualMachineProxyImpl

use of com.intellij.debugger.jdi.VirtualMachineProxyImpl in project intellij-community by JetBrains.

the class DebugProcessImpl method closeProcess.

protected void closeProcess(boolean closedByUser) {
    DebuggerManagerThreadImpl.assertIsManagerThread();
    if (myState.compareAndSet(State.INITIAL, State.DETACHING) || myState.compareAndSet(State.ATTACHED, State.DETACHING)) {
        try {
            getManagerThread().close();
        } finally {
            final VirtualMachineProxyImpl vm = myVirtualMachineProxy;
            myVirtualMachineProxy = null;
            myPositionManager = CompoundPositionManager.EMPTY;
            myReturnValueWatcher = null;
            myNodeRenderersMap.clear();
            myRenderers.clear();
            DebuggerUtils.cleanupAfterProcessFinish(this);
            myState.compareAndSet(State.DETACHING, State.DETACHED);
            try {
                myDebugProcessDispatcher.getMulticaster().processDetached(this, closedByUser);
            } finally {
                //}
                if (vm != null) {
                    try {
                        // to be on the safe side ensure that VM mirror, if present, is disposed and invalidated
                        vm.dispose();
                    } catch (Throwable ignored) {
                    }
                }
                myWaitFor.up();
            }
        }
    }
}
Also used : VirtualMachineProxyImpl(com.intellij.debugger.jdi.VirtualMachineProxyImpl)

Example 10 with VirtualMachineProxyImpl

use of com.intellij.debugger.jdi.VirtualMachineProxyImpl in project intellij-community by JetBrains.

the class DebugProcessImpl method commitVM.

@SuppressWarnings({ "HardCodedStringLiteral" })
protected void commitVM(VirtualMachine vm) {
    if (!isInInitialState()) {
        LOG.error("State is invalid " + myState.get());
    }
    DebuggerManagerThreadImpl.assertIsManagerThread();
    myPositionManager = new CompoundPositionManager(new PositionManagerImpl(this));
    LOG.debug("*******************VM attached******************");
    checkVirtualMachineVersion(vm);
    myVirtualMachineProxy = new VirtualMachineProxyImpl(this, vm);
    if (!StringUtil.isEmpty(ourTrace)) {
        int mask = 0;
        StringTokenizer tokenizer = new StringTokenizer(ourTrace);
        while (tokenizer.hasMoreTokens()) {
            String token = tokenizer.nextToken();
            if ("SENDS".compareToIgnoreCase(token) == 0) {
                mask |= VirtualMachine.TRACE_SENDS;
            } else if ("RAW_SENDS".compareToIgnoreCase(token) == 0) {
                mask |= 0x01000000;
            } else if ("RECEIVES".compareToIgnoreCase(token) == 0) {
                mask |= VirtualMachine.TRACE_RECEIVES;
            } else if ("RAW_RECEIVES".compareToIgnoreCase(token) == 0) {
                mask |= 0x02000000;
            } else if ("EVENTS".compareToIgnoreCase(token) == 0) {
                mask |= VirtualMachine.TRACE_EVENTS;
            } else if ("REFTYPES".compareToIgnoreCase(token) == 0) {
                mask |= VirtualMachine.TRACE_REFTYPES;
            } else if ("OBJREFS".compareToIgnoreCase(token) == 0) {
                mask |= VirtualMachine.TRACE_OBJREFS;
            } else if ("ALL".compareToIgnoreCase(token) == 0) {
                mask |= VirtualMachine.TRACE_ALL;
            }
        }
        vm.setDebugTraceMode(mask);
    }
}
Also used : VirtualMachineProxyImpl(com.intellij.debugger.jdi.VirtualMachineProxyImpl) StackCapturingLineBreakpoint(com.intellij.debugger.ui.breakpoints.StackCapturingLineBreakpoint) StepIntoBreakpoint(com.intellij.debugger.ui.breakpoints.StepIntoBreakpoint) RunToCursorBreakpoint(com.intellij.debugger.ui.breakpoints.RunToCursorBreakpoint)

Aggregations

VirtualMachineProxyImpl (com.intellij.debugger.jdi.VirtualMachineProxyImpl)21 DebugProcessImpl (com.intellij.debugger.engine.DebugProcessImpl)5 DebugProcess (com.intellij.debugger.engine.DebugProcess)4 XDebugSession (com.intellij.xdebugger.XDebugSession)3 Nullable (org.jetbrains.annotations.Nullable)3 EvaluateException (com.intellij.debugger.engine.evaluation.EvaluateException)2 DebuggerContextImpl (com.intellij.debugger.impl.DebuggerContextImpl)2 Project (com.intellij.openapi.project.Project)2 Method (com.sun.jdi.Method)2 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 SourcePosition (com.intellij.debugger.SourcePosition)1 JavaExecutionStack (com.intellij.debugger.engine.JavaExecutionStack)1 SuspendContextImpl (com.intellij.debugger.engine.SuspendContextImpl)1 ExpressionEvaluator (com.intellij.debugger.engine.evaluation.expression.ExpressionEvaluator)1 DebuggerCommandImpl (com.intellij.debugger.engine.events.DebuggerCommandImpl)1 MethodReturnValueWatcher (com.intellij.debugger.engine.requests.MethodReturnValueWatcher)1 DebuggerSession (com.intellij.debugger.impl.DebuggerSession)1 BreakpointManager (com.intellij.debugger.ui.breakpoints.BreakpointManager)1