我在Android上运行的C ++ codeBase的,并希望有用户发送崩溃报告。
I have C++ codebase running on Android, and want to have crash reports sent by users.
我使用 ACRA库这对于Java的code工作正常,但是当事情崩溃在本土code,我没有得到足够的信息。其实我想收到的本地函数调用堆栈跟踪。我知道崩溃信息印刷成我的logcat过程结束后,我可以配置ACRA读/发送logcat的。我设置我的code。使用信号处理程序并调用回Java通过ACRA报告来检测本机毁人亡。它的工作原理也很好。
I'm using ACRA library which works fine for Java code, but when something crashes in native code, I don't get enough information. Actually I'd like to receive stack trace of native function calls. I know crash info is printed into logcat after my process ends, and I can configure ACRA to read/send logcat. I've setup my code to detect native crash using signal handlers and calling back to Java for reporting by ACRA. It works also fine.
不过有这种方法错误的时机 - ACRA读取日志而崩溃的过程仍然活着,和Android(不知道到底是哪一部分)写入崩溃报告的logcat后坠毁过程完全结束。因此,我不使用ACRA时收到的堆栈跟踪。
However there's bad timing with this approach - ACRA reads logs while crashing process is still alive, and Android (don't know exactly which part) writes crash report to logcat after crashed process completely ends. So I don't receive stack traces when using ACRA.
所以我在寻找一种方法以编程方式从C ++ code读取当前的堆栈跟踪,并满足这种信息,以ACRA(或者其他的崩溃报告工具)我自己。
So I'm looking for a way to programatically read current stack trace from C++ code, and feed this info to ACRA (or maybe other crash reporting tool) myself.
我需要的是某种形式的这份报告写的logcat的:
All I need is some kind of this report written to logcat:
10-10 08:29:13.868: INFO/DEBUG(1121): #00 pc 0003fc7c /data/data/com.ex.lib/libapp.so
10-10 08:29:13.891: INFO/DEBUG(1121): #04 pc 00016df4 /system/lib/libdvm.so
10-10 08:29:13.891: INFO/DEBUG(1121): #05 pc 00045284 /system/lib/libdvm.so
10-10 08:29:13.899: INFO/DEBUG(1121): #15 pc 00047c56 /system/lib/libdvm.so
10-10 08:29:13.922: INFO/DEBUG(1121): #16 pc 00030e4c /system/lib/libandroid_runtime.so
有没有办法从我的code得到这个堆栈跟踪?
Is there any way to get this stack trace from my code?
我在游戏基地项目做到了这一点 - 你可以看到JNI code此位置处理:
I have done this in my game base project - you can see the JNI code which handles this here:
https://bitbucket.org/xg/android-game-base/src/c0d969d44a55/jni/NativeActivityJNI.cpp#cl-40
它调用这里定义的Java方法:
which calls the Java method defined here:
https://bitbucket.org/xg/android-game-base/src/c0d969d44a55/src/com/gmail/whittock/tom/Util/NativeActivity.java#cl-91
整体解决方案是基于处理信号,然后在信号处理程序烧成召集到Java转储堆栈跟踪等,在我的code,我开始另一项活动得到了logcat的信息,并通过电子邮件发送给我
The overall solution is based on handling signals, then in the signal handler firing a call up to java to dump the stack trace etc, in my code I start another activity to get the logcat information and email it to me.