Home | History | Annotate | Download | only in html
      1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
      2 <html xmlns="http://www.w3.org/1999/xhtml">
      3 <head>
      4 <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
      5 <meta http-equiv="X-UA-Compatible" content="IE=9"/>
      6 <meta name="generator" content="Doxygen 1.8.5"/>
      7 <title>NDK Programmer&#39;s Guide: &lt;code&gt;ndk-stack&lt;/code&gt;</title>
      8 <link href="tabs.css" rel="stylesheet" type="text/css"/>
      9 <script type="text/javascript" src="jquery.js"></script>
     10 <script type="text/javascript" src="dynsections.js"></script>
     11 <link href="navtree.css" rel="stylesheet" type="text/css"/>
     12 <script type="text/javascript" src="resize.js"></script>
     13 <script type="text/javascript" src="navtree.js"></script>
     14 <script type="text/javascript">
     15   $(document).ready(initResizable);
     16   $(window).load(resizeHeight);
     17 </script>
     18 <link href="doxygen.css" rel="stylesheet" type="text/css" />
     19 </head>
     20 <body>
     21 <div id="top"><!-- do not remove this div, it is closed by doxygen! -->
     22 <div id="titlearea">
     23 <table cellspacing="0" cellpadding="0">
     24  <tbody>
     25  <tr style="height: 56px;">
     26   <td style="padding-left: 0.5em;">
     27    <div id="projectname">NDK Programmer&#39;s Guide
     28    </div>
     29   </td>
     30  </tr>
     31  </tbody>
     32 </table>
     33 </div>
     34 <!-- end header part -->
     35 <!-- Generated by Doxygen 1.8.5 -->
     36 </div><!-- top -->
     37 <div id="side-nav" class="ui-resizable side-nav-resizable">
     38   <div id="nav-tree">
     39     <div id="nav-tree-contents">
     40       <div id="nav-sync" class="sync"></div>
     41     </div>
     42   </div>
     43   <div id="splitbar" style="-moz-user-select:none;"
     44        class="ui-resizable-handle">
     45   </div>
     46 </div>
     47 <script type="text/javascript">
     48 $(document).ready(function(){initNavTree('md_3__key__topics__debugging__n_d_k-_s_t_a_c_k.html','');});
     49 </script>
     50 <div id="doc-content">
     51 <div class="header">
     52   <div class="headertitle">
     53 <div class="title"><code>ndk-stack</code> </div>  </div>
     54 </div><!--header-->
     55 <div class="contents">
     56 <div class="textblock"><h2>Introduction</h2>
     57 <p>This document describes the 'ndk-stack' tool that is distributed with the Android NDK, since release r6.</p>
     58 <h2>Overview</h2>
     59 <p>'ndk-stack' is a simple tool that allows you to filter stack traces as they appear in the output of '<code>adb logcat</code>' and replace any address inside a shared library with the corresponding &lt;source-file&gt;:&lt;line-number&gt; values.</p>
     60 <p>In a nutshell, it will translate something like: </p>
     61 <pre class="fragment">      I/DEBUG   (   31): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
     62       I/DEBUG   (   31): Build fingerprint: 'generic/google_sdk/generic/:2.2/FRF91/43546:eng/test-keys'
     63       I/DEBUG   (   31): pid: 351, tid: 351  %gt;%gt;%gt; /data/local/ndk-tests/crasher &lt;&lt;&lt;
     64       I/DEBUG   (   31): signal 11 (SIGSEGV), fault addr 0d9f00d8
     65       I/DEBUG   (   31):  r0 0000af88  r1 0000a008  r2 baadf00d  r3 0d9f00d8
     66       I/DEBUG   (   31):  r4 00000004  r5 0000a008  r6 0000af88  r7 00013c44
     67       I/DEBUG   (   31):  r8 00000000  r9 00000000  10 00000000  fp 00000000
     68       I/DEBUG   (   31):  ip 0000959c  sp be956cc8  lr 00008403  pc 0000841e  cpsr 60000030
     69       I/DEBUG   (   31):          #00  pc 0000841e  /data/local/ndk-tests/crasher
     70       I/DEBUG   (   31):          #01  pc 000083fe  /data/local/ndk-tests/crasher
     71       I/DEBUG   (   31):          #02  pc 000083f6  /data/local/ndk-tests/crasher
     72       I/DEBUG   (   31):          #03  pc 000191ac  /system/lib/libc.so
     73       I/DEBUG   (   31):          #04  pc 000083ea  /data/local/ndk-tests/crasher
     74       I/DEBUG   (   31):          #05  pc 00008458  /data/local/ndk-tests/crasher
     75       I/DEBUG   (   31):          #06  pc 0000d362  /system/lib/libc.so
     76       I/DEBUG   (   31):
     77 </pre><p>Into the more readable output: </p>
     78 <pre class="fragment">      ********** Crash dump: **********
     79       Build fingerprint: 'generic/google_sdk/generic/:2.2/FRF91/43546:eng/test-keys'
     80       pid: 351, tid: 351  &gt;&gt;&gt; /data/local/ndk-tests/crasher &lt;&lt;&lt;
     81       signal 11 (SIGSEGV), fault addr 0d9f00d8
     82       Stack frame #00  pc 0000841e  /data/local/ndk-tests/crasher : Routine zoo in /tmp/foo/crasher/jni/zoo.c:13
     83       Stack frame #01  pc 000083fe  /data/local/ndk-tests/crasher : Routine bar in /tmp/foo/crasher/jni/bar.c:5
     84       Stack frame #02  pc 000083f6  /data/local/ndk-tests/crasher : Routine my_comparison in /tmp/foo/crasher/jni/foo.c:9
     85       Stack frame #03  pc 000191ac  /system/lib/libc.so
     86       Stack frame #04  pc 000083ea  /data/local/ndk-tests/crasher : Routine foo in /tmp/foo/crasher/jni/foo.c:14
     87       Stack frame #05  pc 00008458  /data/local/ndk-tests/crasher : Routine main in /tmp/foo/crasher/jni/main.c:19
     88       Stack frame #06  pc 0000d362  /system/lib/libc.so
     89 </pre><h2>Usage</h2>
     90 <p>To do this, you will first need a directory containing symbolic versions of your application's shared libraries. If you use the NDK build system (i.e. ndk-build), then these are always located under <code>$PROJECT_PATH/obj/local/&lt;abi&gt;</code>, where <code>&lt;abi&gt;</code> stands for your device's ABI (i.e. '<code>armeabi</code>' by default).</p>
     91 <p>You can feed the logcat text either as direct input to the program, e.g.: </p>
     92 <pre class="fragment">    adb logcat | $NDK/ndk-stack -sym $PROJECT_PATH/obj/local/armeabi
     93 </pre><p>Or you can use the -dump option to specify the logcat as an input file, e.g.: </p>
     94 <pre class="fragment">    adb logcat &gt; /tmp/foo.txt
     95     $NDK/ndk-stack -sym $PROJECT_PATH/obj/local/armeabi -dump foo.txt
     96 </pre><p>** IMPORTANT **:</p>
     97 <blockquote class="doxtable">
     98 <p>The tool looks for the initial line containing starts in the logcat output,</p>
     99 <p></p>
    100 </blockquote>
    101 <p>i.e. something that looks like: </p>
    102 <pre class="fragment">    *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
    103 </pre><p>When copy/pasting traces, don't forget this line from the traces, or ndk-stack won't work correctly.</p>
    104 <h2>TODO</h2>
    105 <p>A future version of '<code>ndk-stack</code>' will try to launch '<code>adb logcat</code>' and select the library path automatically. For now, you'll have to do these steps manually.</p>
    106 <p>As of now, ndk-stack doesn't handle libraries that don't have debug information in them. It may be useful to try to detect the nearest function entry point to a given PC address (e.g. as in the libc.so example above). </p>
    107 </div></div><!-- contents -->
    108 </div><!-- doc-content -->
    109 <!-- start footer part -->
    110 <div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
    111   <ul>
    112     <li class="footer">Generated on Wed Jun 25 2014 00:51:19 for NDK Programmer&#39;s Guide by
    113     <a href="http://www.doxygen.org/index.html">
    114     <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.5 </li>
    115   </ul>
    116 </div>
    117 </body>
    118 </html>
    119