title: Debugging kernel using kgdb/gdb on arm target?
body: <p>I got <code>vmlinux.uimg</code> and <code>vmlinux</code> from my friend. The <code>vmlinux</code> is build with Linux version 4.14.10. I have two machines:</p>
  
  <ul>
  <li>target (arm 32 bit architecture) and</li>
  <li>host (x86 architecture)</li>
  </ul>
  
  <p>Both systems are connected with wire, port numbers are <code>/dev/ttySAC3</code> and <code>/dev/ttyUSB0</code> respectively. Target boot up by reading image file <code>vmlinux.uimg</code> from sd card. I want to debug this <code>vmlinux</code> from my host machine.</p>
  
  <p>The steps I am following are:</p>
  
  <ol>
  <li>Start minicom in host.</li>
  <li><p>Type</p>
  
  <pre><code>echo ttySAC3,115200 &gt; /sys/module/kgdboc/parameters/kgdboc in minicom.
  </code></pre>
  
  <p>I am getting "KGDB: Registered I/O driver kgdboc".</p></li>
  <li><p>Type</p>
  
  <pre><code>echo g &gt;/proc/sysrq-trigger in minicom
  </code></pre>
  
  <p>I am getting "sysrq DEBUG and Entering KGDB".</p></li>
  <li>Close minicom.</li>
  <li>Go to vmlinux folder through terminal in host machine.</li>
  <li><p>Type</p>
  
  <pre><code>gdb vmlinux
  </code></pre>
  
  <p>[Note: this gdb I am using is 7.10 version for arm]</p></li>
  <li><p>In GDB type</p>
  
  <pre><code>target remote /dev/ttyUSB0
  </code></pre>
  
  <p>It give me a message </p>
  
  <pre><code>Remote debugging using /dev/ttyUSB0 0xc0d14f5 in sysrq_dbg_op()
  </code></pre></li>
  <li><p>In GDB type</p>
  
  <pre><code>b do_mmap_pgoff
  </code></pre>
  
  <p>I am getting a message</p>
  
  <pre><code>breakpoint 1 at xxxx: do_map_pgoff (4 location)
  </code></pre></li>
  <li><p>In GDB type</p>
  
  <pre><code>cont
  </code></pre>
  
  <p>This gives me a message</p>
  
  <pre><code>Continuing.
  </code></pre>
  
  <p>and then does nothing..</p></li>
  </ol>
  
  <p>The problems:</p>
  
  <ol>
  <li><p>GDB <code>continue</code> is not working as expected. I am expecting last step(9) to continue with target restart and hit the break point instead it is getting crash.</p></li>
  <li><p>GDB <code>step</code> and <code>next</code> are not working as expected. Single stepping until exit from <code>sysrq_dbg_op()</code> which has no line number information. "Warning: invalid remote reply".</p></li>
  <li><p>GDB 'run' is also not working. It display a message "The remote target does not support run"</p></li>
  <li><p>How can I call a module on my target on which I have put breakpoint as I can not use minicom and gdb concurrently. </p></li>
  <li><p>What all steps I should follow after I freeze the kernel.</p></li>
  </ol>
  
  <p>What is wrong in this process?</p>