Author: fireball
Date: Fri Dec 14 16:02:39 2007
New Revision: 31213
URL:
http://svn.reactos.org/svn/reactos?rev=31213&view=rev
Log:
- Add debugging macros support to CmLib (to use, set the CmlibTraceLevel debugging mask in
cminit.c).
- Add tracing to hivecell.c.
Modified:
trunk/reactos/lib/cmlib/cminit.c
trunk/reactos/lib/cmlib/cmlib.h
trunk/reactos/lib/cmlib/hivecell.c
trunk/reactos/lib/cmlib/hivewrt.c
trunk/reactos/tools/mkhive/rtl.c
Modified: trunk/reactos/lib/cmlib/cminit.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/cmlib/cminit.c?rev=312…
==============================================================================
--- trunk/reactos/lib/cmlib/cminit.c (original)
+++ trunk/reactos/lib/cmlib/cminit.c Fri Dec 14 16:02:39 2007
@@ -6,6 +6,8 @@
*/
#include "cmlib.h"
+
+ULONG CmlibTraceLevel = 0;
BOOLEAN CMAPI
CmCreateRootNode(
Modified: trunk/reactos/lib/cmlib/cmlib.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/cmlib/cmlib.h?rev=3121…
==============================================================================
--- trunk/reactos/lib/cmlib/cmlib.h (original)
+++ trunk/reactos/lib/cmlib/cmlib.h Fri Dec 14 16:02:39 2007
@@ -23,6 +23,30 @@
#define STATUS_NOT_REGISTRY_FILE ((NTSTATUS)0xC000015C)
#define STATUS_REGISTRY_RECOVERED ((NTSTATUS)0x40000009)
+#endif
+
+//
+// Debug support switch
+//
+#define _CMLIB_DEBUG_ 1
+
+//
+// These define the Debug Masks Supported
+//
+#define CMLIB_HCELL_DEBUG 0x01
+
+//
+// Debug/Tracing support
+//
+#if _CMLIB_DEBUG_
+#ifdef NEW_DEBUG_SYSTEM_IMPLEMENTED // enable when Debug Filters are implemented
+#define CMLTRACE DbgPrintEx
+#else
+#define CMLTRACE(x, ...) \
+ if (x & CmlibTraceLevel) DbgPrint(__VA_ARGS__)
+#endif
+#else
+#define CMLTRACE(x, ...) DPRINT(__VA_ARGS__)
#endif
#ifndef _TYPEDEFS_HOST_H
@@ -158,6 +182,7 @@
#endif
+extern ULONG CmlibTraceLevel;
/*
* Public functions.
Modified: trunk/reactos/lib/cmlib/hivecell.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/cmlib/hivecell.c?rev=3…
==============================================================================
--- trunk/reactos/lib/cmlib/hivecell.c (original)
+++ trunk/reactos/lib/cmlib/hivecell.c Fri Dec 14 16:02:39 2007
@@ -15,6 +15,9 @@
HCELL_INDEX CellIndex)
{
PVOID Block;
+
+ CMLTRACE(CMLIB_HCELL_DEBUG, "%s - Hive %p, CellIndex %08lx\n",
+ __FUNCTION__, RegistryHive, CellIndex);
ASSERT(CellIndex != HCELL_NIL);
if (!RegistryHive->Flat)
@@ -105,6 +108,9 @@
ULONG CellLastBlock;
ASSERT(RegistryHive->ReadOnly == FALSE);
+
+ CMLTRACE(CMLIB_HCELL_DEBUG, "%s - Hive %p, CellIndex %08lx, HoldingLock
%b\n",
+ __FUNCTION__, RegistryHive, CellIndex, HoldingLock);
if ((CellIndex & HCELL_TYPE_MASK) >> HCELL_TYPE_SHIFT != Stable)
return FALSE;
@@ -321,6 +327,9 @@
ASSERT(RegistryHive->ReadOnly == FALSE);
+ CMLTRACE(CMLIB_HCELL_DEBUG, "%s - Hive %p, Size %x, %s, Vicinity %08lx\n",
+ __FUNCTION__, RegistryHive, Size, (Storage == 0) ? "Stable" :
"Volatile", Vicinity);
+
/* Round to 16 bytes multiple. */
Size = ROUND_UP(Size + sizeof(HCELL), 16);
@@ -356,6 +365,9 @@
FreeCell->Size = -FreeCell->Size;
RtlZeroMemory(FreeCell + 1, Size - sizeof(HCELL));
+ CMLTRACE(CMLIB_HCELL_DEBUG, "%s - CellIndex %08lx\n",
+ __FUNCTION__, FreeCellOffset);
+
return FreeCellOffset;
}
@@ -372,6 +384,9 @@
HSTORAGE_TYPE Storage;
ASSERT(CellIndex != HCELL_NIL);
+
+ CMLTRACE(CMLIB_HCELL_DEBUG, "%s - Hive %p, CellIndex %08lx, Size %x\n",
+ __FUNCTION__, RegistryHive, CellIndex, Size);
Storage = (CellIndex & HCELL_TYPE_MASK) >> HCELL_TYPE_SHIFT;
@@ -415,6 +430,9 @@
ULONG CellBlock;
ASSERT(RegistryHive->ReadOnly == FALSE);
+
+ CMLTRACE(CMLIB_HCELL_DEBUG, "%s - Hive %p, CellIndex %08lx\n",
+ __FUNCTION__, RegistryHive, CellIndex);
Free = HvpGetCellHeader(RegistryHive, CellIndex);
Modified: trunk/reactos/lib/cmlib/hivewrt.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/cmlib/hivewrt.c?rev=31…
==============================================================================
--- trunk/reactos/lib/cmlib/hivewrt.c (original)
+++ trunk/reactos/lib/cmlib/hivewrt.c Fri Dec 14 16:02:39 2007
@@ -163,7 +163,7 @@
RegistryHive->BaseBlock->Type = HFILE_TYPE_PRIMARY;
RegistryHive->BaseBlock->Sequence1++;
RegistryHive->BaseBlock->CheckSum =
- HvpHiveHeaderChecksum(RegistryHive->BaseBlock);
+ HvpHiveHeaderChecksum(RegistryHive->BaseBlock);
/* Write hive block */
FileOffset = 0;
Modified: trunk/reactos/tools/mkhive/rtl.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/tools/mkhive/rtl.c?rev=312…
==============================================================================
--- trunk/reactos/tools/mkhive/rtl.c (original)
+++ trunk/reactos/tools/mkhive/rtl.c Fri Dec 14 16:02:39 2007
@@ -5,6 +5,7 @@
*/
#include <stdlib.h>
+#include <stdarg.h>
#include "mkhive.h"
#include <bitmap.c>
@@ -157,3 +158,14 @@
free(p);
}
+ULONG
+__cdecl
+DbgPrint(
+ IN CHAR *Format,
+ IN ...)
+{
+ va_list ap;
+ va_start(ap, Format);
+ vprintf(Format, ap);
+ va_end(ap);
+}