读书人

今日排错用到的一个btrace脚本

发布时间: 2012-12-23 11:28:15 作者: rapoo

今天排错用到的一个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;}    }}

读书人网 >编程

热点推荐