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