Kernel Debugging: Difference between revisions

Jump to navigation Jump to search
* Develop in hosted environment
[unchecked revision][unchecked revision]
(added introduction and category tags, fixed a style error, removed PFR tag)
(* Develop in hosted environment)
Line 96:
 
I won't start explaining all the nice things about gdb, but as you can see, it is a very powerfull tool for debuging OSes.
 
== Develop in hosted environment ==
Another possibility, which is also a great architectural exercise, is to code every software module in a hosted environment like Linux, and then porting it to your OS. You can do this for kernel code too, not just usermode programs.
 
Suppose you want to develop your VFS interface implementation. Your already created the interface for block devices (doesn't matter if you already implemented it in your kernel). In this case, you can implement your block device interface as a set of wrappers that [http://en.wikipedia.org/wiki/Adapter_pattern adapts] your interface to POSIX calls. You will then implement your VFS interface (i.e., the code that will manage the filesystem drivers in your kernel) on top of those wrappers.
 
Now, the Pors. First of all, you can use your favourite debugger. You can also use unit testing, for example, which is far better than testing software by hand, if you use the right method.
 
There are some Cons on this approach. For example, you are far from your target environment when you code like this. This is further agravated by the fact that so-called ''freestanding'' environments are dramatically more sensible to undefined behaviour, specially unitilialized variables. You can workarround this limitation by asking the compiler to perform aggressive optimization while testing hosted, which make software more sensible to undefined behaviour, too.
 
== Related Threads ==
 
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.

Navigation menu