ReactOS debugging questions

All development related issues welcome

Moderator: Moderator Team

Post Reply
Barracuda72
Posts: 9
Joined: Mon Oct 17, 2011 10:51 am

ReactOS debugging questions

Post by Barracuda72 »

I have a bunch of debugging issues and will be very thankful if somebody will be kind enough to answer them.

1) Is it even possible to debug ReactOS in Qemu under Windows x64? I've tried several versions of Qemu, several releases of WinDbg,
different communication methods but still with no luck.
a) With "pipe" method Qemu just hangs forever, probably waiting for debugger to connect, but even on WinDbg connection it isn't becoming alive.
b) With com0com and serial ports Qemu works fine, but now it's WinDbg turn: it crashes instantly as debuggee tries to send something thru COM.
c) Debugging via network requires some sophisticated DNS setup, so I'd prefer to avoid that.
Bochs is an excellent thing, but Qemu is much faster, and it matters. Even on my Xeon I have to wait for half a minute before Bochs stats,
boots from disk, loads kernel and HAL, makes some progress and stops on BP. Debugging could've been much faster with Qemu but...

2) I want to debug registry code. The problem is I can't just insert __debugbreak somewhere, because same code is used on host in mkhive.exe
utility, and it crashes in that case. What conditional define should I put around __debugbreak?

3) I can debug kernel code fine, but when I insert BP somewhere in driver I can only debug it in disassembly. It seems that WinDbg only loads
symbols and debug info for ntoskrnl.exe, and not for other modules. In modules list it also shows only ntoskrln.exe. Can I somehow tell it to
recognize another modules too? Or maybe it's the kernel that misinforms WinDbg about modules, as it does with threads (there are a couple of threads,
but Processes and Threads in WinDbg shows only one with extremely suspicious address 0xF0F0F0F0 :) )?
hbelusca
Developer
Posts: 1204
Joined: Sat Dec 26, 2009 10:36 pm
Location: Zagreb, Croatia

Re: ReactOS debugging questions

Post by hbelusca »

1) You may consider using instead VBox or VMWare :P
But otherwise it should work, if you configure QEmu serial port correctly and using com0com (so, let's say com0com creates the pair COM1 and COM2; you link QEmu's serial port to e.g. COM1 while you'll connect WinDbg to COM2).
However, even if serial port is at 115200 bauds, it may not be fast enough; using pipes is not working ok usually. That's why ppl usually use http://virtualkd.sysprogs.org/ together with VBox, for example. Or use pipes or com0com with VMWare.

2) Hive library common header being sdk/lib/cmlib/cmlib.h , you put a "#define __debugbreak()" alone somewhere inside the "#ifdef CMLIB_HOST" clauses (this is what is defined when being compiled as a host-tool). When it'll compile as NTOS code then the correct __debugbreak() will be used instead.

3)
It seems that WinDbg only loads symbols and debug info for ntoskrnl.exe, and not for other modules.
Be sure to use your own build, with symbols correctly configured on WinDbg side (in the File/Symbol paths dialog), as well as the path to source. Please also first check that everything works ok when you try to debug x86 32-bit ReactOS (since almost all devs use that and it's known to work very well). I don't know if things still work ok on x64.
By "default" WinDbg should see kernel + loaded drivers symbols, and be able to do step-by-step in the (kernel-mode) code.
Barracuda72
Posts: 9
Joined: Mon Oct 17, 2011 10:51 am

Re: ReactOS debugging questions

Post by Barracuda72 »

1) You may consider using instead VBox or VMWare :P
Oh, yea, totally forgot about that. Will try VBox then, it seems to support port pass-through.
But otherwise it should work, if you configure QEmu serial port correctly and using com0com (so, let's say com0com creates the pair COM1 and COM2; you link QEmu's serial port to e.g. COM1 while you'll connect WinDbg to COM2).
And what's the right options for COM in Qemu? Tried switching parity and such with no luck.
However, even if serial port is at 115200 bauds, it may not be fast enough; using pipes is not working ok usually. That's why ppl usually use http://virtualkd.sysprogs.org/ together with VBox, for example. Or use pipes or com0com with VMWare.
VirtualKD is interesting project, but out of question at least for now - x64 build of ReactOS barely makes it to the stage of driver loading, so it's not possible to install guest driver required by VKD.
2) Hive library common header being sdk/lib/cmlib/cmlib.h , you put a "#define __debugbreak()" alone somewhere inside the "#ifdef CMLIB_HOST" clauses (this is what is defined when being compiled as a host-tool). When it'll compile as NTOS code then the correct __debugbreak() will be used instead.
Thanks for a hint - nice trick!
3) Be sure to use your own build, with symbols correctly configured on WinDbg side (in the File/Symbol paths dialog), as well as the path to source. Please also first check that everything works ok when you try to debug x86 32-bit ReactOS (since almost all devs use that and it's known to work very well). I don't know if things still work ok on x64.
By "default" WinDbg should see kernel + loaded drivers symbols, and be able to do step-by-step in the (kernel-mode) code.
Hmm, okay. I have low interest in x86, but it seems logical to first check popular configuration before switching to abandoned one. Again, thanks for an advice.
hbelusca
Developer
Posts: 1204
Joined: Sat Dec 26, 2009 10:36 pm
Location: Zagreb, Croatia

Re: ReactOS debugging questions

Post by hbelusca »

Barracuda72 wrote: VirtualKD is interesting project, but out of question at least for now - x64 build of ReactOS barely makes it to the stage of driver loading, so it's not possible to install guest driver required by VKD.
Actually, better: you install VKD on Windows (the part that will communicate with the VM), while on the VM side you boot using "ReactOS (VirtualKD)" because we have a clone of the kdcom.dll layer for VKD (called "kdvm.dll"). I do that and it works perfect. This kdvm.dll is loaded together with ntoskrnl (and hal) so this should not be a problem for x64. The only question is whether this kdvm.dll still works when in x64 bit (and also, whether the kd layer on ntoskrnl side is compiled and/or works ok in x64 bit mode).
Barracuda72 wrote:
3) Be sure to use your own build, with symbols correctly configured on WinDbg side (in the File/Symbol paths dialog), as well as the path to source. Please also first check that everything works ok when you try to debug x86 32-bit ReactOS (since almost all devs use that and it's known to work very well). I don't know if things still work ok on x64.
By "default" WinDbg should see kernel + loaded drivers symbols, and be able to do step-by-step in the (kernel-mode) code.
Hmm, okay. I have low interest in x86, but it seems logical to first check popular configuration before switching to abandoned one. Again, thanks for an advice.
It was first just to be sure you can test your setup with a known configuration. Then the next step would be to restart the VM etc... with x64 build (and the windbg symbols & source file paths configured) and check if it continues to work, or not.
Post Reply

Who is online

Users browsing this forum: No registered users and 15 guests