Log the native backtrace when exception throws#3960
Log the native backtrace when exception throws#3960
Conversation
It is always a pain for us that after converting c++ exception to java's, all the native backtrace just lost. This tries to hook into the __cxa_throw to log the native backtrace PCs when exception throws. The pc address can be then decoded through addr2line like: addr2line -C -f -e librealm-jni.so 0xa0293 0xa0548 0xb8cd1 0x3acb3 0x15611
|
It might be worth comparing with https://github.com/realm/realm-core/blob/master/src/realm/util/terminate.cpp |
|
We must also investigate how it works together with Crashlytics: https://docs.fabric.io/android/crashlytics/ndk.html |
| @@ -0,0 +1,65 @@ | |||
| #include <unwind.h> | |||
There was a problem hiding this comment.
Does API < 16 have libunwind?
There was a problem hiding this comment.
Did you see anything about the API 16 with libunwind? I cannot find too much information about that.
But! https://code.google.com/p/android/issues/detail?id=199936
libunwind is not an NDK API. even if you get this to work now, in future releases you will be prevented from linking against libunwind at runtime.
:( :( :(
There was a problem hiding this comment.
unwind.h exists in both R10e and R13b.
There was a problem hiding this comment.
|
Despite my concerns and comments, I like the idea! |
|
According to http://stackoverflow.com/a/35585744/1396606 , it seems it is safe for us to use |
|
Some ideas in #813 |
|
I think I have heard rumours that the NDK team is working on a new |
It is always a pain for us that after converting c++ exception to
java's, all the native backtrace just lost.
This tries to hook into the __cxa_throw to log the native backtrace PCs
when exception throws.
The pc address can be then decoded through addr2line like:
addr2line -C -f -e librealm-jni.so 0xa0293 0xa0548 0xb8cd1 0x3acb3 0x15611
A more wicked idea would be totally implement a __cxa_throw function and
convert exceptions from there and unwind the callstack to where JNI borders
then return to java peacefully. It seems to be doable and we can get rid of
the
try CATCHSTDblocks for every JNI call. Need more investigations.