ReactOS 0.4.15-dev-7931-gfd331f1
udf_dbg.h
Go to the documentation of this file.
1
2// Copyright (C) Alexander Telyatnikov, Ivan Keliukh, Yegor Anchishkin, SKIF Software, 1999-2013. Kiev, Ukraine
3// All rights reserved
4// This file was released under the GPLv2 on June 2015.
6/*
7 Module name:
8
9 Udf_dbg.h
10
11 Abstract:
12
13 This file contains small set of debug macroses.
14 It is used by the UDF project.
15
16*/
17
18#ifndef _UDF_DEBUG_H_
19#define _UDF_DEBUG_H_
20
21//======================================
22
23//#define ALWAYS_CHECK_WAIT_TIMEOUT
24//#define PRINT_ALWAYS
25
26#ifdef UDF_DBG
27
28//#define CHECK_ALLOC_FRAMES
29
30//#define TRACK_SYS_ALLOCS
31//#define TRACK_SYS_ALLOC_CALLERS
32
33// Use internal deadlock detector
34//#define USE_DLD
35
36#endif //UDF_DBG
37
38#define PROTECTED_MEM_RTL
39
40//#define UDF_SIMULATE_WRITES
41
42//#define USE_PERF_PRINT
43
44#define USE_KD_PRINT
45#define USE_MM_PRINT
46#define USE_AD_PRINT
47#define UDF_DUMP_EXTENT
48//#define USE_TH_PRINT
49//#define USE_TIME_PRINT
50//#define CHECK_REF_COUNTS
51
52//======================================
53
54#if defined UDF_DBG || defined PRINT_ALWAYS
55
56 ULONG
57 _cdecl
59 PCH Format,
60 ...
61 );
62
63
64 #ifdef KdPrint
65 #undef KdPrint
66 #endif
67
68 #ifdef USE_KD_PRINT
69 #define KdPrint(_x_) DbgPrint _x_
70 #else
71 #define KdPrint(a) {NOTHING;}
72 #endif //USE_KD_PRINT
73
74 #ifdef USE_MM_PRINT
75 #define MmPrint(_x_) DbgPrint _x_
76 #else
77 #define MmPrint(_x_) {NOTHING;}
78 #endif //USE_MM_PRINT
79
80 #ifdef USE_TIME_PRINT
81 extern ULONG UdfTimeStamp;
82 #define TmPrint(_x_) {UdfTimeStamp++;KdPrint(("TM:%d: ",UdfTimeStamp));KdPrint(_x_);}
83 #else
84 #define TmPrint KdPrint
85 #endif //USE_MM_PRINT
86
87 #ifdef USE_PERF_PRINT
88 #define PerfPrint(_x_) DbgPrint _x_
89 #else
90 #define PerfPrint(_x_) {NOTHING;}
91 #endif //USE_MM_PRINT
92
93 #ifdef USE_AD_PRINT
94 #define AdPrint(_x_) {DbgPrint("Thrd:%x:",PsGetCurrentThread());DbgPrint _x_;}
95 #else
96 #define AdPrint(_x_) {NOTHING;}
97 #endif
98
99 #ifdef USE_TH_PRINT
100 #define ThPrint(_x_) {DbgPrint("Thrd:%x:",PsGetCurrentThread());DbgPrint _x_;}
101 #else
102 #define ThPrint(_x_) {NOTHING;}
103 #endif
104
105 #ifdef UDF_DUMP_EXTENT
106 #define ExtPrint(_x_) KdPrint(_x_)
107 #else
108 #define ExtPrint(_x_) {NOTHING;}
109 #endif
110
111#else // defined UDF_DBG || defined PRINT_ALWAYS
112
113 #define MmPrint(_x_) {NOTHING;}
114 #define TmPrint(_x_) {NOTHING;}
115 #define PerfPrint(_x_) {NOTHING;}
116 #define AdPrint(_x_) {NOTHING;}
117 #define ThPrint(_x_) {NOTHING;}
118 #define ExtPrint(_x_) {NOTHING;}
119
120#endif // defined UDF_DBG || defined PRINT_ALWAYS
121
126 );
127
128#if defined ALWAYS_CHECK_WAIT_TIMEOUT
129 #define DbgWaitForSingleObject(o, to) DbgWaitForSingleObject_(o, to)
130#else
131 #define DbgWaitForSingleObject(o, to) KeWaitForSingleObject(o, Executive, KernelMode, FALSE, to);
132#endif
133
134#ifdef UDF_DBG
135
136#ifdef _X86_
137// This is an illegal use of INT3
138#define UDFBreakPoint() { __asm int 3 }
139#else // _X86_
140
141#define UDFBreakPoint() DbgBreakPoint()
142#endif // _X86_
143
144#ifdef BRUTE
145#define BrutePoint() UDFBreakPoint()
146#else
147#define BrutePoint() {}
148#endif // BRUTE
149
150#ifdef CHECK_REF_COUNTS
151#define ASSERT_REF(_a_) ASSERT(_a_)
152#else
153#define ASSERT_REF(_a_) {NOTHING;}
154#endif //CHECK_REF_COUNTS
155
156#ifdef TRACK_SYS_ALLOCS
157
158PVOID DebugAllocatePool(POOL_TYPE Type,ULONG size
159#ifdef TRACK_SYS_ALLOC_CALLERS
160, ULONG SrcId, ULONG SrcLine
161#endif //TRACK_SYS_ALLOC_CALLERS
162);
163VOID DebugFreePool(PVOID addr);
164
165#ifdef TRACK_SYS_ALLOC_CALLERS
166 #define DbgAllocatePoolWithTag(a,b,c) DebugAllocatePool(a,b,UDF_BUG_CHECK_ID,__LINE__)
167 #define DbgAllocatePool(x,y) DebugAllocatePool(x,y,UDF_BUG_CHECK_ID,__LINE__)
168#else //TRACK_SYS_ALLOC_CALLERS
169 #define DbgAllocatePoolWithTag(a,b,c) DebugAllocatePool(a,b)
170 #define DbgAllocatePool(x,y) DebugAllocatePool(x,y)
171#endif //TRACK_SYS_ALLOC_CALLERS
172#define DbgFreePool(x) DebugFreePool(x)
173
174#else //TRACK_SYS_ALLOCS
175
176#define DbgAllocatePoolWithTag(a,b,c) ExAllocatePoolWithTag(a,b,c)
177#define DbgAllocatePool(x,y) ExAllocatePoolWithTag(x,y,'Fnwd')
178#define DbgFreePool(x) ExFreePool(x)
179
180#endif //TRACK_SYS_ALLOCS
181
182
183#ifdef PROTECTED_MEM_RTL
184
185#define DbgMoveMemory(d, s, l) \
186_SEH2_TRY { \
187 RtlMoveMemory(d, s, l); \
188} _SEH2_EXCEPT (EXCEPTION_EXECUTE_HANDLER) { \
189 BrutePoint(); \
190} _SEH2_END;
191
192#define DbgCopyMemory(d, s, l) \
193_SEH2_TRY { \
194 RtlCopyMemory(d, s, l); \
195} _SEH2_EXCEPT (EXCEPTION_EXECUTE_HANDLER) { \
196 BrutePoint(); \
197} _SEH2_END;
198
199__inline
200ULONG
202 _SEH2_TRY {
203 return RtlCompareMemory(d, s, l);
205 BrutePoint();
206 } _SEH2_END;
207 return -1;
208}
209
210#else //PROTECTED_MEM_RTL
211
212#define DbgMoveMemory(d, s, l) RtlMoveMemory(d, s, l)
213#define DbgCopyMemory(d, s, l) RtlCopyMemory(d, s, l)
214#define DbgCompareMemory(d, s, l) RtlCompareMemory(d, s, l)
215
216#endif //PROTECTED_MEM_RTL
217
218//#define KdPrint(_x_)
219
220#ifdef VALIDATE_STRUCTURES
221#define ValidateFileInfo(fi) \
222{ /* validate FileInfo */ \
223 if(!fi || (fi)->IntegrityTag) { \
224 KdPrint(("UDF: ERROR! Using deallocated structure !!!\n"));\
225 BrutePoint(); \
226 } \
227 if(fi && !fi->Dloc) { \
228 KdPrint(("UDF: ERROR! FI without Dloc !!!\n"));\
229 BrutePoint(); \
230 } \
231}
232
233#else
234#define ValidateFileInfo(fi) {}
235#endif
236
237#if defined (_X86_) && defined (_MSC_VER)
238
239__inline VOID UDFTouch(IN PVOID addr)
240{
241 __asm {
242 mov eax,addr
243 mov al,[byte ptr eax]
244 }
245}
246
247#else // NO X86 optimization , use generic C/C++
248
249__inline VOID UDFTouch(IN PVOID addr)
250{
251 UCHAR a = ((PUCHAR)addr)[0];
252 a = a;
253}
254
255#endif // _X86_
256
257#else // UDF_DBG
258
259#define DbgAllocatePool(x,y) ExAllocatePoolWithTag(x,y,'Fnwd')
260#define DbgFreePool(x) ExFreePool(x)
261#define DbgAllocatePoolWithTag(a,b,c) ExAllocatePoolWithTag(a,b,c)
262
263#define DbgMoveMemory(d, s, l) RtlMoveMemory(d, s, l)
264#define DbgCopyMemory(d, s, l) RtlCopyMemory(d, s, l)
265#define DbgCompareMemory(d, s, l) RtlCompareMemory(d, s, l)
266
267#define ASSERT_REF(_a_) {NOTHING;}
268
269#define UDFBreakPoint() {}
270#define BrutePoint() {}
271#define ValidateFileInfo(fi) {}
272
273#define UDFTouch(addr) {}
274
275#endif // UDF_DBG
276
277#if defined UDF_DBG || defined PRINT_ALWAYS
278
279#define KdDump(a,b) \
280if((a)!=NULL) { \
281 ULONG i; \
282 for(i=0; i<(b); i++) { \
283 ULONG c; \
284 c = (ULONG)(*(((PUCHAR)(a))+i)); \
285 KdPrint(("%2.2x ",c)); \
286 if ((i & 0x0f) == 0x0f) KdPrint(("\n")); \
287 } \
288 KdPrint(("\n")); \
289}
290
291#else
292
293#define KdDump(a,b) {}
294
295#endif // UDF_DBG
296
297#define UserPrint KdPrint
298
299#endif // _UDF_DEBUG_H_
Type
Definition: Type.h:7
LONG NTSTATUS
Definition: precomp.h:26
r l[0]
Definition: byte_order.h:168
#define RtlCompareMemory(s1, s2, l)
Definition: env_spec_w32.h:465
#define _SEH2_END
Definition: filesup.c:22
#define _SEH2_TRY
Definition: filesup.c:19
GLdouble s
Definition: gl.h:2039
GLsizeiptr size
Definition: glext.h:5919
GLenum const GLvoid * addr
Definition: glext.h:9621
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6204
#define DbgPrint
Definition: hal.h:12
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
#define d
Definition: ke_i.h:81
#define a
Definition: ke_i.h:78
static PVOID ptr
Definition: dispmode.c:27
CHAR * PCH
Definition: ntbasedef.h:391
static ULONG Timeout
Definition: ping.c:61
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:34
PULONG MinorVersion OPTIONAL
Definition: CrossNt.h:68
ecx edi movl ebx edx edi decl ecx esi eax jecxz decl eax andl eax esi movl eax
Definition: synth_sse3d.h:85
INT POOL_TYPE
Definition: typedefs.h:78
#define IN
Definition: typedefs.h:39
unsigned char * PUCHAR
Definition: typedefs.h:53
uint32_t ULONG
Definition: typedefs.h:59
#define UDFTouch(addr)
Definition: udf_dbg.h:273
#define DbgCompareMemory(d, s, l)
Definition: udf_dbg.h:265
#define BrutePoint()
Definition: udf_dbg.h:270
NTSTATUS DbgWaitForSingleObject_(IN PVOID Object, IN PLARGE_INTEGER Timeout OPTIONAL)
_Must_inspect_result_ _In_ WDFCOLLECTION _In_ WDFOBJECT Object
unsigned char UCHAR
Definition: xmlstorage.h:181