Debugging is a difficult task. ?Writing a debugger sounds like an even more difficult task (wouldn't know, haven't done it yet, but I'm looking forward to "debugging the debugger"
). ?Here's what you COULD do:
1) Get a copy of NASM, or use the -S option under GCC
2) If you get NASM, you can use ndisasm to dissasemble the object code that was produced by GCC, this will give you code offsets for all of your instructions, and if you know where you've loaded your OS and where this particular module fits in, you can calculate what the linear address of the code will be
3) If you use the -S option, GCC will generate the assembly but will not assemble it, you can then look at this code (WARNING: It's in AT&T syntax!). ?This won't generate the listing file for you (does anybody know how to do that with gas?)
4) Anyway, you can plunk down some money for VMWare (or just get the temp license). ?In the options, turn on extra debugging log info.
5) Run your OS inside VMWare, if you get an unhandled GP# or any other unhandled exception, VMWare will most likely crash. ?
6) Once this happens, check inside your VMWare/WM/MyOS directory and look for VMWare, VMWare.txt, VMWare.log, something like that, and open it
7) Scroll down to the bottom, you'll see the last instruction's offset that caused the fault plus the type of fault and error code. ?You can then use this information to narrow down what went wrong
Of course, once you install your exception handlers, VMWare will let your OS handle exceptions and won't crash unless the virtual machine manages to triple-fault, so this technique only works for the early stages of OS design. ?Also, this won't help with more subtle bugs that don't generate exceptions. ?I haven't gotten to that point yet so I won't pretend to give you advice, but I'll probably be writing my own debugger (in the simplest sense of the word) pretty soon now. ?But it will be difficult, and will probably take me a while to figure out how to write one. ?
I'm not trying to be rude or anything, but if you don't want to write a piece of code because you think it's too difficult, then why do you want to write an operating system?