title: Android Kernel Debugging
body: <p>I have been experimenting with getting <code>kgdb</code> to work the Nexus One.</p>
  
  <p>I have pulled the kernel from <a href="https://android.googlesource.com" rel="nofollow noreferrer">https://android.googlesource.com</a> and enabled everything to do with <code>kgdb</code> including <code>kgdbts</code> testing using <code>menuconfig</code>. Successfully built the kernel and flashed it to the device (which is unlocked rooted and running CyanogenMod 7)</p>
  
  <p>I have also followed the instructions found on  <a href="http://bootloader.wikidot.com/android:kgdb" rel="nofollow noreferrer">http://bootloader.wikidot.com/android:kgdb</a> to enable the usb connection to act as a serial connection as required by <code>kgdb</code> (and tested communications from <code>ttyACM0</code> to <code>ttyGS0</code> successfully).</p>
  
  <p>The following folders exist indicating that <code>kgdboc</code> and <code>kgdbts</code> have been built into the kernel:</p>
  
  <pre><code>/sys/modules/kgdboc/parameters
  /sys/modules/kgdbts/parameters
  </code></pre>
  
  <p>The following is the output from dmesg showing the <code>kgdbts</code> testing being done show what (I think) is a successful completion of the tests:</p>
  
  <pre><code># dmesg | grep kgdb
  &lt;6&gt;[   12.974060] kgdb: Registered I/O driver kgdbts.
  &lt;6&gt;[   12.981781] kgdbts:RUN plant and detach test
  &lt;6&gt;[   12.995178] kgdbts:RUN sw breakpoint test
  &lt;6&gt;[   13.002441] kgdbts:RUN bad memory access test
  &lt;6&gt;[   13.010864] kgdbts:RUN singlestep test 1000 iterations
  &lt;6&gt;[   13.019042] kgdbts:RUN singlestep [0/1000]
  &lt;6&gt;[   13.077850] kgdbts:RUN singlestep [100/1000]
  &lt;6&gt;[   13.132720] kgdbts:RUN singlestep [200/1000]
  &lt;6&gt;[   13.187500] kgdbts:RUN singlestep [300/1000]
  &lt;6&gt;[   13.242370] kgdbts:RUN singlestep [400/1000]
  &lt;6&gt;[   13.297149] kgdbts:RUN singlestep [500/1000]
  &lt;6&gt;[   13.351928] kgdbts:RUN singlestep [600/1000]
  &lt;6&gt;[   13.406829] kgdbts:RUN singlestep [700/1000]
  &lt;6&gt;[   13.461578] kgdbts:RUN singlestep [800/1000]
  &lt;6&gt;[   13.516540] kgdbts:RUN singlestep [900/1000]
  &lt;6&gt;[   13.570922] kgdbts:RUN do_fork for 100 breakpoints
  &lt;6&gt;[   21.117645] kgdb: Unregistered I/O driver kgdbts, debugger disabled.
  </code></pre>
  
  <p>I believe that the problem I am running into is getting the kernel to trigger <code>kgdb</code>.</p>
  
  <pre><code># echo -n g &gt; /proc/sysrq-trigger
  </code></pre>
  
  <p>Just results in dropping me back to the command prompt and (I think) it is suppose to freeze everything and send a prompt over usb which is being used as a psuedo serial port since the phone doesn't have a real one.</p>
  
  <p>From what I gather from my research that prompt is supposed to be the trigger that will allow me to issue</p>
  
  <pre><code>(gdb) target remote /dev/ttyACM0
  </code></pre>
  
  <p>And connect to a debugging session with the kernel.</p>
  
  <p>I have also tested <code>/proc/sysrq-trigger</code> with <code>b</code> and <code>c</code> just confirm that I am able to pass some commands to <code>sysrq</code>.</p>
  
  <p>So my question following my long winded attempt to provide as much information as possible is why is <code>g</code> not triggering the debugger? </p>
  
  <p>This is my first attempt at kernel debugging on any system and I have run out of ways to phrase my search on google so I turn to you. Thanks!</p>
  
  <p>(I have also tried putting kdgbwait in the kernel command line without success as I believe this is not yet supported by the android kernel)</p>