Enable kernel tracing
The ReactOS kernel implements a per module tracing mechanism compiled in and enabled on demand.
Kernel tracing is currently implemented in the following modules: CM, DBGK, IO, LPC, OB and PS
To enable tracing for a module, first locate its header file in ntoskrnl/include/internal/ and change
#define _X_DEBUG_ 0x00
#define _X_DEBUG_ 1
_X_DEBUG_ is located at the top of the header, X being the module abbreviation.
This will compile in (but not enable) tracing for the module and requires a clean kernel recompile to have an effect.
To enable the trace, find the per-module trace variable and set it to one or more debug masks.
The debug masks applying to a module are located in the module's header file below _X_DEBUG_.
The trace variables are named and located as follows:
CM: CmpTraceLevel - ntoskrnl/config/cmsysini.c
DBGK: DbgkpTraceLevel - ntoskrnl/dbgk/dbgkobj.c
IO: IopTraceLevel - ntoskrnl/io/iomgr.c
LPC: LpcpTraceLevel - ntoskrnl/lpc/port.c
OB: ObpTraceLevel - ntoskrnl/ob/obinit.c
PS: PspTraceLevel - ntoskrnl/ps/query.c
The variables are initially set to 0:
ULONG PspTraceLevel = 0;
To set a mask simply assign it to the variable:
ULONG PspTraceLevel = PS_THREAD_DEBUG;
When setting multiple masks separate them with the C OR bitwise operator:
ULONG PspTraceLevel = PS_THREAD_DEBUG | PS_PROCESS_DEBUG;
To enable all output from a module assign -1 (0xFFFFFFFF, all bits set) to the variable:
ULONG PspTraceLevel = -1;
Note that you don't need a clean recompile if you are only setting debug masks.
Example: Enabling Ob Handle and Namespace tracing
1. Enable _OB_DEBUG_ in ntoskrnl\include\internal\ob.h --- #define _OB_DEBUG_ 1
2. Set ObpTraceLevel, located in ntoskrnl\ob\obinit.c, to OB_HANDLE_DEBUG and OB_NAMESPACE_DEBUG. --- ULONG ObpTraceLevel = OB_HANDLE_DEBUG | OB_NAMESPACE_DEBUG;
3. Make a clean ntoskrnl recompile to compile in the traces --- make ntoskrnl_clean ntoskrnl