android ndk调用Log.getStackTraceString(new Throwable())输出堆栈信息
16lz
2021-12-04
//String str = Log.getStackTraceString(new Throwable());//Log.d("yunshouhu", str);jclass jcl_Log = (*env)->FindClass(env, "android/util/Log");jmethodID mid_getStackTraceString = (*env)->GetStaticMethodID(env, jcl_Log, "getStackTraceString", "(Ljava/lang/Throwable;)Ljava/lang/String;");jclass cls_Throwable = (*env)->FindClass( env, "java/lang/Throwable");jmethodID fn_Throwable = (*env)->GetMethodID(env, cls_Throwable, "", "()V" );jobject obj_Throwable = (*env)->NewObject(env, cls_Throwable, fn_Throwable);jstring trace = (*env)->CallStaticObjectMethod(env, jcl_Log, mid_getStackTraceString,obj_Throwable);const char *trace_str = (*env)->GetStringUTFChars(env, trace, 0);LOGI("%s",trace_str);(*env)->DeleteLocalRef(env, jcl_Log);(*env)->DeleteLocalRef(env, cls_Throwable);(*env)->DeleteLocalRef(env, obj_Throwable);(*env)->ReleaseStringUTFChars(env, trace, trace_str);(*env)->DeleteLocalRef(env,trace);
更多相关文章
- 代码中设置drawableleft
- android 3.0 隐藏 系统标题栏
- Android开发中activity切换动画的实现
- Android(安卓)学习 笔记_05. 文件下载
- Android中直播视频技术探究之—摄像头Camera视频源数据采集解析
- 技术博客汇总
- android 2.3 wifi (一)
- AndRoid Notification的清空和修改
- Android中的Chronometer