Skip to content

Debug the Kernel with Eclipse

G33KatWork edited this page Sep 13, 2010 · 3 revisions

Sometimes you may want to debug the kernel on the source level to find an insistent bug easier.

We can use the GDB on the command line. If you are comfortable with this way, you are just fine. Just type “make qemudebug” or “make bochsdebug” and Qemu or Bochs will wait for you to attach a GDB.

If you want it comfortable you can also use Eclipse:

The requirements are Eclipse with the CDT Plugin and the Zylin Embedded CDT Plugin from http://opensource.zylin.com/embeddedcdt.html

  1. Install everything
  2. Create an empty Makefile C++ Project in Eclipse
  3. Click “Run → Debug Configurations…”
  4. Create a new “Zylin Embedded debug (Native)” configuration and give it a descriptive name
  5. Under “C/C++ Application” in the “Main” tab select the kernel.elf file you built by typing “make” in the GeexOS root directory
  6. Got to tab “Debugger”
  7. Set the gdb executable which is located under “toolchain/‘target’/bin/” under the GeexOS directory in the field “GDB debugger” — substitute ‘target’ with your architecture you are compiling the kernel for
  8. Go to tab “Commands”
  9. Enter the following commands in the textbox labeled with “‘Initialize’ commands”:
    target remote 127.0.0.1:1234
    b <intial breakpoint>
    c
  10. replace “” with a function name you want the gdb to halt — be careful with mangled names when using C++
  11. Go to tab “Source”
  12. Click “Add…” and select “File System Directory”
  13. Choose the folder “kernel/src” under your GeexOS directory and click “OK”
  14. Now start up your Qemu or Bochs in debug mode and click “Debug”
  15. The GDB should be attached and you are ready to debug
Clone this wiki locally