[WIN32K]
authorTimo Kreuzer <timo.kreuzer@reactos.org>
Fri, 18 Feb 2011 14:35:44 +0000 (14:35 +0000)
committerTimo Kreuzer <timo.kreuzer@reactos.org>
Fri, 18 Feb 2011 14:35:44 +0000 (14:35 +0000)
compile gdidebug code as a seperate file and give it a seperate header

svn path=/trunk/; revision=50799

reactos/subsystems/win32/win32k/include/gdidebug.h [new file with mode: 0644]
reactos/subsystems/win32/win32k/include/win32kp.h
reactos/subsystems/win32/win32k/objects/gdidbg.c
reactos/subsystems/win32/win32k/objects/gdiobj.c
reactos/subsystems/win32/win32k/win32k.rbuild

diff --git a/reactos/subsystems/win32/win32k/include/gdidebug.h b/reactos/subsystems/win32/win32k/include/gdidebug.h
new file mode 100644 (file)
index 0000000..42c20f9
--- /dev/null
@@ -0,0 +1,75 @@
+#pragma once
+
+extern ULONG gulDebugChannels;
+
+enum _DEBUGCHANNELS
+{
+    DbgCustom = 1,
+    DbgObjects = 2,
+    DbgBitBlt = 4,
+    DbgXlate = 8,
+    DbgModeSwitch = 16,
+};
+
+#define DBGENABLE(ch) gulDebugChannels |= (ch);
+#define DBGDISABLE(ch) gulDebugChannels &= ~(ch);
+#define DPRINTCH(ch) if (gulDebugChannels & (ch)) DbgPrint
+
+#ifdef GDI_DEBUG
+
+#define KeRosDumpStackFrames(Frames, Count) KdSystemDebugControl('DsoR', (PVOID)Frames, Count, NULL, 0, NULL, KernelMode)
+NTSYSAPI ULONG APIENTRY RtlWalkFrameChain(OUT PVOID *Callers, IN ULONG Count, IN ULONG Flags);
+
+#define IS_HANDLE_VALID(idx) \
+    ((GdiHandleTable->Entries[idx].Type & GDI_ENTRY_BASETYPE_MASK) != 0)
+
+#define GDIDBG_TRACECALLER() \
+  DPRINT1("-> called from:\n"); \
+  KeRosDumpStackFrames(NULL, 20);
+#define GDIDBG_TRACEALLOCATOR(handle) \
+  DPRINT1("-> allocated from:\n"); \
+  KeRosDumpStackFrames(GDIHandleAllocator[GDI_HANDLE_GET_INDEX(handle)], GDI_STACK_LEVELS);
+#define GDIDBG_TRACELOCKER(handle) \
+  DPRINT1("-> locked from:\n"); \
+  KeRosDumpStackFrames(GDIHandleLocker[GDI_HANDLE_GET_INDEX(handle)], GDI_STACK_LEVELS);
+#define GDIDBG_TRACESHARELOCKER(handle) \
+  DPRINT1("-> locked from:\n"); \
+  KeRosDumpStackFrames(GDIHandleShareLocker[GDI_HANDLE_GET_INDEX(handle)], GDI_STACK_LEVELS);
+#define GDIDBG_TRACEDELETER(handle) \
+  DPRINT1("-> deleted from:\n"); \
+  KeRosDumpStackFrames(GDIHandleDeleter[GDI_HANDLE_GET_INDEX(handle)], GDI_STACK_LEVELS);
+#define GDIDBG_CAPTUREALLOCATOR(handle) \
+  CaptureStackBackTace((PVOID*)GDIHandleAllocator[GDI_HANDLE_GET_INDEX(handle)], GDI_STACK_LEVELS);
+#define GDIDBG_CAPTURELOCKER(handle) \
+  CaptureStackBackTace((PVOID*)GDIHandleLocker[GDI_HANDLE_GET_INDEX(handle)], GDI_STACK_LEVELS);
+#define GDIDBG_CAPTURESHARELOCKER(handle) \
+  CaptureStackBackTace((PVOID*)GDIHandleShareLocker[GDI_HANDLE_GET_INDEX(handle)], GDI_STACK_LEVELS);
+#define GDIDBG_CAPTUREDELETER(handle) \
+  CaptureStackBackTace((PVOID*)GDIHandleDeleter[GDI_HANDLE_GET_INDEX(handle)], GDI_STACK_LEVELS);
+#define GDIDBG_DUMPHANDLETABLE() \
+  IntDumpHandleTable(GdiHandleTable)
+#define GDIDBG_INITLOOPTRACE() \
+  ULONG Attempts = 0;
+#define GDIDBG_TRACELOOP(Handle, PrevThread, Thread) \
+  if ((++Attempts % 20) == 0) \
+  { \
+    DPRINT1("[%d] Handle 0x%p Locked by 0x%x (we're 0x%x)\n", Attempts, Handle, PrevThread, Thread); \
+  }
+
+#else
+
+#define GDIDBG_TRACECALLER()
+#define GDIDBG_TRACEALLOCATOR(index)
+#define GDIDBG_TRACELOCKER(index)
+#define GDIDBG_TRACESHARELOCKER(index)
+#define GDIDBG_CAPTUREALLOCATOR(index)
+#define GDIDBG_CAPTURELOCKER(index)
+#define GDIDBG_CAPTURESHARELOCKER(index)
+#define GDIDBG_CAPTUREDELETER(handle)
+#define GDIDBG_DUMPHANDLETABLE()
+#define GDIDBG_INITLOOPTRACE()
+#define GDIDBG_TRACELOOP(Handle, PrevThread, Thread)
+#define GDIDBG_TRACEDELETER(handle)
+
+#endif /* GDI_DEBUG */
+
index 7842bb2..94bf319 100644 (file)
@@ -87,3 +87,4 @@
 #include <include/ldevobj.h>
 #include <include/device.h>
 #include <dib/dib.h>
 #include <include/ldevobj.h>
 #include <include/device.h>
 #include <dib/dib.h>
+#include <include/gdidebug.h>
index efa686f..3a0ac31 100644 (file)
@@ -1,7 +1,21 @@
-#ifdef GDI_DEBUG
+/*
+ * PROJECT:         ReactOS win32 kernel mode subsystem
+ * LICENSE:         GPL - See COPYING in the top level directory
+ * FILE:            subsystems/win32/win32k/objects/gdidbg.c
+ * PURPOSE:         Special debugging functions for gdi
+ * PROGRAMMERS:     Timo Kreuzer
+ */
+
+/** INCLUDES ******************************************************************/
+
+#include <win32k.h>
+#define NDEBUG
+#include <debug.h>
 
 
-#define KeRosDumpStackFrames(Frames, Count) KdSystemDebugControl('DsoR', (PVOID)Frames, Count, NULL, 0, NULL, KernelMode)
-NTSYSAPI ULONG APIENTRY RtlWalkFrameChain(OUT PVOID *Callers, IN ULONG Count, IN ULONG Flags);
+
+ULONG gulDebugChannels = 0;
+
+#ifdef GDI_DEBUG
 
 #define GDI_STACK_LEVELS 20
 static ULONG_PTR GDIHandleAllocator[GDI_HANDLE_COUNT][GDI_STACK_LEVELS+1];
 
 #define GDI_STACK_LEVELS 20
 static ULONG_PTR GDIHandleAllocator[GDI_HANDLE_COUNT][GDI_STACK_LEVELS+1];
@@ -37,9 +51,6 @@ CompareBacktraces(ULONG idx1, ULONG idx2)
     return TRUE;
 }
 
     return TRUE;
 }
 
-#define IS_HANDLE_VALID(idx) \
-    ((GdiHandleTable->Entries[idx].Type & GDI_ENTRY_BASETYPE_MASK) != 0)
-
 void IntDumpHandleTable(PGDI_HANDLE_TABLE HandleTable)
 {
     static int leak_reported = 0;
 void IntDumpHandleTable(PGDI_HANDLE_TABLE HandleTable)
 {
     static int leak_reported = 0;
@@ -110,8 +121,8 @@ void IntDumpHandleTable(PGDI_HANDLE_TABLE HandleTable)
     for (i = 0; i < nTraces && AllocatorTable[i].count > 1; i++)
     {
         /* Print out the allocation count */
     for (i = 0; i < nTraces && AllocatorTable[i].count > 1; i++)
     {
         /* Print out the allocation count */
-        DbgPrint(" %i allocs, type = 0x%lx:\n", 
-                 AllocatorTable[i].count, 
+        DbgPrint(" %i allocs, type = 0x%lx:\n",
+                 AllocatorTable[i].count,
                  GdiHandleTable->Entries[AllocatorTable[i].idx].Type);
 
         /* Dump the frames */
                  GdiHandleTable->Entries[AllocatorTable[i].idx].Type);
 
         /* Dump the frames */
@@ -272,39 +283,6 @@ GdiDbgHTIntegrityCheck()
        return r;
 }
 
        return r;
 }
 
-#define GDIDBG_TRACECALLER() \
-  DPRINT1("-> called from:\n"); \
-  KeRosDumpStackFrames(NULL, 20);
-#define GDIDBG_TRACEALLOCATOR(handle) \
-  DPRINT1("-> allocated from:\n"); \
-  KeRosDumpStackFrames(GDIHandleAllocator[GDI_HANDLE_GET_INDEX(handle)], GDI_STACK_LEVELS);
-#define GDIDBG_TRACELOCKER(handle) \
-  DPRINT1("-> locked from:\n"); \
-  KeRosDumpStackFrames(GDIHandleLocker[GDI_HANDLE_GET_INDEX(handle)], GDI_STACK_LEVELS);
-#define GDIDBG_TRACESHARELOCKER(handle) \
-  DPRINT1("-> locked from:\n"); \
-  KeRosDumpStackFrames(GDIHandleShareLocker[GDI_HANDLE_GET_INDEX(handle)], GDI_STACK_LEVELS);
-#define GDIDBG_TRACEDELETER(handle) \
-  DPRINT1("-> deleted from:\n"); \
-  KeRosDumpStackFrames(GDIHandleDeleter[GDI_HANDLE_GET_INDEX(handle)], GDI_STACK_LEVELS);
-#define GDIDBG_CAPTUREALLOCATOR(handle) \
-  CaptureStackBackTace((PVOID*)GDIHandleAllocator[GDI_HANDLE_GET_INDEX(handle)], GDI_STACK_LEVELS);
-#define GDIDBG_CAPTURELOCKER(handle) \
-  CaptureStackBackTace((PVOID*)GDIHandleLocker[GDI_HANDLE_GET_INDEX(handle)], GDI_STACK_LEVELS);
-#define GDIDBG_CAPTURESHARELOCKER(handle) \
-  CaptureStackBackTace((PVOID*)GDIHandleShareLocker[GDI_HANDLE_GET_INDEX(handle)], GDI_STACK_LEVELS);
-#define GDIDBG_CAPTUREDELETER(handle) \
-  CaptureStackBackTace((PVOID*)GDIHandleDeleter[GDI_HANDLE_GET_INDEX(handle)], GDI_STACK_LEVELS);
-#define GDIDBG_DUMPHANDLETABLE() \
-  IntDumpHandleTable(GdiHandleTable)
-#define GDIDBG_INITLOOPTRACE() \
-  ULONG Attempts = 0;
-#define GDIDBG_TRACELOOP(Handle, PrevThread, Thread) \
-  if ((++Attempts % 20) == 0) \
-  { \
-    DPRINT1("[%d] Handle 0x%p Locked by 0x%x (we're 0x%x)\n", Attempts, Handle, PrevThread, Thread); \
-  }
-
 ULONG
 FASTCALL
 GDIOBJ_IncrementShareCount(POBJ Object)
 ULONG
 FASTCALL
 GDIOBJ_IncrementShareCount(POBJ Object)
@@ -315,20 +293,5 @@ GDIOBJ_IncrementShareCount(POBJ Object)
     return cLocks;
 }
 
     return cLocks;
 }
 
-#else
-
-#define GDIDBG_TRACECALLER()
-#define GDIDBG_TRACEALLOCATOR(index)
-#define GDIDBG_TRACELOCKER(index)
-#define GDIDBG_TRACESHARELOCKER(index)
-#define GDIDBG_CAPTUREALLOCATOR(index)
-#define GDIDBG_CAPTURELOCKER(index)
-#define GDIDBG_CAPTURESHARELOCKER(index)
-#define GDIDBG_CAPTUREDELETER(handle)
-#define GDIDBG_DUMPHANDLETABLE()
-#define GDIDBG_INITLOOPTRACE()
-#define GDIDBG_TRACELOOP(Handle, PrevThread, Thread)
-#define GDIDBG_TRACEDELETER(handle)
-
 #endif /* GDI_DEBUG */
 
 #endif /* GDI_DEBUG */
 
index beeee0a..deb62e6 100644 (file)
@@ -8,8 +8,6 @@
 
 /** INCLUDES ******************************************************************/
 
 
 /** INCLUDES ******************************************************************/
 
-//#define GDI_DEBUG
-
 #include <win32k.h>
 #define NDEBUG
 #include <debug.h>
 #include <win32k.h>
 #define NDEBUG
 #include <debug.h>
@@ -28,8 +26,6 @@
   DPRINT("%s:%i: Delay\n", __FILE__, __LINE__); \
   KeDelayExecutionThread(KernelMode, FALSE, &ShortDelay)
 
   DPRINT("%s:%i: Delay\n", __FILE__, __LINE__); \
   KeDelayExecutionThread(KernelMode, FALSE, &ShortDelay)
 
-#include "gdidbg.c"
-
 static
 BOOL INTERNAL_CALL GDI_CleanupDummy(PVOID ObjectBody);
 
 static
 BOOL INTERNAL_CALL GDI_CleanupDummy(PVOID ObjectBody);
 
index a472d21..fa51a09 100644 (file)
                <file>freetype.c</file>
                <file>gdibatch.c</file>
                <file>gdiobj.c</file>
                <file>freetype.c</file>
                <file>gdibatch.c</file>
                <file>gdiobj.c</file>
+               <file>gdidbg.c</file>
                <file>icm.c</file>
                <file>line.c</file>
                <file>metafile.c</file>
                <file>icm.c</file>
                <file>line.c</file>
                <file>metafile.c</file>