メニュー
1) tombstone ファイル
2) 対応する実行可能ファイルまたはライブラリ ファイルとシンボル
3) スタック スクリプト
廃棄ファイルの生成
既製のトゥームストーン ファイルを手元に持っていない場合は、手動で作成できます。
1) ネイティブ コードに null ポインター エラーを記述し、直接クラッシュした場合は tombstone ファイルが生成されます。
2) シグナル 11 (SIGSEGV) を既存のプロセスに送信します。
3) トゥームストーン ファイルは /data/tombstones/ ディレクトリに保存されます。
例: system_server にシグナルを送信して、それを記念するトゥームストーンを生成できます。
system_server の重要性と複雑さを考慮すると、そのトゥームストーン コンテンツは非常に豊富です...
より単純なネイティブ プログラムを見つければ、生成されるトゥームストーンはより単純になります。
シンボルファイル
AOSP ソース コードでは、対応するディレクトリは次のとおりです。
out/target/product/${prod_name}/symbols/
プロジェクト情報に従って ${prod_name} を入力します。
スタック スクリプト
stack は、AOSP ソース コードと Android NDK の両方にある Python スクリプトです。
AOSP での場所:
prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.9/bin/
# stack 脚本的用法
$ stack -h
usage: stack [-h] [--arch ARCH] [--syms SYMS] [FILE]
Parse and symbolize crashes
positional arguments:
FILE should contain a stack trace in it somewhere the tool
will find that and re-print it with source files and
line numbers. If you don't pass FILE, or if file is -,
it reads from stdin.
optional arguments:
-h, --help show this help message and exit
--arch ARCH the target architecture
--syms SYMS, --symdir SYMS
the symbols directory
廃棄ファイルの解析
シンボル ファイル ディレクトリと対応するトゥームストーン ファイルをスタック スクリプトに渡します。これにより、エラーに対応するメソッド名を解決できます。
$ stack --syms ${aosp_dir}/out/target/product/${prod_name}/symbols/ ~/temp/tombstones/tombstone_25
Searching for native crashes in /home/user/temp/tombstones/tombstone_25
Reading symbols from symbols/
Revision: '0'
pid: 19272, tid: 19272, name: logcat >>> logcat <<<
signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x8
x0 000000563dd67f1d x1 0000007ffc1de546 x2 0000007ffc1db608 x3 0000000000000030
x4 0000000000000010 x5 b4000077403c0061 x6 2d20315b203a3231 x7 5d3237323931203e
x8 0000000000000000 x9 0000000000000070 x10 6d75642065726f63 x11 0000000000000008
x12 0000000000000000 x13 0a2e64656c6c6163 x14 0000007860504d22 x15 00000000fffffffe
x16 0000007860501d80 x17 0000007861a92934 x18 00000078618b6000 x19 0000007ffc1dd990
x20 0000007861b547f0 x21 0000007ffc1de546 x22 0000000000000054 x23 b4000076103b41c0
x24 0000007ffc1dbee0 x25 00000078608fb000 x26 0000000000000000 x27 b4000076103b48b0
x28 0000007ffc1dc4f0 x29 0000007ffc1dbe40
sp 0000007ffc1db990 pc 000000563dd6edfc
Using arm64 toolchain from: /home/user/code/prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.9/bin/
Stack Trace:
RELADDR FUNCTION FILE:LINE
v--------------> getLastLine(char const*) system/core/logcat/logcat.cpp:270
v--------------> getLastLogTimeString(char const*) system/core/logcat/logcat.cpp:306
000000000000edfc Logcat::RotateLogs2()+192 system/core/logcat/logcat.cpp:497
000000000000fd74 Logcat::ProcessBuffer(log_msg*)+628 system/core/logcat/logcat.cpp:637
0000000000012d34 Logcat::Run(int, char**)+11676 system/core/logcat/logcat.cpp:1600
00000000000134a4 main+268 system/core/logcat/logcat.cpp:1647
00000000000499fc __libc_init+108 bionic/libc/bionic/libc_init_dynamic.cpp:151
廃棄ファイルを手動で表示する
tombstone ファイルを直接開くためのテキスト エディター (vi、vs コード) があり、多くの基本的な有用な情報を確認することもできます。