use of com.intellij.debugger.engine.DebugProcessImpl in project kotlin by JetBrains.
the class DebuggerSteppingHelper method createStepOutCommand.
public static DebugProcessImpl.ResumeCommand createStepOutCommand(final SuspendContextImpl suspendContext, final boolean ignoreBreakpoints, final List<KtNamedFunction> inlineFunctions, final KtFunctionLiteral inlineArgument) {
final DebugProcessImpl debugProcess = suspendContext.getDebugProcess();
return debugProcess.new ResumeCommand(suspendContext) {
@Override
public void contextAction() {
try {
StackFrameProxyImpl frameProxy = suspendContext.getFrameProxy();
if (frameProxy != null) {
Action action = KotlinSteppingCommandProviderKt.getStepOutAction(frameProxy.location(), suspendContext, inlineFunctions, inlineArgument);
createStepRequest(suspendContext, getContextThread(), debugProcess.getVirtualMachineProxy().eventRequestManager(), StepRequest.STEP_LINE, StepRequest.STEP_OUT);
action.apply(debugProcess, suspendContext, ignoreBreakpoints);
return;
}
debugProcess.createStepOverCommand(suspendContext, ignoreBreakpoints).contextAction();
} catch (EvaluateException ignored) {
}
}
};
}
use of com.intellij.debugger.engine.DebugProcessImpl 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.engine.DebugProcessImpl in project intellij-community by JetBrains.
the class MethodBreakpoint method createRequestForPreparedClassEmulated.
static void createRequestForPreparedClassEmulated(@NotNull MethodBreakpointBase breakpoint, @NotNull DebugProcessImpl debugProcess, @NotNull ReferenceType classType, boolean base) {
if (!base && !shouldCreateRequest(breakpoint, breakpoint.getXBreakpoint(), debugProcess, true)) {
return;
}
try {
Method lambdaMethod = MethodBytecodeUtil.getLambdaMethod(classType, debugProcess.getVirtualMachineProxy());
StreamEx<Method> methods = lambdaMethod != null ? StreamEx.of(lambdaMethod) : breakpoint.matchingMethods(StreamEx.of(classType.methods()).filter(m -> base || !m.isAbstract()), debugProcess);
boolean found = false;
for (Method method : methods) {
found = true;
if (base && method.isNative()) {
breakpoint.disableEmulation();
return;
}
Method target = MethodBytecodeUtil.getBridgeTargetMethod(method, debugProcess.getVirtualMachineProxy());
if (target != null && !DebuggerUtilsEx.allLineLocations(target).isEmpty()) {
method = target;
}
List<Location> allLineLocations = DebuggerUtilsEx.allLineLocations(method);
if (!allLineLocations.isEmpty()) {
if (breakpoint.isWatchEntry()) {
createLocationBreakpointRequest(breakpoint, ContainerUtil.getFirstItem(allLineLocations), debugProcess);
}
if (breakpoint.isWatchExit()) {
MethodBytecodeUtil.visit(method, new MethodVisitor(Opcodes.API_VERSION) {
int myLastLine = 0;
@Override
public void visitLineNumber(int line, Label start) {
myLastLine = line;
}
@Override
public void visitInsn(int opcode) {
switch(opcode) {
case Opcodes.RETURN:
case Opcodes.IRETURN:
case Opcodes.FRETURN:
case Opcodes.ARETURN:
case Opcodes.LRETURN:
case Opcodes.DRETURN:
//case Opcodes.ATHROW:
allLineLocations.stream().filter(l -> l.lineNumber() == myLastLine).findFirst().ifPresent(location -> createLocationBreakpointRequest(breakpoint, location, debugProcess));
}
}
}, true);
}
}
}
if (base && found) {
// desired class found - now also track all new classes
createRequestForSubClasses(breakpoint, debugProcess, classType);
}
} catch (Exception e) {
LOG.debug(e);
}
}
use of com.intellij.debugger.engine.DebugProcessImpl in project intellij-community by JetBrains.
the class StackCapturingLineBreakpoint method processLocatableEvent.
@Override
public boolean processLocatableEvent(SuspendContextCommandImpl action, LocatableEvent event) throws EventProcessingException {
SuspendContextImpl suspendContext = action.getSuspendContext();
if (suspendContext != null) {
ThreadReferenceProxyImpl thread = suspendContext.getThread();
if (thread != null) {
DebugProcessImpl process = suspendContext.getDebugProcess();
try {
StackFrameProxyImpl frameProxy = ContainerUtil.getFirstItem(thread.forceFrames());
if (frameProxy != null) {
Map<Object, List<StackFrameItem>> stacks = process.getUserData(CAPTURED_STACKS);
if (stacks == null) {
stacks = new CapturedStacksMap();
process.putUserData(CAPTURED_STACKS, Collections.synchronizedMap(stacks));
}
Value key = myCaptureEvaluator.evaluate(new EvaluationContextImpl(suspendContext, frameProxy));
if (key instanceof ObjectReference) {
List<StackFrameItem> frames = StackFrameItem.createFrames(suspendContext, true);
if (frames.size() > MAX_STACK_LENGTH) {
frames = frames.subList(0, MAX_STACK_LENGTH);
}
stacks.put(getKey((ObjectReference) key), frames);
}
}
} catch (EvaluateException e) {
LOG.debug(e);
process.printToConsole(DebuggerBundle.message("error.unable.to.evaluate.capture.expression", e.getMessage()) + "\n");
}
}
}
return false;
}
use of com.intellij.debugger.engine.DebugProcessImpl in project intellij-community by JetBrains.
the class StackCapturingLineBreakpoint method getRelatedStack.
@Nullable
public static List<StackFrameItem> getRelatedStack(@NotNull StackFrameProxyImpl frame, @NotNull SuspendContextImpl suspendContext) {
DebugProcessImpl debugProcess = suspendContext.getDebugProcess();
Map<Object, List<StackFrameItem>> capturedStacks = debugProcess.getUserData(CAPTURED_STACKS);
if (ContainerUtil.isEmpty(capturedStacks)) {
return null;
}
List<StackCapturingLineBreakpoint> captureBreakpoints = debugProcess.getUserData(CAPTURE_BREAKPOINTS);
if (ContainerUtil.isEmpty(captureBreakpoints)) {
return null;
}
try {
Location location = frame.location();
String className = location.declaringType().name();
String methodName = location.method().name();
for (StackCapturingLineBreakpoint b : captureBreakpoints) {
String insertClassName = b.myCapturePoint.myInsertClassName;
if ((StringUtil.isEmpty(insertClassName) || StringUtil.equals(insertClassName, className)) && StringUtil.equals(b.myCapturePoint.myInsertMethodName, methodName)) {
try {
Value key = b.myInsertEvaluator.evaluate(new EvaluationContextImpl(suspendContext, frame));
if (key instanceof ObjectReference) {
return capturedStacks.get(getKey((ObjectReference) key));
}
} catch (EvaluateException e) {
LOG.debug(e);
debugProcess.printToConsole(DebuggerBundle.message("error.unable.to.evaluate.insert.expression", e.getMessage()) + "\n");
}
}
}
} catch (EvaluateException e) {
LOG.debug(e);
}
return null;
}
Aggregations