1 page.title=ndk-stack 2 @jd:body 3 4 <div id="qv-wrapper"> 5 <div id="qv"> 6 <h2>On this page</h2> 7 8 <ol> 9 <li><a href="#use">Usage</a></li> 10 </ol> 11 </div> 12 </div> 13 14 <p>The {@code ndk-stack} tool allows you to filter stack traces as they appear in the 15 output of <a href="{@docRoot}tools/help/logcat.html">{@code adb logcat}</a>. It also replaces any 16 address inside a shared library with the corresponding 17 {@code <source-file>:<line-number>} values from your source code, making issues easier 18 to pinpoint.</p> 19 20 <p>For example, it translates something like:</p> 21 22 <pre> 23 I/DEBUG ( 31): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** 24 I/DEBUG ( 31): Build fingerprint: 'generic/google_sdk/generic/:2.2/FRF91/43546:eng/test-keys' 25 I/DEBUG ( 31): pid: 351, tid: 351 %gt;%gt;%gt; /data/local/ndk-tests/crasher <<< 26 I/DEBUG ( 31): signal 11 (SIGSEGV), fault addr 0d9f00d8 27 I/DEBUG ( 31): r0 0000af88 r1 0000a008 r2 baadf00d r3 0d9f00d8 28 I/DEBUG ( 31): r4 00000004 r5 0000a008 r6 0000af88 r7 00013c44 29 I/DEBUG ( 31): r8 00000000 r9 00000000 10 00000000 fp 00000000 30 I/DEBUG ( 31): ip 0000959c sp be956cc8 lr 00008403 pc 0000841e cpsr 60000030 31 I/DEBUG ( 31): #00 pc 0000841e /data/local/ndk-tests/crasher 32 I/DEBUG ( 31): #01 pc 000083fe /data/local/ndk-tests/crasher 33 I/DEBUG ( 31): #02 pc 000083f6 /data/local/ndk-tests/crasher 34 I/DEBUG ( 31): #03 pc 000191ac /system/lib/libc.so 35 I/DEBUG ( 31): #04 pc 000083ea /data/local/ndk-tests/crasher 36 I/DEBUG ( 31): #05 pc 00008458 /data/local/ndk-tests/crasher 37 I/DEBUG ( 31): #06 pc 0000d362 /system/lib/libc.so 38 I/DEBUG ( 31): 39 </pre> 40 41 <p>into the more readable output: </p> 42 43 <pre> 44 ********** Crash dump: ********** 45 Build fingerprint: 'generic/google_sdk/generic/:2.2/FRF91/43546:eng/test-keys' 46 pid: 351, tid: 351 >>> /data/local/ndk-tests/crasher <<< 47 signal 11 (SIGSEGV), fault addr 0d9f00d8 48 Stack frame #00 pc 0000841e /data/local/ndk-tests/crasher : Routine zoo in /tmp/foo/crasher/jni/zoo.c:13 49 Stack frame #01 pc 000083fe /data/local/ndk-tests/crasher : Routine bar in /tmp/foo/crasher/jni/bar.c:5 50 Stack frame #02 pc 000083f6 /data/local/ndk-tests/crasher : Routine my_comparison in /tmp/foo/crasher/jni/foo.c:9 51 Stack frame #03 pc 000191ac /system/lib/libc.so 52 Stack frame #04 pc 000083ea /data/local/ndk-tests/crasher : Routine foo in /tmp/foo/crasher/jni/foo.c:14 53 Stack frame #05 pc 00008458 /data/local/ndk-tests/crasher : Routine main in /tmp/foo/crasher/jni/main.c:19 54 Stack frame #06 pc 0000d362 /system/lib/libc.so 55 </pre> 56 57 <h2>Usage</h2> 58 <p>To use {@code ndk-stack}, you first need a directory containing symbolic versions of your app's 59 shared libraries. If you use the NDK build system ({@code ndk-build}), these shared-library 60 files reside under {@code $PROJECT_PATH/obj/local/<abi>}, where {@code <abi>} represents 61 your device's ABI. By default, the system uses the {@code armeabi} ABI.</p> 62 63 <p>There are two ways to use the tool. You can feed the logcat text as direct input to the program. 64 For example:</p> 65 66 <pre class="no-pretty-print"> 67 adb logcat | $NDK/ndk-stack -sym $PROJECT_PATH/obj/local/armeabi 68 </pre> 69 70 <p>You can also use the {@code -dump} option to specify the logcat as an input file. For example: 71 </p> 72 73 <pre class="no-pretty-print"> 74 adb logcat > /tmp/foo.txt 75 $NDK/ndk-stack -sym $PROJECT_PATH/obj/local/armeabi -dump foo.txt 76 </pre> 77 78 <p>When it begins parsing the logcat output, the tool looks for an initial line of asterisks. 79 For example:</p> 80 81 <pre class="no-pretty-print"> 82 *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** 83 </pre> 84 85 <p class="note"><strong>Note: </strong>When copy/pasting traces, don't forget this line, or 86 {@code ndk-stack} won't work correctly.</p>