Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android How To Read JNI Core Dump Files

I'm coding JNI application. Logcat indicates that log files exist data/log/dumpstate_app_native.txt Also stuff in system tombstones. When I access the Samsung Infuse as media device I don't see any such files. In fact I don't see my application data files either? Where are they, I do see other application packages but not much under data period. Here is what I see in logcat:

dumpstate /data/log/dumpstate_app_native.txt copying /data/tombstones/tombstone_01 to DropBox (SYSTEM_TOMBSTONE) Wrote stack traces to '/data/anr/traces.txt

I did search on device as media device for *.txt and found nothing.

like image 468
Androider Avatar asked Dec 01 '11 08:12

Androider


People also ask

How to analyze tombstone Android?

You can use the debuggerd tool to get a stack dump from a running process. From the command line, invoke debuggerd using a process ID (PID) to dump a full tombstone to stdout . To get just the stack for every thread in the process, include the -b or --backtrace flag.

How does JNI work on Android?

JNI is the Java Native Interface. It defines a way for the bytecode that Android compiles from managed code (written in the Java or Kotlin programming languages) to interact with native code (written in C/C++).

What is Tombstone PB file?

Tombstone is a file contains stack traces for all the threads in a crashing process (not just the thread that caught the signal), a full memory map, and a list of all open file descriptors.


1 Answers

You won't be able to read the tombstone files unless you are using an emulator or a rooted phone. Logcat does print out the tombstone at debug level (it's that big core dump right before the "copying tombstone" message). There should be a section that looks something like this:

01-18 16:28:04.334 16759 16759 I DEBUG   :  scr 80000012
01-18 16:28:04.334 16759 16759 I DEBUG   : 
01-18 16:28:04.384 16759 16759 I DEBUG   :          #00  pc 00007f84  /data/data/com.myapp/lib/myjnilib.so
01-18 16:28:04.384 16759 16759 I DEBUG   :          #01  pc 00008f80  /data/data/com.myapp/lib/myjnilib.so
01-18 16:28:04.394 16759 16759 I DEBUG   :          #02  pc 00002c6a  /data/data/com.myapp/lib/myjnilib.so
01-18 16:28:04.394 16759 16759 I DEBUG   :          #03  pc 00002ea8  /data/data/com.myapp/lib/myjnilib.so
01-18 16:28:04.394 16759 16759 I DEBUG   :          #04  pc 00003178  /data/data/com.myapp/lib/myjnilib.so
01-18 16:28:04.394 16759 16759 I DEBUG   :          #05  pc 00011e74  /system/lib/libdvm.so
...

This is the abbreviated stacktrace. You'll need to use the addr2line tool in the NDK to determine the function, file and line number that those hex addresses refer to. On my OSX system, the command to get the first line of the stacktrace looks like this:

/opt/android-ndk-r7/toolchains/arm-linux-androideabi-4.4.3/prebuilt/darwin-x86/bin/arm-linux-androideabi-addr2line -f -e myJNIproject/obj/local/armeabi/myjnilib.so 0x00007f84

where myJNIproject/obj/local/armeabi/myjnilib.so is the version of myjnilib.so that contains line number information.

like image 74
robinj Avatar answered Sep 23 '22 03:09

robinj