source: trunk/include/dbglog.h

Last change on this file was 22041, checked in by dmik, 13 years ago

kernel32: Add public debug log lock/unlock methods for higher level serialization.

File size: 3.6 KB
Line 
1/*
2 * Miscellaneous definitions
3 * Debug prototypes and macros
4 */
5
6
7#ifndef __DBGLOG_H__
8#define __DBGLOG_H__
9
10#if !defined(_OS2WIN_H) && !defined(__INCLUDE_WINUSER_H) && !defined(__WINE_WINBASE_H) && !defined(__WINE_WINDEF_H)
11 #include <win32type.h>
12#endif
13
14#ifdef __cplusplus
15 extern "C" {
16#endif
17
18#ifdef DEBUG
19#define DEBUG_LOGGING 1
20#ifdef PRIVATE_LOGGING
21 //To use private dll logging, define PRIVATE_LOGGING and
22 //add Open/ClosePrivateLogFiles (see below) functions to the dll
23 //to open close the private logfile. The logfile handle should
24 //be stored in the _privateLogFile variable
25 //dprintf can be called like this:
26 //dprintf((LOG, "PE file : %s", szFileName));
27 #define LOG (void*)_privateLogFile
28 #define dprintf(a) WritePrivateLog a
29 #define dprintfGlobal(a) WriteLog a
30#else
31 #define dprintf(a) WriteLog a
32 #define dprintfNoEOL(a) WriteLogNoEOL a
33#endif
34 #define eprintf(a) WriteLog a
35 #define dassert(a, b) if(!(a)) dprintf b
36 #define dbgCheckObj(a) a->checkObject()
37 #define dprintfLock() WriteLogLock()
38 #define dprintfUnlock() WriteLogUnlock()
39 #define DisableLogging() DecreaseLogCount()
40 #define EnableLogging() IncreaseLogCount()
41
42#ifdef DEBUG_ENABLELOG_LEVEL2
43#ifdef PRIVATE_LOGGING
44 #define dprintf2(a) WritePrivateLog a
45#else
46 #define dprintf2(a) WriteLog a
47#endif
48#else
49 #define dprintf2(a)
50#endif
51
52#else
53 #define dprintfGlobal(a)
54 #define dprintf(a)
55 #define dprintf2(a)
56 #define dprintfNoEOL(a)
57 #define eprintf(a)
58 #define dassert(a, b)
59 #define dbgCheckObj(a)
60 #define dprintfLock()
61 #define dprintfUnlock()
62 #define DisableLogging()
63 #define EnableLogging()
64#endif
65
66
67// necessary types
68#ifndef __WINE_WINDEF_H
69#ifdef ULONG
70 #error ULONG definition is bad.
71 #define ULONG nope.
72#endif
73#if !defined(NO_ULONG) && !defined(OS2DEF_INCLUDED)
74 typedef unsigned long ULONG;
75 typedef unsigned long HMODULE;
76#endif
77#endif //!__WINE_WINDEF_H
78
79#ifndef SYSTEM
80# define SYSTEM _System
81#endif
82
83
84int SYSTEM WriteLog(const char *tekst, ...);
85int SYSTEM WriteLogNoEOL(const char *tekst, ...);
86int SYSTEM WritePrivateLog(void *logfile, const char *tekst, ...);
87
88void SYSTEM WriteLogLock();
89void SYSTEM WriteLogUnlock();
90
91void SYSTEM DecreaseLogCount();
92void SYSTEM IncreaseLogCount();
93
94void SYSTEM CheckVersion(ULONG version, char *modname);
95
96void SYSTEM CheckVersionFromHMOD(ULONG version, HMODULE hModule);
97
98int SYSTEM DebugErrorBox(ULONG iErrorCode,
99 char* pszFormat,
100 ...);
101
102//To use private logfiles for dlls, you must have these functions and call
103//them when the dll is loaded (open) and the exitlist handler is called (close)
104void OpenPrivateLogFiles();
105void ClosePrivateLogFiles();
106
107/* enable support for the _interrupt() statement */
108#if defined(__IBMCPP__) || defined(__IBMC__) || defined(__GNUC__)
109
110#ifndef __GNUC__
111# include <builtin.h>
112#endif
113
114#ifdef DEBUG
115
116#ifdef __cplusplus
117
118#ifdef PRIVATE_LOGGING
119#define DebugInt3() do { \
120 dprintf((LOG, "BREAKPOINT %s %s %d", __FILE__, __FUNCTION__, __LINE__)); \
121 _interrupt(3); \
122} while (0)
123#else
124#define DebugInt3() do { \
125 dprintf(("BREAKPOINT %s %s %d", __FILE__, __FUNCTION__, __LINE__)); \
126 _interrupt(3); \
127} while (0)
128#endif
129
130#else /* __cplusplus */
131 #define DebugInt3() _interrupt(3)
132#endif
133
134#else /* DEBUG */
135 #define DebugInt3()
136#endif
137
138#else /* defined(__IBMCPP__) || defined(__IBMC__) || defined(__GNUC__) */
139
140#ifdef DEBUG
141 #define DebugInt3() _asm int 3;
142#else
143 #define DebugInt3()
144#endif
145
146#endif /* defined(__IBMCPP__) || defined(__IBMC__) || defined(__GNUC__) */
147
148#ifdef __cplusplus
149 }
150#endif
151
152
153#endif //__DBGLOG_H__
154
Note: See TracBrowser for help on using the repository browser.