Android - Generate Java stack trace in native code

       I had to fetch the java stack trace from native code which happened to throw an exception upon a failure. Unfortunately, this particular native function had multiple entry points from Java and a tombstone only helped find the native stack trace and not the java stack trace. All that was needed, was to send SIGNAL_QUIT to the current process and that was already being handled by dalvik virtual machine hosting the application. The threads are suspended and the java stack trace is saved in /data/anr/traces.txt


                   kill(getpid(), 3);

No comments: