Difference between revisions of "Enable kernel tracing"

From ReactOS Wiki
Jump to: navigation, search
m (formatting)
m (+wikitable, add category)
Line 14: Line 14:
  
 
The trace variables are named and located as follows:
 
The trace variables are named and located as follows:
{|
+
{| class="wikitable"
 
! Abbr !! Name            !! File
 
! Abbr !! Name            !! File
 
|-------------------------------
 
|-------------------------------
Line 48: Line 48:
 
# Set ObpTraceLevel, located in ntoskrnl\ob\obinit.c, to OB_HANDLE_DEBUG and OB_NAMESPACE_DEBUG.<br /><pre>ULONG ObpTraceLevel = OB_HANDLE_DEBUG | OB_NAMESPACE_DEBUG;</pre>
 
# Set ObpTraceLevel, located in ntoskrnl\ob\obinit.c, to OB_HANDLE_DEBUG and OB_NAMESPACE_DEBUG.<br /><pre>ULONG ObpTraceLevel = OB_HANDLE_DEBUG | OB_NAMESPACE_DEBUG;</pre>
 
# Make a clean ntoskrnl recompile to compile in the traces<br /><pre>make ntoskrnl_clean ntoskrnl</pre>
 
# Make a clean ntoskrnl recompile to compile in the traces<br /><pre>make ntoskrnl_clean ntoskrnl</pre>
 +
 +
[[Category:Tutorial]]

Revision as of 15:43, 17 November 2009

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

to

#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:

Abbr Name File
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