in src/main/java/com/intellij/rt/debugger/agent/ThrowableTransformer.java [27:62]
public MethodVisitor visitMethod(final int access, String name, String descriptor, String signature, String[] exceptions) {
MethodVisitor superMethodVisitor = super.visitMethod(access, name, descriptor, signature, exceptions);
switch (name) {
case "<init>":
// Insert call of CaptureStorage.captureThrowable(this) in the end of constructors.
return new MethodVisitor(api, superMethodVisitor) {
@Override
public void visitInsn(int opcode) {
if (opcode == Opcodes.RETURN) {
mv.visitVarInsn(Opcodes.ALOAD, 0);
CaptureAgent.invokeStorageMethod(mv, "captureThrowable");
}
super.visitInsn(opcode);
}
};
case "printStackTrace":
case "lockedPrintStackTrace":
case "printEnclosedStackTrace":
// Replace getOurStackTrace() call with CaptureStorage.getAsyncStackTrace()
// during all kinds of stack trace printing.
return new MethodVisitor(api, superMethodVisitor) {
@Override
public void visitMethodInsn(int opcode, String owner, String name, String descriptor, boolean isInterface) {
if (name.equals("getOurStackTrace")) {
CaptureAgent.invokeStorageMethod(mv, "getAsyncStackTrace");
} else {
super.visitMethodInsn(opcode, owner, name, descriptor, isInterface);
}
}
};
default:
return superMethodVisitor;
}
}