Native code - how to get function call stack (backtrace) programmatically

前端 未结 2 696
感情败类
感情败类 2021-02-18 13:41

I have C++ codebase running on Android, and want to have crash reports sent by users.

I\'m using ACRA library which works fine for Java code, but when something crashes

2条回答
  •  一生所求
    2021-02-18 14:17

    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

    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

    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.

提交回复
热议问题