Search in sources :

Example 1 with VirtualMachineProxyImpl

use of com.intellij.debugger.jdi.VirtualMachineProxyImpl in project smali by JesusFreke.

the class LazyValue method virtualMachine.

@Override
public VirtualMachine virtualMachine() {
    if (evaluationContext != null) {
        return ((VirtualMachineProxyImpl) evaluationContext.getDebugProcess().getVirtualMachineProxy()).getVirtualMachine();
    } else {
        final DebuggerContextImpl debuggerContext = DebuggerManagerEx.getInstanceEx(project).getContext();
        final DebugProcessImpl process = debuggerContext.getDebugProcess();
        if (process != null) {
            return process.getVirtualMachineProxy().getVirtualMachine();
        }
    }
    return null;
}
Also used : VirtualMachineProxyImpl(com.intellij.debugger.jdi.VirtualMachineProxyImpl) DebugProcessImpl(com.intellij.debugger.engine.DebugProcessImpl) DebuggerContextImpl(com.intellij.debugger.impl.DebuggerContextImpl)

Example 2 with VirtualMachineProxyImpl

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

the class LambdaMethodFilter method locationMatches.

public boolean locationMatches(DebugProcessImpl process, Location location) throws EvaluateException {
    final VirtualMachineProxyImpl vm = process.getVirtualMachineProxy();
    final Method method = location.method();
    return DebuggerUtilsEx.isLambda(method) && (!vm.canGetSyntheticAttribute() || method.isSynthetic());
}
Also used : VirtualMachineProxyImpl(com.intellij.debugger.jdi.VirtualMachineProxyImpl) Method(com.sun.jdi.Method)

Example 3 with VirtualMachineProxyImpl

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

the class PositionManagerImpl method findNested.

@Nullable
private ReferenceType findNested(final ReferenceType fromClass, final int currentDepth, final PsiClass classToFind, final int requiredDepth, final SourcePosition position) {
    ApplicationManager.getApplication().assertReadAccessAllowed();
    final VirtualMachineProxyImpl vmProxy = myDebugProcess.getVirtualMachineProxy();
    if (fromClass.isPrepared()) {
        if (currentDepth < requiredDepth) {
            final List<ReferenceType> nestedTypes = vmProxy.nestedTypes(fromClass);
            for (ReferenceType nested : nestedTypes) {
                final ReferenceType found = findNested(nested, currentDepth + 1, classToFind, requiredDepth, position);
                if (found != null) {
                    return found;
                }
            }
            return null;
        }
        int rangeBegin = Integer.MAX_VALUE;
        int rangeEnd = Integer.MIN_VALUE;
        for (Location location : DebuggerUtilsEx.allLineLocations(fromClass)) {
            final int lnumber = DebuggerUtilsEx.getLineNumber(location, false);
            if (lnumber <= 1) {
                // such locations are hardly correspond to real lines in code, so skipping them too
                continue;
            }
            final Method method = DebuggerUtilsEx.getMethod(location);
            if (method == null || DebuggerUtils.isSynthetic(method) || method.isBridge()) {
                // do not take into account synthetic stuff
                continue;
            }
            int locationLine = lnumber - 1;
            PsiFile psiFile = position.getFile().getOriginalFile();
            if (psiFile instanceof PsiCompiledFile) {
                locationLine = DebuggerUtilsEx.bytecodeToSourceLine(psiFile, locationLine);
                if (locationLine < 0)
                    continue;
            }
            rangeBegin = Math.min(rangeBegin, locationLine);
            rangeEnd = Math.max(rangeEnd, locationLine);
        }
        final int positionLine = position.getLine();
        if (positionLine >= rangeBegin && positionLine <= rangeEnd) {
            // First offsets belong to parent class, and offsets inside te substring "new Runnable(){" belong to anonymous runnable.
            if (!classToFind.isValid()) {
                return null;
            }
            Set<PsiClass> lineClasses = getLineClasses(position.getFile(), rangeEnd);
            if (lineClasses.size() > 1) {
                // if there's more than one class on the line - try to match by name
                for (PsiClass aClass : lineClasses) {
                    if (classToFind.equals(aClass)) {
                        return fromClass;
                    }
                }
            } else if (!lineClasses.isEmpty()) {
                return classToFind.equals(lineClasses.iterator().next()) ? fromClass : null;
            }
            return null;
        }
    }
    return null;
}
Also used : VirtualMachineProxyImpl(com.intellij.debugger.jdi.VirtualMachineProxyImpl) Method(com.sun.jdi.Method) ReferenceType(com.sun.jdi.ReferenceType) Location(com.sun.jdi.Location) Nullable(org.jetbrains.annotations.Nullable)

Example 4 with VirtualMachineProxyImpl

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

the class ClassLoadingUtils method defineClass.

public static void defineClass(String name, byte[] bytes, EvaluationContext context, DebugProcess process, ClassLoaderReference classLoader) throws EvaluateException {
    try {
        VirtualMachineProxyImpl proxy = (VirtualMachineProxyImpl) process.getVirtualMachineProxy();
        Method defineMethod = ((ClassType) classLoader.referenceType()).concreteMethodByName("defineClass", "(Ljava/lang/String;[BII)Ljava/lang/Class;");
        StringReference nameObj = proxy.mirrorOf(name);
        DebuggerUtilsEx.keep(nameObj, context);
        process.invokeMethod(context, classLoader, defineMethod, Arrays.asList(nameObj, mirrorOf(bytes, context, process), proxy.mirrorOf(0), proxy.mirrorOf(bytes.length)));
    } catch (Exception e) {
        throw new EvaluateException("Error during class " + name + " definition: " + e, e);
    }
}
Also used : EvaluateException(com.intellij.debugger.engine.evaluation.EvaluateException) VirtualMachineProxyImpl(com.intellij.debugger.jdi.VirtualMachineProxyImpl) EvaluateException(com.intellij.debugger.engine.evaluation.EvaluateException) IOException(java.io.IOException)

Example 5 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)

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