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;
}
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());
}
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;
}
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);
}
}
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;
}
Aggregations