Another question
Another question
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
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.
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
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
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
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:
or:
here's the (kinda) manual
http://bochs.sourceforge.net/docs-html/debugger.html
vb seg:off lbreak addr Set a linear address instruction breakpoint
lb addr
so you would do:
Code: Select all
lb 0x7c00h
Code: Select all
vb 0x07c0:0x0
http://bochs.sourceforge.net/docs-html/debugger.html
Re:Another question
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.
You can get the function at my website.
If the problem can't be froozen in the C code, try jmp $ in NASM code.