/Teaching/Operating Systems/Tutorials/Debugging the SWEB-Kernel with cgd

Debugging the SWEB-Kernel with cgd

  1. sudo apt-get install cgdbto install cgdb
  2. make debug
  3. make
  4. make qemugdb
  5. Open a second command line and run make runcgdb (or another debugger you’re preferring make runddd / make rungdb / …)

Wenn diese Befehle nicht funktionieren:

  • in the directory utils/gdb/gdbinitthere is a useful gdbinit File.
  • gdb -nx -x utils/gdb/gdbinit -r ../sweb-bin/kernel.x. -nx results in gdb not executing .gdbinit (optional).

Ahhh! How do I get rid of the debug information?

  • simply run make x86_64

SWEB debugging locking errors debugging

Debugging locking errors with a debugger is much more difficult than without it. This is due to different timings when executing the binary. But there is a different possibility to debug locks by using debug()-statements. However, Thomas Malcher, wrote an add-on for gdb to apply the so-called Locktree-algorithm onto mutexes in SWEB. Further research has to be done on the efficiency evaluation of this algorithm. Nevertheless, it’s worth a try. Further details can be found on this page in the materials: Debugging SWEB with GDB Lock Tree

Using Eclipse CDT debugger

  1. Compiling the whole project (cmake . and make) (this is to assure that the compiled kernel image is in the sweb-bin folder)
  2. Create a new debug configuration (Debug as) in Eclipse: “C/C++ Remote Application” with the following settings:
    • Main:
      • C/C++ Application: …/sweb-bin/kernel.x (choose with browse)
      • Disable auto build
      • Debugging Launcher: GDB (SDF) Manual Remote Debugging Launcher
    • Debugger:
      • Stop on startup at: startup
      • Connection: TCP / localhost / 1234
    • Common:
      • Display in favorites menu: Debug
  3. run make qemugdb in the terminal
  4. now debug with the debug configuration chosen in eclipse before
  5. Choose the appropriate resolution in the grub startup menu

Eclipse would stop the execution of the kernel-image at the startup function in the file /sweb/common/source/kernel/main.cpp if set up correctly.  This specific breakpoint can be changed in your debug configuration if you want to use different or additional breakpoints.

The demo video can be found here: http://www.youtube.com/watch?v=TXbgYE-lRCU