use of com.intellij.debugger.jdi.VirtualMachineProxyImpl in project intellij-community by JetBrains.
the class DebugProcessEvents method vmAttached.
private void vmAttached() {
DebuggerManagerThreadImpl.assertIsManagerThread();
LOG.assertTrue(!isAttached());
if (myState.compareAndSet(State.INITIAL, State.ATTACHED)) {
final VirtualMachineProxyImpl machineProxy = getVirtualMachineProxy();
final EventRequestManager requestManager = machineProxy.eventRequestManager();
if (machineProxy.canGetMethodReturnValues()) {
myReturnValueWatcher = new MethodReturnValueWatcher(requestManager);
}
final ThreadStartRequest threadStartRequest = requestManager.createThreadStartRequest();
threadStartRequest.setSuspendPolicy(EventRequest.SUSPEND_NONE);
threadStartRequest.enable();
final ThreadDeathRequest threadDeathRequest = requestManager.createThreadDeathRequest();
threadDeathRequest.setSuspendPolicy(EventRequest.SUSPEND_NONE);
threadDeathRequest.enable();
// fill position managers
((DebuggerManagerImpl) DebuggerManager.getInstance(getProject())).getCustomPositionManagerFactories().map(factory -> factory.fun(this)).filter(Objects::nonNull).forEach(this::appendPositionManager);
Stream.of(Extensions.getExtensions(PositionManagerFactory.EP_NAME, getProject())).map(factory -> factory.createPositionManager(this)).filter(Objects::nonNull).forEach(this::appendPositionManager);
myDebugProcessDispatcher.getMulticaster().processAttached(this);
createStackCapturingBreakpoints();
// breakpoints should be initialized after all processAttached listeners work
ApplicationManager.getApplication().runReadAction(() -> {
XDebugSession session = getSession().getXDebugSession();
if (session != null) {
session.initBreakpoints();
}
});
final String addressDisplayName = DebuggerBundle.getAddressDisplayName(getConnection());
final String transportName = DebuggerBundle.getTransportName(getConnection());
showStatusText(DebuggerBundle.message("status.connected", addressDisplayName, transportName));
LOG.debug("leave: processVMStartEvent()");
}
}
use of com.intellij.debugger.jdi.VirtualMachineProxyImpl in project intellij-community by JetBrains.
the class UnaryExpressionEvaluator method evaluate.
public Object evaluate(EvaluationContextImpl context) throws EvaluateException {
Value operand = (Value) myOperandEvaluator.evaluate(context);
VirtualMachineProxyImpl vm = context.getDebugProcess().getVirtualMachineProxy();
if (myOperationType == JavaTokenType.PLUS) {
if (DebuggerUtils.isNumeric(operand)) {
return operand;
}
throw EvaluateExceptionUtil.createEvaluateException(DebuggerBundle.message("evaluation.error.numeric.expected"));
} else if (myOperationType == JavaTokenType.MINUS) {
if (DebuggerUtils.isInteger(operand)) {
long v = ((PrimitiveValue) operand).longValue();
return DebuggerUtilsEx.createValue(vm, myExpectedType, -v);
}
if (DebuggerUtils.isNumeric(operand)) {
double v = ((PrimitiveValue) operand).doubleValue();
return DebuggerUtilsEx.createValue(vm, myExpectedType, -v);
}
throw EvaluateExceptionUtil.createEvaluateException(DebuggerBundle.message("evaluation.error.numeric.expected"));
} else if (myOperationType == JavaTokenType.TILDE) {
if (DebuggerUtils.isInteger(operand)) {
long v = ((PrimitiveValue) operand).longValue();
return DebuggerUtilsEx.createValue(vm, myExpectedType, ~v);
}
throw EvaluateExceptionUtil.createEvaluateException(DebuggerBundle.message("evaluation.error.integer.expected"));
} else if (myOperationType == JavaTokenType.EXCL) {
if (operand instanceof BooleanValue) {
boolean v = ((BooleanValue) operand).booleanValue();
return DebuggerUtilsEx.createValue(vm, myExpectedType, !v);
}
throw EvaluateExceptionUtil.createEvaluateException(DebuggerBundle.message("evaluation.error.boolean.expected"));
}
throw EvaluateExceptionUtil.createEvaluateException(DebuggerBundle.message("evaluation.error.operation.not.supported", myOperationText));
}
use of com.intellij.debugger.jdi.VirtualMachineProxyImpl in project intellij-community by JetBrains.
the class CompilingEvaluator method evaluate.
@Override
public Value evaluate(final EvaluationContext evaluationContext) throws EvaluateException {
DebugProcess process = evaluationContext.getDebugProcess();
EvaluationContextImpl autoLoadContext = ((EvaluationContextImpl) evaluationContext).createEvaluationContext(evaluationContext.getThisObject());
autoLoadContext.setAutoLoadClasses(true);
ClassLoaderReference classLoader = ClassLoadingUtils.getClassLoader(autoLoadContext, process);
autoLoadContext.setClassLoader(classLoader);
String version = ((VirtualMachineProxyImpl) process.getVirtualMachineProxy()).version();
Collection<ClassObject> classes = compile(JdkVersionUtil.getVersion(version));
defineClasses(classes, autoLoadContext, process, classLoader);
try {
// invoke base evaluator on call code
SourcePosition position = ContextUtil.getSourcePosition(evaluationContext);
ExpressionEvaluator evaluator = DebuggerInvocationUtil.commitAndRunReadAction(myProject, new EvaluatingComputable<ExpressionEvaluator>() {
@Override
public ExpressionEvaluator compute() throws EvaluateException {
TextWithImports callCode = getCallCode();
PsiElement copyContext = myData.getAnchor();
CodeFragmentFactory factory = DebuggerUtilsEx.findAppropriateCodeFragmentFactory(callCode, copyContext);
return factory.getEvaluatorBuilder().build(factory.createCodeFragment(callCode, copyContext, myProject), position);
}
});
return evaluator.evaluate(autoLoadContext);
} catch (Exception e) {
throw new EvaluateException("Error during generated code invocation " + e, e);
}
}
use of com.intellij.debugger.jdi.VirtualMachineProxyImpl in project intellij-community by JetBrains.
the class BinaryExpressionEvaluator method evaluateOperation.
static Object evaluateOperation(final Value leftResult, final IElementType opType, final Evaluator rightOperand, final String expectedType, final EvaluationContextImpl context) throws EvaluateException {
VirtualMachineProxyImpl vm = context.getDebugProcess().getVirtualMachineProxy();
if (leftResult instanceof BooleanValue) {
boolean v1 = ((PrimitiveValue) leftResult).booleanValue();
if (opType == JavaTokenType.OROR && v1) {
return DebuggerUtilsEx.createValue(vm, expectedType, true);
}
if (opType == JavaTokenType.ANDAND && !v1) {
return DebuggerUtilsEx.createValue(vm, expectedType, false);
}
}
Value rightResult = (Value) rightOperand.evaluate(context);
if (opType == JavaTokenType.PLUS) {
if (DebuggerUtils.isInteger(leftResult) && DebuggerUtils.isInteger(rightResult)) {
final long v1 = ((PrimitiveValue) leftResult).longValue();
final long v2 = ((PrimitiveValue) rightResult).longValue();
return DebuggerUtilsEx.createValue(vm, expectedType, v1 + v2);
}
if (DebuggerUtils.isNumeric(leftResult) && DebuggerUtils.isNumeric(rightResult)) {
final double v1 = ((PrimitiveValue) leftResult).doubleValue();
final double v2 = ((PrimitiveValue) rightResult).doubleValue();
return DebuggerUtilsEx.createValue(vm, expectedType, v1 + v2);
}
if (leftResult instanceof CharValue && rightResult instanceof CharValue) {
char v1 = ((CharValue) leftResult).charValue();
char v2 = ((CharValue) rightResult).charValue();
return DebuggerUtilsEx.createValue(vm, expectedType, v1 + v2);
}
if (leftResult instanceof StringReference || rightResult instanceof StringReference) {
String v1 = DebuggerUtils.getValueAsString(context, leftResult);
String v2 = DebuggerUtils.getValueAsString(context, rightResult);
return vm.mirrorOf(v1 + v2);
}
throw EvaluateExceptionUtil.createEvaluateException(DebuggerBundle.message("evaluation.error.incompatible.types", "+"));
} else if (opType == JavaTokenType.MINUS) {
if (DebuggerUtils.isInteger(leftResult) && DebuggerUtils.isInteger(rightResult)) {
final long v1 = ((PrimitiveValue) leftResult).longValue();
final long v2 = ((PrimitiveValue) rightResult).longValue();
return DebuggerUtilsEx.createValue(vm, expectedType, v1 - v2);
}
if (DebuggerUtils.isNumeric(leftResult) && DebuggerUtils.isNumeric(rightResult)) {
double v1 = ((PrimitiveValue) leftResult).doubleValue();
double v2 = ((PrimitiveValue) rightResult).doubleValue();
return DebuggerUtilsEx.createValue(vm, expectedType, v1 - v2);
}
if (leftResult instanceof CharValue && rightResult instanceof CharValue) {
char v1 = ((CharValue) leftResult).charValue();
char v2 = ((CharValue) rightResult).charValue();
return DebuggerUtilsEx.createValue(vm, expectedType, v1 - v2);
}
throw EvaluateExceptionUtil.createEvaluateException(DebuggerBundle.message("evaluation.error.incompatible.types", "-"));
} else if (opType == JavaTokenType.ASTERISK) {
if (DebuggerUtils.isInteger(leftResult) && DebuggerUtils.isInteger(rightResult)) {
final long v1 = ((PrimitiveValue) leftResult).longValue();
final long v2 = ((PrimitiveValue) rightResult).longValue();
return DebuggerUtilsEx.createValue(vm, expectedType, v1 * v2);
}
if (DebuggerUtils.isNumeric(leftResult) && DebuggerUtils.isNumeric(rightResult)) {
double v1 = ((PrimitiveValue) leftResult).doubleValue();
double v2 = ((PrimitiveValue) rightResult).doubleValue();
return DebuggerUtilsEx.createValue(vm, expectedType, v1 * v2);
}
if (leftResult instanceof CharValue && rightResult instanceof CharValue) {
char v1 = ((CharValue) leftResult).charValue();
char v2 = ((CharValue) rightResult).charValue();
return DebuggerUtilsEx.createValue(vm, expectedType, v1 * v2);
}
throw EvaluateExceptionUtil.createEvaluateException(DebuggerBundle.message("evaluation.error.incompatible.types", "*"));
} else if (opType == JavaTokenType.DIV) {
if (DebuggerUtils.isInteger(leftResult) && DebuggerUtils.isInteger(rightResult)) {
long v1 = ((PrimitiveValue) leftResult).longValue();
long v2 = ((PrimitiveValue) rightResult).longValue();
return DebuggerUtilsEx.createValue(vm, expectedType, v1 / v2);
}
if (DebuggerUtils.isNumeric(leftResult) && DebuggerUtils.isNumeric(rightResult)) {
double v1 = ((PrimitiveValue) leftResult).doubleValue();
double v2 = ((PrimitiveValue) rightResult).doubleValue();
return DebuggerUtilsEx.createValue(vm, expectedType, v1 / v2);
}
if (leftResult instanceof CharValue && rightResult instanceof CharValue) {
char v1 = ((CharValue) leftResult).charValue();
char v2 = ((CharValue) rightResult).charValue();
return DebuggerUtilsEx.createValue(vm, expectedType, v1 / v2);
}
throw EvaluateExceptionUtil.createEvaluateException(DebuggerBundle.message("evaluation.error.incompatible.types", "/"));
} else if (opType == JavaTokenType.PERC) {
if (DebuggerUtils.isInteger(leftResult) && DebuggerUtils.isInteger(rightResult)) {
long v1 = ((PrimitiveValue) leftResult).longValue();
long v2 = ((PrimitiveValue) rightResult).longValue();
return DebuggerUtilsEx.createValue(vm, expectedType, v1 % v2);
}
if (DebuggerUtils.isNumeric(leftResult) && DebuggerUtils.isNumeric(rightResult)) {
double v1 = ((PrimitiveValue) leftResult).doubleValue();
double v2 = ((PrimitiveValue) rightResult).doubleValue();
return DebuggerUtilsEx.createValue(vm, expectedType, v1 % v2);
}
if (leftResult instanceof CharValue && rightResult instanceof CharValue) {
char v1 = ((CharValue) leftResult).charValue();
char v2 = ((CharValue) rightResult).charValue();
return DebuggerUtilsEx.createValue(vm, expectedType, v1 % v2);
}
throw EvaluateExceptionUtil.createEvaluateException(DebuggerBundle.message("evaluation.error.incompatible.types", "%"));
} else if (opType == JavaTokenType.LTLT) {
if (DebuggerUtils.isInteger(leftResult) && DebuggerUtils.isInteger(rightResult)) {
final long v2 = ((PrimitiveValue) rightResult).longValue();
if (leftResult instanceof ByteValue) {
return DebuggerUtilsEx.createValue(vm, expectedType, ((ByteValue) leftResult).byteValue() << v2);
} else if (leftResult instanceof ShortValue) {
return DebuggerUtilsEx.createValue(vm, expectedType, ((ShortValue) leftResult).shortValue() << v2);
} else if (leftResult instanceof IntegerValue) {
return DebuggerUtilsEx.createValue(vm, expectedType, ((IntegerValue) leftResult).intValue() << v2);
}
return DebuggerUtilsEx.createValue(vm, expectedType, ((PrimitiveValue) leftResult).longValue() << v2);
}
if (leftResult instanceof CharValue && rightResult instanceof CharValue) {
return DebuggerUtilsEx.createValue(vm, expectedType, ((CharValue) leftResult).charValue() << ((CharValue) rightResult).charValue());
}
throw EvaluateExceptionUtil.createEvaluateException(DebuggerBundle.message("evaluation.error.incompatible.types", "<<"));
} else if (opType == JavaTokenType.GTGT) {
if (DebuggerUtils.isInteger(leftResult) && DebuggerUtils.isInteger(rightResult)) {
final long v2 = ((PrimitiveValue) rightResult).longValue();
if (leftResult instanceof ByteValue) {
return DebuggerUtilsEx.createValue(vm, expectedType, ((ByteValue) leftResult).byteValue() >> v2);
} else if (leftResult instanceof ShortValue) {
return DebuggerUtilsEx.createValue(vm, expectedType, ((ShortValue) leftResult).shortValue() >> v2);
} else if (leftResult instanceof IntegerValue) {
return DebuggerUtilsEx.createValue(vm, expectedType, ((IntegerValue) leftResult).intValue() >> v2);
}
return DebuggerUtilsEx.createValue(vm, expectedType, ((PrimitiveValue) leftResult).longValue() >> v2);
}
if (leftResult instanceof CharValue && rightResult instanceof CharValue) {
return DebuggerUtilsEx.createValue(vm, expectedType, ((CharValue) leftResult).charValue() >> ((CharValue) rightResult).charValue());
}
throw EvaluateExceptionUtil.createEvaluateException(DebuggerBundle.message("evaluation.error.incompatible.types", ">>"));
} else if (opType == JavaTokenType.GTGTGT) {
if (DebuggerUtils.isInteger(leftResult) && DebuggerUtils.isInteger(rightResult)) {
final long v2 = ((PrimitiveValue) rightResult).longValue();
if (leftResult instanceof ByteValue) {
return DebuggerUtilsEx.createValue(vm, expectedType, ((ByteValue) leftResult).byteValue() >>> v2);
} else if (leftResult instanceof ShortValue) {
return DebuggerUtilsEx.createValue(vm, expectedType, ((ShortValue) leftResult).shortValue() >>> v2);
} else if (leftResult instanceof IntegerValue) {
return DebuggerUtilsEx.createValue(vm, expectedType, ((IntegerValue) leftResult).intValue() >>> v2);
}
return DebuggerUtilsEx.createValue(vm, expectedType, ((PrimitiveValue) leftResult).longValue() >>> v2);
}
if (leftResult instanceof CharValue && rightResult instanceof CharValue) {
return DebuggerUtilsEx.createValue(vm, expectedType, ((CharValue) leftResult).charValue() >>> ((CharValue) rightResult).charValue());
}
throw EvaluateExceptionUtil.createEvaluateException(DebuggerBundle.message("evaluation.error.incompatible.types", ">>>"));
} else if (opType == JavaTokenType.AND) {
if (DebuggerUtils.isInteger(leftResult) && DebuggerUtils.isInteger(rightResult)) {
long v1 = ((PrimitiveValue) leftResult).longValue();
long v2 = ((PrimitiveValue) rightResult).longValue();
return DebuggerUtilsEx.createValue(vm, expectedType, v1 & v2);
}
if (leftResult instanceof CharValue && rightResult instanceof CharValue) {
char v1 = ((CharValue) leftResult).charValue();
char v2 = ((CharValue) rightResult).charValue();
return DebuggerUtilsEx.createValue(vm, expectedType, v1 & v2);
}
if (leftResult instanceof BooleanValue && rightResult instanceof BooleanValue) {
boolean v1 = ((PrimitiveValue) leftResult).booleanValue();
boolean v2 = ((PrimitiveValue) rightResult).booleanValue();
return DebuggerUtilsEx.createValue(vm, expectedType, v1 & v2);
}
throw EvaluateExceptionUtil.createEvaluateException(DebuggerBundle.message("evaluation.error.incompatible.types", "&"));
} else if (opType == JavaTokenType.OR) {
if (DebuggerUtils.isInteger(leftResult) && DebuggerUtils.isInteger(rightResult)) {
long v1 = ((PrimitiveValue) leftResult).longValue();
long v2 = ((PrimitiveValue) rightResult).longValue();
return DebuggerUtilsEx.createValue(vm, expectedType, v1 | v2);
}
if (leftResult instanceof CharValue && rightResult instanceof CharValue) {
char v1 = ((CharValue) leftResult).charValue();
char v2 = ((CharValue) rightResult).charValue();
return DebuggerUtilsEx.createValue(vm, expectedType, v1 | v2);
}
if (leftResult instanceof BooleanValue && rightResult instanceof BooleanValue) {
boolean v1 = ((PrimitiveValue) leftResult).booleanValue();
boolean v2 = ((PrimitiveValue) rightResult).booleanValue();
return DebuggerUtilsEx.createValue(vm, expectedType, v1 | v2);
}
throw EvaluateExceptionUtil.createEvaluateException(DebuggerBundle.message("evaluation.error.incompatible.types", "|"));
} else if (opType == JavaTokenType.XOR) {
if (DebuggerUtils.isInteger(leftResult) && DebuggerUtils.isInteger(rightResult)) {
long v1 = ((PrimitiveValue) leftResult).longValue();
long v2 = ((PrimitiveValue) rightResult).longValue();
return DebuggerUtilsEx.createValue(vm, expectedType, v1 ^ v2);
}
if (leftResult instanceof CharValue && rightResult instanceof CharValue) {
char v1 = ((CharValue) leftResult).charValue();
char v2 = ((CharValue) rightResult).charValue();
return DebuggerUtilsEx.createValue(vm, expectedType, v1 ^ v2);
}
if (leftResult instanceof BooleanValue && rightResult instanceof BooleanValue) {
boolean v1 = ((PrimitiveValue) leftResult).booleanValue();
boolean v2 = ((PrimitiveValue) rightResult).booleanValue();
return DebuggerUtilsEx.createValue(vm, expectedType, v1 ^ v2);
}
throw EvaluateExceptionUtil.createEvaluateException(DebuggerBundle.message("evaluation.error.incompatible.types", "^"));
} else if (opType == JavaTokenType.EQEQ) {
if (leftResult == null && rightResult == null) {
return DebuggerUtilsEx.createValue(vm, expectedType, true);
}
if (leftResult == null) {
return DebuggerUtilsEx.createValue(vm, expectedType, rightResult.equals(null));
}
if (rightResult == null) {
return DebuggerUtilsEx.createValue(vm, expectedType, leftResult.equals(null));
}
if (DebuggerUtils.isInteger(leftResult) && DebuggerUtils.isInteger(rightResult)) {
final long v1 = ((PrimitiveValue) leftResult).longValue();
final long v2 = ((PrimitiveValue) rightResult).longValue();
return DebuggerUtilsEx.createValue(vm, expectedType, v1 == v2);
}
if (DebuggerUtils.isNumeric(leftResult) && DebuggerUtils.isNumeric(rightResult)) {
double v1 = ((PrimitiveValue) leftResult).doubleValue();
double v2 = ((PrimitiveValue) rightResult).doubleValue();
return DebuggerUtilsEx.createValue(vm, expectedType, v1 == v2);
}
if (leftResult instanceof BooleanValue && rightResult instanceof BooleanValue) {
boolean v1 = ((PrimitiveValue) leftResult).booleanValue();
boolean v2 = ((PrimitiveValue) rightResult).booleanValue();
return DebuggerUtilsEx.createValue(vm, expectedType, v1 == v2);
}
if (leftResult instanceof CharValue && rightResult instanceof CharValue) {
char v1 = ((CharValue) leftResult).charValue();
char v2 = ((CharValue) rightResult).charValue();
return DebuggerUtilsEx.createValue(vm, expectedType, v1 == v2);
}
if (leftResult instanceof ObjectReference && rightResult instanceof ObjectReference) {
ObjectReference v1 = (ObjectReference) leftResult;
ObjectReference v2 = (ObjectReference) rightResult;
return DebuggerUtilsEx.createValue(vm, expectedType, v1.uniqueID() == v2.uniqueID());
}
throw EvaluateExceptionUtil.createEvaluateException(DebuggerBundle.message("evaluation.error.incompatible.types", "=="));
} else if (opType == JavaTokenType.OROR) {
if (leftResult instanceof BooleanValue && rightResult instanceof BooleanValue) {
boolean v1 = ((PrimitiveValue) leftResult).booleanValue();
boolean v2 = ((PrimitiveValue) rightResult).booleanValue();
return DebuggerUtilsEx.createValue(vm, expectedType, v1 || v2);
}
throw EvaluateExceptionUtil.createEvaluateException(DebuggerBundle.message("evaluation.error.incompatible.types", "||"));
} else if (opType == JavaTokenType.ANDAND) {
if (leftResult instanceof BooleanValue && rightResult instanceof BooleanValue) {
boolean v1 = ((PrimitiveValue) leftResult).booleanValue();
boolean v2 = ((PrimitiveValue) rightResult).booleanValue();
return DebuggerUtilsEx.createValue(vm, expectedType, v1 && v2);
}
throw EvaluateExceptionUtil.createEvaluateException(DebuggerBundle.message("evaluation.error.incompatible.types", "&&"));
} else if (opType == JavaTokenType.NE) {
if (leftResult == null && rightResult == null)
return DebuggerUtilsEx.createValue(vm, expectedType, false);
if (leftResult == null)
return DebuggerUtilsEx.createValue(vm, expectedType, !rightResult.equals(null));
if (rightResult == null)
return DebuggerUtilsEx.createValue(vm, expectedType, !leftResult.equals(null));
if (DebuggerUtils.isInteger(leftResult) && DebuggerUtils.isInteger(rightResult)) {
final long v1 = ((PrimitiveValue) leftResult).longValue();
final long v2 = ((PrimitiveValue) rightResult).longValue();
return DebuggerUtilsEx.createValue(vm, expectedType, v1 != v2);
}
if (DebuggerUtils.isNumeric(leftResult) && DebuggerUtils.isNumeric(rightResult)) {
double v1 = ((PrimitiveValue) leftResult).doubleValue();
double v2 = ((PrimitiveValue) rightResult).doubleValue();
return DebuggerUtilsEx.createValue(vm, expectedType, v1 != v2);
}
if (leftResult instanceof BooleanValue && rightResult instanceof BooleanValue) {
boolean v1 = ((PrimitiveValue) leftResult).booleanValue();
boolean v2 = ((PrimitiveValue) rightResult).booleanValue();
return DebuggerUtilsEx.createValue(vm, expectedType, v1 != v2);
}
if (leftResult instanceof CharValue && rightResult instanceof CharValue) {
char v1 = ((CharValue) leftResult).charValue();
char v2 = ((CharValue) rightResult).charValue();
return DebuggerUtilsEx.createValue(vm, expectedType, v1 != v2);
}
if (leftResult instanceof ObjectReference && rightResult instanceof ObjectReference) {
ObjectReference v1 = (ObjectReference) leftResult;
ObjectReference v2 = (ObjectReference) rightResult;
return DebuggerUtilsEx.createValue(vm, expectedType, v1.uniqueID() != v2.uniqueID());
}
throw EvaluateExceptionUtil.createEvaluateException(DebuggerBundle.message("evaluation.error.incompatible.types", "!="));
} else if (opType == JavaTokenType.LT) {
if (DebuggerUtils.isInteger(leftResult) && DebuggerUtils.isInteger(rightResult)) {
final long v1 = ((PrimitiveValue) leftResult).longValue();
final long v2 = ((PrimitiveValue) rightResult).longValue();
return DebuggerUtilsEx.createValue(vm, expectedType, v1 < v2);
}
if (DebuggerUtils.isNumeric(leftResult) && DebuggerUtils.isNumeric(rightResult)) {
double v1 = ((PrimitiveValue) leftResult).doubleValue();
double v2 = ((PrimitiveValue) rightResult).doubleValue();
return DebuggerUtilsEx.createValue(vm, expectedType, v1 < v2);
}
if (leftResult instanceof CharValue && rightResult instanceof CharValue) {
char v1 = ((CharValue) leftResult).charValue();
char v2 = ((CharValue) rightResult).charValue();
return DebuggerUtilsEx.createValue(vm, expectedType, v1 < v2);
}
throw EvaluateExceptionUtil.createEvaluateException(DebuggerBundle.message("evaluation.error.incompatible.types", "<"));
} else if (opType == JavaTokenType.GT) {
if (DebuggerUtils.isInteger(leftResult) && DebuggerUtils.isInteger(rightResult)) {
final long v1 = ((PrimitiveValue) leftResult).longValue();
final long v2 = ((PrimitiveValue) rightResult).longValue();
return DebuggerUtilsEx.createValue(vm, expectedType, v1 > v2);
}
if (DebuggerUtils.isNumeric(leftResult) && DebuggerUtils.isNumeric(rightResult)) {
double v1 = ((PrimitiveValue) leftResult).doubleValue();
double v2 = ((PrimitiveValue) rightResult).doubleValue();
return DebuggerUtilsEx.createValue(vm, expectedType, v1 > v2);
}
if (leftResult instanceof CharValue && rightResult instanceof CharValue) {
char v1 = ((CharValue) leftResult).charValue();
char v2 = ((CharValue) rightResult).charValue();
return DebuggerUtilsEx.createValue(vm, expectedType, v1 > v2);
}
throw EvaluateExceptionUtil.createEvaluateException(DebuggerBundle.message("evaluation.error.incompatible.types", ">"));
} else if (opType == JavaTokenType.LE) {
if (DebuggerUtils.isInteger(leftResult) && DebuggerUtils.isInteger(rightResult)) {
final long v1 = ((PrimitiveValue) leftResult).longValue();
final long v2 = ((PrimitiveValue) rightResult).longValue();
return DebuggerUtilsEx.createValue(vm, expectedType, v1 <= v2);
}
if (DebuggerUtils.isNumeric(leftResult) && DebuggerUtils.isNumeric(rightResult)) {
double v1 = ((PrimitiveValue) leftResult).doubleValue();
double v2 = ((PrimitiveValue) rightResult).doubleValue();
return DebuggerUtilsEx.createValue(vm, expectedType, v1 <= v2);
}
if (leftResult instanceof CharValue && rightResult instanceof CharValue) {
char v1 = ((CharValue) leftResult).charValue();
char v2 = ((CharValue) rightResult).charValue();
return DebuggerUtilsEx.createValue(vm, expectedType, v1 <= v2);
}
throw EvaluateExceptionUtil.createEvaluateException(DebuggerBundle.message("evaluation.error.incompatible.types", "<="));
} else if (opType == JavaTokenType.GE) {
if (DebuggerUtils.isInteger(leftResult) && DebuggerUtils.isInteger(rightResult)) {
final long v1 = ((PrimitiveValue) leftResult).longValue();
final long v2 = ((PrimitiveValue) rightResult).longValue();
return DebuggerUtilsEx.createValue(vm, expectedType, v1 >= v2);
}
if (DebuggerUtils.isNumeric(leftResult) && DebuggerUtils.isNumeric(rightResult)) {
double v1 = ((PrimitiveValue) leftResult).doubleValue();
double v2 = ((PrimitiveValue) rightResult).doubleValue();
return DebuggerUtilsEx.createValue(vm, expectedType, v1 >= v2);
}
if (leftResult instanceof CharValue && rightResult instanceof CharValue) {
char v1 = ((CharValue) leftResult).charValue();
char v2 = ((CharValue) rightResult).charValue();
return DebuggerUtilsEx.createValue(vm, expectedType, v1 >= v2);
}
throw EvaluateExceptionUtil.createEvaluateException(DebuggerBundle.message("evaluation.error.incompatible.types", ">="));
}
LOG.assertTrue(false);
return null;
}
use of com.intellij.debugger.jdi.VirtualMachineProxyImpl in project intellij-community by JetBrains.
the class ThreadDumpAction method actionPerformed.
public void actionPerformed(AnActionEvent e) {
final Project project = e.getProject();
if (project == null) {
return;
}
DebuggerContextImpl context = (DebuggerManagerEx.getInstanceEx(project)).getContext();
final DebuggerSession session = context.getDebuggerSession();
if (session != null && session.isAttached()) {
final DebugProcessImpl process = context.getDebugProcess();
process.getManagerThread().invoke(new DebuggerCommandImpl() {
protected void action() throws Exception {
final VirtualMachineProxyImpl vm = process.getVirtualMachineProxy();
vm.suspend();
try {
final List<ThreadState> threads = buildThreadStates(vm);
ApplicationManager.getApplication().invokeLater(() -> {
XDebugSession xSession = session.getXDebugSession();
if (xSession != null) {
DebuggerUtilsEx.addThreadDump(project, threads, xSession.getUI(), session);
}
}, ModalityState.NON_MODAL);
} finally {
vm.resume();
}
}
});
}
}
Aggregations