Another question

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
Ozguxxx

Another question

Post by Ozguxxx »

Hi everybody, I think I am about to finish about %66.66666 of my keyboard handler. (BTW abless, I inspired from your kernel alot. No copy-pasting, I got ideas. ;D Thanx.) MY question is: Is there a way to debug OS codes in some way? Almost always I try to find my errors by chance, I mean I try some code, if it doesnt work I try anohter I think many people do in the same way. Anyway I need a debugger for OS code. Thanx...
PlayOS

Re:Another question

Post by PlayOS »

Hi,

I think what you need to do is insert a DEBUG function in your kernel and use it to print a message on the screen, add it to all of your kernel code, and insert a preprocessor around the function, to either include or exlude it

#ifdef _DEBUG_
DEBUG("Doing something in my kernel!\n");
#endif

by doing this you can build a debug version of your OS just by defining _DEBUG_ in your kernel, and a release version by leaving it out.

Hope this helps.
Ozguxxx

Re:Another question

Post by Ozguxxx »

Thanx for your advice PlayOS but it is not enough for debugging asm codes. I mean I want to see what actually happens as my code goes on instruction by instruction. It is sometimes very hard to trace all asm code and sometimes the error is in part of code that you think is working... Does everybody do debugging in that way? Thanx again.
grey wolf

Re:Another question

Post by grey wolf »

bochs comes with a run-time debigger, but it's rather awkward to use. i'm still trying to figure out how to set a breakpoint in my bootstrap code.
dronkit

Re:Another question

Post by dronkit »

vbreak seg:off Set a virtual address instruction breakpoint
vb seg:off lbreak addr Set a linear address instruction breakpoint
lb addr

so you would do:

Code: Select all

lb 0x7c00h
or:

Code: Select all

vb 0x07c0:0x0
here's the (kinda) manual ;)
http://bochs.sourceforge.net/docs-html/debugger.html
Tom

Re:Another question

Post by Tom »

I just use my Freeze() function to stop my code and see what's causing my probs - works great.

You can get the function at my website.
If the problem can't be froozen in the C code, try jmp $ in NASM code.
Ozguxxx

Re:Another question

Post by Ozguxxx »

Thanks for bochs debugger link. I will try to understand it... ;)
Post Reply