Debugging multithreaded kernel with GDB

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
Andy1988
Member
Member
Posts: 50
Joined: Fri Aug 22, 2008 12:01 pm
Location: Germany - Aachen

Debugging multithreaded kernel with GDB

Post by Andy1988 »

Hi,
I just finished my scheduler :) Until now everything is hardcoded, but it works. It prints happily A's and B's.

The thing I noticed is that GDB gets quite confused about this. I'm running my kernel in qemu with 1 CPU.
I'm attaching GDB, setting the breakpoint to my main function where nothing is initialized yet and the kernel executes the kernel thread. Only my second thread seems to be paused. At the time the instruction pointer should hit the breakpoint no scheduling should be initialized.

I also tried to debug the multitasking sample from James Molloy and the behaviour is the same. I needed some inspiration how to do the actual task switching, so the core mechanisms are the same in both kernels. :D

This is the strange behaviour:
Bildschirmfoto-2010-04-11-um-00.09.39-Kopie.png
The kernel thread itself outputs the B's.

Does anybody know what's happening there and how to get rid of it?
Post Reply