Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I get a C++ stack trace when Android app crashes?

Most of the errors that occur in my C++ code cause the app to simply exit, with no LogCat output whatsoever, and no message on the device. Null pointers and incorrect use of JNI often produce this result, and needless to say, it makes debugging very hard.

Currently I can get a stack trace with the 'bt' command in ndk-gdb, but not if the crash occurs within the first 2 seconds of startup, because ndk-gdb starts the process and attaches to it after it has started. Plus, ndk-gdb is unreliable, often saying it can't find any symbols, or complaining about nonfatal "SIGILL" errors, for example.

Is there a way to trap the error and print a stack trace, or other information when an app crashes? For example, if there was a SIGSEGV, I'd like to know which address the app was trying to access.

like image 858
Qwertie Avatar asked Jun 25 '12 18:06

Qwertie


1 Answers

trace.txt file give something ? I don't remember if his location is : /data/anr/trace.txt or /data/data/{pkg}/trace.txt

like image 160
xunien Avatar answered Oct 03 '22 18:10

xunien