MollenOS wrote:rdos wrote:gerryg400 wrote:I must be misunderstanding printf debugging. What's wrong with it ?
Everything. They alter state and introduce new bugs + cannot tell you what a debugger typically can tell you. Once the basic exception handlers are in place, the next step is to integrate a remote debugger or local debugger thread so you can single step the kernel, preferably in source-code form. Before that is done, planting "int 3" in code, which triggers the exception handlers, is a good way to get the current register state.
Of course, if you are in an emulator rather than on real hardware, then the emulator might have good options for doing the above an easier way, but you still need it when you come to real hardware that isn't booting.
I really disagree with this statement. Printf debugging is slow, but it surely works really well. Integrating support for a remote debugger or a local debugger is a lot more work out of the box and printf debugging is a lot more simple to implement.
There hasn't been one issue in my OS that could not get fixed by printf debugging. Printf debugging might not be suitable for you, but it sure as hell is for 90% of people here.
Well, if you can do printf, then you can do register dumps, and if you can do register dumps and have support for keyboard, then you can do an interactive debugger which is far more effective than printf-debugging will ever be. You are just used to an inefficient method.
BTW, I developed the low level stuff in my OS before emulators were generally available, so one of my first steps was to do a 486-emulator so I could trace the boot process. After that, I made the integrated debugger that works after multithreading is started, and it is running as a thread, and individual faulted threads can be inspected, modified and single-stepped / restarted regardless if they run in kernel or application space, including V86-mode, protected mode and long mode. This is still available and used when there are problems in the startup process on real hardware or in specific drivers. Lastly, I ported OpenWatcom and their remote debugging stub so I could debug applications (and drivers) at source level remotely, which is the optimal way of debugging. I use this to debug device-drivers too, because then I just define the "test" syscall, chain it to the code I want to debug in kernel space, and can then trace into it with the application debugger.