a513968708101fa6671bdd7b488b60d4d44435e3
[reactos.git] / reactos / win32ss / gdi / ntgdi / gdidebug.h
1 #pragma once
2
3 typedef enum _LOG_EVENT_TYPE
4 {
5 EVENT_ALLOCATE,
6 EVENT_CREATE_HANDLE,
7 EVENT_REFERENCE,
8 EVENT_DEREFERENCE,
9 EVENT_LOCK,
10 EVENT_UNLOCK,
11 EVENT_DELETE,
12 EVENT_FREE,
13 EVENT_SET_OWNER,
14 } LOG_EVENT_TYPE;
15
16 typedef struct _LOGENTRY
17 {
18 SLIST_ENTRY sleLink;
19 LOG_EVENT_TYPE nEventType;
20 DWORD dwProcessId;
21 DWORD dwThreadId;
22 ULONG ulUnique;
23 LPARAM lParam;
24 PVOID apvBackTrace[20];
25 union
26 {
27 ULONG_PTR data1;
28 } data;
29 } LOGENTRY, *PLOGENTRY;
30
31 #if KDBG
32 BOOLEAN
33 NTAPI
34 DbgGdiKdbgCliCallback(
35 IN PCHAR Command,
36 IN ULONG Argc,
37 IN PCH Argv[]);
38 #endif
39
40 #if DBG_ENABLE_EVENT_LOGGING
41 VOID NTAPI DbgDumpEventList(PSLIST_HEADER pslh);
42 VOID NTAPI DbgLogEvent(PSLIST_HEADER pslh, LOG_EVENT_TYPE nEventType, LPARAM lParam);
43 VOID NTAPI DbgCleanupEventList(PSLIST_HEADER pslh);
44 VOID NTAPI DbgPrintEvent(PLOGENTRY pLogEntry);
45 #define DBG_LOGEVENT(pslh, type, val) DbgLogEvent(pslh, type, (ULONG_PTR)val)
46 #define DBG_INITLOG(pslh) InitializeSListHead(pslh)
47 #define DBG_DUMP_EVENT_LIST(pslh) DbgDumpEventList(pslh)
48 #define DBG_CLEANUP_EVENT_LIST(pslh) DbgCleanupEventList(pslh)
49 #else
50 #define DBG_LOGEVENT(pslh, type, val) ((void)(val))
51 #define DBG_INITLOG(pslh)
52 #define DBG_DUMP_EVENT_LIST(pslh)
53 #define DBG_CLEANUP_EVENT_LIST(pslh)
54 #endif
55
56
57 VOID NTAPI DbgDumpGdiHandleTableWithBT(VOID);
58 ULONG NTAPI DbgCaptureStackBackTace(PVOID* pFrames, ULONG nFramesToCapture);
59 BOOL NTAPI DbgGdiHTIntegrityCheck(VOID);
60 VOID NTAPI DbgDumpLockedGdiHandles(VOID);
61
62 #define KeRosDumpStackFrames(Frames, Count) KdSystemDebugControl('DsoR', (PVOID)Frames, Count, NULL, 0, NULL, KernelMode)
63 NTSYSAPI ULONG APIENTRY RtlWalkFrameChain(OUT PVOID *Callers, IN ULONG Count, IN ULONG Flags);
64
65 #if DBG
66 void
67 NTAPI
68 GdiDbgPreServiceHook(ULONG ulSyscallId, PULONG_PTR pulArguments);
69
70 ULONG_PTR
71 NTAPI
72 GdiDbgPostServiceHook(ULONG ulSyscallId, ULONG_PTR ulResult);
73
74 #define ID_Win32PreServiceHook 'WSH0'
75 #define ID_Win32PostServiceHook 'WSH1'
76
77 FORCEINLINE void
78 GdiDbgAssertNoLocks(char * pszFile, ULONG nLine)
79 {
80 PTHREADINFO pti = (PTHREADINFO)PsGetCurrentThreadWin32Thread();
81 if (pti && pti->cExclusiveLocks != 0)
82 {
83 DbgPrint("(%s:%lu) There are %lu exclusive locks!\n",
84 pszFile, nLine, pti->cExclusiveLocks);
85 ASSERT(FALSE);
86 }
87 }
88
89 #define ASSERT_NOGDILOCKS() GdiDbgAssertNoLocks(__FILE__,__LINE__)
90 #else
91 #define ASSERT_NOGDILOCKS()
92 #endif
93