title: How to debug the Linux kernel with GDB and QEMU?
body: <p>I'm new to kernel development and I would like to know how to run/debug the linux kernel using QEMU and gdb. I'm actually reading Robert Love's book but unfortunately it doesn't help the reader on how to install proper tools to run or debug the kernel... So what I did was to follow this tutorial <a href="http://opensourceforu.efytimes.com/2011/02/kernel-development-debugging-using-eclipse/" rel="noreferrer">http://opensourceforu.efytimes.com/2011/02/kernel-development-debugging-using-eclipse/</a>. I'm using eclipse as an IDE to develop on the kernel but I wanted first to get it work under QEMU/gdb. So what I did so far was:</p>
  
  <p>1) To compile the kernel with:</p>
  
  <pre><code>make defconfig (then setting the CONFIG_DEBUG_INFO=y in the .config)
  make -j4
  </code></pre>
  
  <p>2) Once the compilation is over I run Qemu using:</p>
  
  <pre><code>qemu-system-x86_64 -s -S /dev/zero -kernel /arch/x86/boot/bzImage
  </code></pre>
  
  <p>which launch the kernel in "stopped" state</p>
  
  <p>3) Thus I have to use gdb, I try the following command:</p>
  
  <pre><code>gdb ./vmlinux
  </code></pre>
  
  <p>which run it correctly but... Now I don't know what to do... I know that I have to use remote debugging on the port 1234 (default port used by Qemu), using the vmlinux as the symbol table file for debugging.</p>
  
  <p>So my question is: What should I do to run the kernel on Qemu, attach my debugger to it and thus, get them work together to make my life easier with kernel development.</p>