今天排错用到的一个btrace脚本
觉得优雅的封装错误 是一门艺术 要学习学习。
@BTracepublic class InvokeMethodTrace { @TLS static Throwable remotingException; @TLS static String msg; @OnMethod(clazz = "java.lang.Throwable", method = "<init>") public static void onThrownRemotingException(@Self Throwable self, String arg) {msg = arg;remotingException = self; } @OnMethod(clazz = "java.lang.Throwable", method = "<init>", location = @Location(Kind.RETURN)) public static void onthrowreturn() {if (remotingException != null) { println("====================="); println(concat("java.lang.Throwable msg:", msg)); println("=====thread stack====="); jstack(remotingException); println("====================="); remotingException = null;} }}