use of com.intellij.debugger.engine.jdi.StackFrameProxy in project smali by JesusFreke.
the class SmaliCodeFragmentFactory method evaluateRegister.
@Nullable
public static Value evaluateRegister(EvaluationContext context, final SmaliMethod smaliMethod, final int registerNum, final String type) throws EvaluateException {
if (registerNum >= smaliMethod.getRegisterCount()) {
return null;
}
final StackFrameProxy frameProxy = context.getSuspendContext().getFrameProxy();
if (frameProxy == null) {
return null;
}
VirtualMachine vm = frameProxy.getStackFrame().virtualMachine();
Location currentLocation = frameProxy.location();
if (currentLocation == null) {
return null;
}
Method method = currentLocation.method();
try {
final Constructor<LocalVariableImpl> localVariableConstructor = LocalVariableImpl.class.getDeclaredConstructor(VirtualMachine.class, Method.class, Integer.TYPE, Location.class, Location.class, String.class, String.class, String.class);
localVariableConstructor.setAccessible(true);
Constructor<LocationImpl> locationConstructor = LocationImpl.class.getDeclaredConstructor(VirtualMachine.class, Method.class, Long.TYPE);
locationConstructor.setAccessible(true);
int methodSize = 0;
for (SmaliInstruction instruction : smaliMethod.getInstructions()) {
methodSize += instruction.getInstructionSize();
}
Location endLocation = null;
for (int endCodeIndex = (methodSize / 2) - 1; endCodeIndex >= 0; endCodeIndex--) {
endLocation = method.locationOfCodeIndex(endCodeIndex);
if (endLocation != null) {
break;
}
}
if (endLocation == null) {
return null;
}
LocalVariable localVariable = localVariableConstructor.newInstance(vm, method, mapRegister(frameProxy.getStackFrame().virtualMachine(), smaliMethod, registerNum), method.location(), endLocation, String.format("v%d", registerNum), type, null);
return frameProxy.getStackFrame().getValue(localVariable);
} catch (NoSuchMethodException e) {
return null;
} catch (InstantiationException e) {
return null;
} catch (IllegalAccessException e) {
return null;
} catch (InvocationTargetException e) {
return null;
}
}
use of com.intellij.debugger.engine.jdi.StackFrameProxy in project intellij-community by JetBrains.
the class ContextUtil method getSourcePosition.
@Nullable
public static SourcePosition getSourcePosition(@Nullable final StackFrameContext context) {
if (context == null) {
return null;
}
DebugProcessImpl debugProcess = (DebugProcessImpl) context.getDebugProcess();
if (debugProcess == null) {
return null;
}
final StackFrameProxy frameProxy = context.getFrameProxy();
if (frameProxy == null) {
return null;
}
Location location = null;
try {
location = frameProxy.location();
} catch (Throwable e) {
LOG.debug(e);
}
if (location == null) {
return null;
}
return debugProcess.getPositionManager().getSourcePosition(location);
}
use of com.intellij.debugger.engine.jdi.StackFrameProxy in project intellij-community by JetBrains.
the class DescriptorTestCase method localVar.
protected LocalVariableDescriptorImpl localVar(DebuggerTree frameTree, EvaluationContextImpl evaluationContext, String name) {
try {
StackFrameProxy frameProxy = evaluationContext.getFrameProxy();
assert frameProxy != null;
LocalVariableDescriptorImpl local = frameTree.getNodeFactory().getLocalVariableDescriptor(null, frameProxy.visibleVariableByName(name));
local.setContext(evaluationContext);
return local;
} catch (EvaluateException e) {
error(e);
return null;
}
}
Aggregations