- Add debugging macros support to CmLib (to use, set the CmlibTraceLevel debugging mask in cminit.c).

- Add tracing to hivecell.c.

svn path=/trunk/; revision=31213
This commit is contained in:
Aleksey Bragin 2007-12-14 13:02:39 +00:00
parent 4aae9354ae
commit 61fab841f2
5 changed files with 58 additions and 1 deletions

View file

@ -7,6 +7,8 @@
#include "cmlib.h"
ULONG CmlibTraceLevel = 0;
BOOLEAN CMAPI
CmCreateRootNode(
PHHIVE Hive,

View file

@ -25,6 +25,30 @@
#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
#include <ntddk.h>
@ -158,6 +182,7 @@ typedef struct _CMHIVE
#endif
extern ULONG CmlibTraceLevel;
/*
* Public functions.

View file

@ -16,6 +16,9 @@ HvpGetCellHeader(
{
PVOID Block;
CMLTRACE(CMLIB_HCELL_DEBUG, "%s - Hive %p, CellIndex %08lx\n",
__FUNCTION__, RegistryHive, CellIndex);
ASSERT(CellIndex != HCELL_NIL);
if (!RegistryHive->Flat)
{
@ -106,6 +109,9 @@ HvMarkCellDirty(
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 @@ HvAllocateCell(
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 @@ HvAllocateCell(
FreeCell->Size = -FreeCell->Size;
RtlZeroMemory(FreeCell + 1, Size - sizeof(HCELL));
CMLTRACE(CMLIB_HCELL_DEBUG, "%s - CellIndex %08lx\n",
__FUNCTION__, FreeCellOffset);
return FreeCellOffset;
}
@ -373,6 +385,9 @@ HvReallocateCell(
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;
OldCell = HvGetCell(RegistryHive, CellIndex);
@ -416,6 +431,9 @@ HvFreeCell(
ASSERT(RegistryHive->ReadOnly == FALSE);
CMLTRACE(CMLIB_HCELL_DEBUG, "%s - Hive %p, CellIndex %08lx\n",
__FUNCTION__, RegistryHive, CellIndex);
Free = HvpGetCellHeader(RegistryHive, CellIndex);
ASSERT(Free->Size < 0);

View file

@ -163,7 +163,7 @@ HvpWriteHive(
RegistryHive->BaseBlock->Type = HFILE_TYPE_PRIMARY;
RegistryHive->BaseBlock->Sequence1++;
RegistryHive->BaseBlock->CheckSum =
HvpHiveHeaderChecksum(RegistryHive->BaseBlock);
HvpHiveHeaderChecksum(RegistryHive->BaseBlock);
/* Write hive block */
FileOffset = 0;

View file

@ -5,6 +5,7 @@
*/
#include <stdlib.h>
#include <stdarg.h>
#include "mkhive.h"
#include <bitmap.c>
@ -157,3 +158,14 @@ ExFreePool(
free(p);
}
ULONG
__cdecl
DbgPrint(
IN CHAR *Format,
IN ...)
{
va_list ap;
va_start(ap, Format);
vprintf(Format, ap);
va_end(ap);
}