Home | History | Annotate | Download | only in debug
      1 <html devsite><head>
      2     <title> GDB</title>
      3     <meta name="project_path" value="/_project.yaml"/>
      4     <meta name="book_path" value="/_book.yaml"/>
      5   </head>
      6   <body>
      7   <!--
      8       Copyright 2017 The Android Open Source Project
      9 
     10       Licensed under the Apache License, Version 2.0 (the "License");
     11       you may not use this file except in compliance with the License.
     12       You may obtain a copy of the License at
     13 
     14           http://www.apache.org/licenses/LICENSE-2.0
     15 
     16       Unless required by applicable law or agreed to in writing, software
     17       distributed under the License is distributed on an "AS IS" BASIS,
     18       WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     19       See the License for the specific language governing permissions and
     20       limitations under the License.
     21   -->
     22 
     23 <p>GNU  (GDB)  Unix  <code>gdb</code>  Android </p>
     24 
     25 <h2 id="running"></h2>
     26 
     27 <p> <code>gdbclient</code>  PID PID  1234 </p>
     28 
     29 <pre class="devsite-terminal devsite-click-to-copy">
     30 gdbclient 1234
     31 </pre>
     32 
     33 <p> <code>gdbserver</code> <code>gdb</code> <code>gdb</code>  <code>gdb</code>  <code>gdbserver</code></p>
     34 
     35 <h2 id="starts"></h2>
     36 
     37 <p> <code>gdbserver</code>  <code>gdbserver64</code> 64 </p>
     38 
     39 <pre class="devsite-terminal devsite-click-to-copy">
     40 adb shell gdbserver :5039 /system/bin/<var>MY_TEST_APP</var>
     41 </pre>
     42 
     43 <p></p>
     44 <pre class="devsite-click-to-copy">
     45 Process <var>MY_TEST_APP</var> created; pid = 3460
     46 Listening on port 5039
     47 </pre>
     48 
     49 <p> <code>gdbserver</code>  PID</p>
     50 
     51 <pre class="devsite-terminal devsite-click-to-copy">
     52 gdbclient <var>APP_PID</var>
     53 </pre>
     54 
     55 <p> <code>gdb</code>  <strong>continue</strong></p>
     56 
     57 <p class="note"><strong></strong> <code>gdbserver</code><code>Reply contains invalid hex digit 59</code></p>
     58 
     59 <h2 id="app-startup"></h2>
     60 
     61 <p><em></em>
     62 <a href="#running"></a><code>logwrapper</code>  <code>strace</code>  <code>valgrind</code> <code>gdbserver</code> </p>
     63 
     64 <p> Java </p>
     65 
     66 <ol>
     67 <li>&gt;&gt;<em></em><strong></strong></li>
     68 
     69 <li><pre class="devsite-terminal devsite-click-to-copy">
     70 am start -a android.intent.action.MAIN -n <var>APP_NAME</var>/.<var>APP_ACTIVITY</var>
     71 </pre></li>
     72 
     73 <li></li>
     74 
     75 <li> <code>gdbserver</code>/<code>gdbclient</code></li></ol>
     76 
     77 <p> Java  (JDWP)  Java  (jdb)</p>
     78 <pre class="devsite-click-to-copy">
     79 <code class="devsite-terminal">adb forward tcp:12345 jdwp:<var>XXX</var>  # (Where XXX is the pid of the debugged process.)</code>
     80 <code class="devsite-terminal">jdb -attach localhost:12345</code>
     81 </pre>
     82 
     83 <h2 id="crash"></h2>
     84 
     85 <p> <code>debuggerd</code>  <code>gdb</code></p>
     86 
     87 <pre class="devsite-click-to-copy">
     88 # Android 7.0 Nougat and later.
     89 <code class="devsite-terminal">adb shell setprop debug.debuggerd.wait_for_gdb true</code>
     90 </pre>
     91 
     92 <pre class="devsite-click-to-copy">
     93 # Android 6.0 Marshmallow and earlier.
     94 <code class="devsite-terminal">adb shell setprop debug.db.uid 999999</code>
     95 </pre>
     96 
     97 <p><code>debuggerd</code>  <code>gdb</code> </p><pre class="devsite-terminal devsite-click-to-copy">
     98 gdbclient <var>PID</var>
     99 </pre>
    100 
    101 <h2 id="symbols"></h2>
    102 
    103 <p> 32  ARM<code>gdb</code> ARM  Thumb</p>
    104 
    105 <pre class="devsite-terminal devsite-click-to-copy">
    106 set arm fallback-mode arm  # or thumb
    107 </pre>
    108 
    109 </body></html>