diff options
Diffstat (limited to 'en/devices/tech/debug/index.html')
-rw-r--r-- | en/devices/tech/debug/index.html | 104 |
1 files changed, 18 insertions, 86 deletions
diff --git a/en/devices/tech/debug/index.html b/en/devices/tech/debug/index.html index b2f4c140..268f24ee 100644 --- a/en/devices/tech/debug/index.html +++ b/en/devices/tech/debug/index.html @@ -25,11 +25,11 @@ <p>This section summarizes useful tools and related commands for debugging, tracing, and profiling native Android platform code when developing -platform-level features. This page covers use of <code>debuggerd</code>, a -daemon process for collecting error information after applications crash, and -the GNU Project debugger (GDB).</p> +platform-level features.</p> -<p>Other pages in this section explore system services with +<p>This page covers use of <code>debuggerd</code>, a daemon process for +collecting error information after applications crash. Other pages in this +section explore system services with <a href="/devices/tech/debug/dumpsys.html">Dumpsys</a>, viewing <a href="/devices/tech/debug/native-memory.html">native memory</a>, <a href="/devices/tech/debug/netstats.html">network</a>, and @@ -37,8 +37,9 @@ the GNU Project debugger (GDB).</p> <a href="/devices/tech/debug/asan.html">AddressSanitizer</a> to detect memory bugs in native code, evaluating <a href="/devices/tech/debug/eval_perf.html"> performance issues</a> (includes -<a href="/devices/tech/debug/systrace">systrace</a>), and several other -debugging tools.</p> +<a href="/devices/tech/debug/systrace">systrace</a>), and using +<a href="/devices/tech/debug/gdb.html">GNU Project debugger (GDB)</a> and +other debugging tools.</p> <h2 id=debuggerd>Using debuggerd</h2> @@ -57,7 +58,7 @@ opt out of crash reporting.</p> <p>Example <code>debuggerd</code> output (with timestamps and extraneous information removed):</p> -<pre class="no-pretty-print"> +<pre class="devsite-click-to-copy"> *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** Build fingerprint: 'Android/aosp_angler/angler:7.1.1/NYC/enh12211018:eng/test-keys' Revision: '0' @@ -95,8 +96,12 @@ unwind with line number information by pasting the above example into <code>stack</code> will be on your $PATH already so you don't need to give the full path.</p> -<pre> -$ development/tools/stack +<pre class="devsite-terminal devsite-click-to-copy"> +development/tools/stack +</pre> + +<p>Example output:</p> +<pre class="devsite-click-to-copy"> Reading native crash info from stdin 03-02 23:53:49.477 17951 17951 F DEBUG : *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** 03-02 23:53:49.477 17951 17951 F DEBUG : Build fingerprint: 'Android/aosp_angler/angler:7.1.1/NYC/enh12211018:eng/test-keys' @@ -146,93 +151,20 @@ directly from <code>debuggerd</code> without taking up anywhere near as much space as an unstripped version.</p> <p>You can also <code>stack</code> an entire tombstone. Example:</p> -<pre> -$ stack < FS/data/tombstones/tombstone_05 +<pre class="devsite-terminal devsite-click-to-copy"> +stack < FS/data/tombstones/tombstone_05</code> </pre> <p>This is useful if you've just unzipped a bugreport in the current directory. For more information about diagnosing native crashes and tombstones, see <a href="/devices/tech/debug/native-crash.html">Diagnosing Native Crashes</a>. </p> -<h3>Getting a stack trace/tombstone from a running process</h3> +<h2 id="tombstone">Getting a stack trace/tombstone from a running process</h2> <p>You can also use <code>debuggerd</code> on a running process. From the command line, invoke <code>debuggerd</code> using a process ID (PID) to dump the full tombstone to <code>stdout</code>. To get just the stack for every thread in -the process, include the <code>-b</code> or <code>--backtrace</code> flag. - -<h2 id=native>Using GDB</h2> - -<p>The GNU Project debugger (GDB) is a commonly used Unix debugger.</p> - -<h3 id=running>Debugging a running app</h3> - -<p>To connect to an already-running app or native daemon, use -<code>gdbclient</code> with a PID. For example, to debug the process with PID -1234, run:</p> - -<pre class="no-pretty-print"> -$ gdbclient 1234 -</pre> - -<p>The script sets up port forwarding, starts the appropriate -<code>gdbserver</code> on the device, starts the appropriate <code>gdb</code> on -the host, configures <code>gdb</code> to find symbols, and connects -<code>gdb</code> to the remote <code>gdbserver</code>.</p> - -<h3 id=starts>Debugging a native process as it starts</h3> - -<p>To debug a process as it starts, use <code>gdbserver</code> or -<code>gdbserver64</code> (for 64-bit processes). For example:</p> - -<pre class="no-pretty-print"> -$ adb shell gdbserver :5039 /system/bin/<em>my_test_app</em> -Process my_test_app created; pid = 3460 -Listening on port 5039 -</pre> - -<p>Next, identify the application PID from the <code>gdbserver</code> output and -use it in another terminal window:</p> - -<pre class="no-pretty-print"> -$ gdbclient <em><app pid></em> -</pre> - -<p>Finally, enter <strong>continue</strong> at the <code>gdb</code> prompt.</p> - -<p class="note"><strong>Note:</strong> If you use the wrong -<code>gdbserver</code>, you'll get an unhelpful error message (such as -"<code>Reply contains invalid hex digit 59</code>").</p> - -<h3 id=crash>Debugging processes that crash</h3> - -<p>If you want <code>debuggerd</code> to suspend crashed processes so you can -attach <code>gdb</code>, set the appropriate property:</p> - -<pre class="no-pretty-print"> -# Android 7.0 Nougat and later. -$ adb shell setprop debug.debuggerd.wait_for_gdb true - -# Android 6.0 Marshmallow and earlier. -$ adb shell setprop debug.db.uid 999999 -</pre> - -<p>At the end of the usual crash output, <code>debuggerd</code> provides -instructions on how to connect <code>gdb</code> using the command: -<pre class="no-pretty-print"> -$ gdbclient <pid> -</pre> - -<h3 id=symbols>Debugging without symbols</h3> - -<p>For 32-bit ARM, if you don’t have symbols, <code>gdb</code> can get confused -about the instruction set it is disassembling (ARM or Thumb). To specify the -instruction set chosen as the default when symbol information is missing, set -the following property:</p> - -<pre class="no-pretty-print"> -$ set arm fallback-mode arm # or thumb -</pre> +the process, include the <code>-b</code> or <code>--backtrace</code> flag.</p> </body> </html> |