Page 1 of 1

Another question

Posted: Sat Oct 19, 2002 3:58 am
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...

Re:Another question

Posted: Sat Oct 19, 2002 6:58 am
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.

Re:Another question

Posted: Sat Oct 19, 2002 11:53 am
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.

Re:Another question

Posted: Sat Oct 19, 2002 12:44 pm
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.

Re:Another question

Posted: Sat Oct 19, 2002 3:17 pm
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

Re:Another question

Posted: Sat Oct 19, 2002 7:43 pm
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.

Re:Another question

Posted: Sun Oct 20, 2002 10:01 am
by Ozguxxx
Thanks for bochs debugger link. I will try to understand it... ;)