source: trunk/include/dbglog.h@ 21916

Last change on this file since 21916 was 21916, checked in by dmik, 14 years ago

Merge branch gcc-kmk to trunk.

File size: 3.4 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 DisableLogging() DecreaseLogCount()
38 #define EnableLogging() IncreaseLogCount()
39
40#ifdef DEBUG_ENABLELOG_LEVEL2
41#ifdef PRIVATE_LOGGING
42 #define dprintf2(a) WritePrivateLog a
43#else
44 #define dprintf2(a) WriteLog a
45#endif
46#else
47 #define dprintf2(a)
48#endif
49
50#else
51 #define dprintfGlobal(a)
52 #define dprintf(a)
53 #define dprintf2(a)
54 #define dprintfNoEOL(a)
55 #define eprintf(a)
56 #define dassert(a, b)
57 #define dbgCheckObj(a)
58 #define DisableLogging()
59 #define EnableLogging()
60#endif
61
62
63// necessary types
64#ifndef __WINE_WINDEF_H
65#ifdef ULONG
66 #error ULONG definition is bad.
67 #define ULONG nope.
68#endif
69#if !defined(NO_ULONG) && !defined(OS2DEF_INCLUDED)
70 typedef unsigned long ULONG;
71 typedef unsigned long HMODULE;
72#endif
73#endif //!__WINE_WINDEF_H
74
75#ifndef SYSTEM
76# define SYSTEM _System
77#endif
78
79
80int SYSTEM WriteLog(const char *tekst, ...);
81int SYSTEM WriteLogNoEOL(const char *tekst, ...);
82int SYSTEM WritePrivateLog(void *logfile, const char *tekst, ...);
83
84void SYSTEM DecreaseLogCount();
85void SYSTEM IncreaseLogCount();
86
87void SYSTEM CheckVersion(ULONG version, char *modname);
88
89void SYSTEM CheckVersionFromHMOD(ULONG version, HMODULE hModule);
90
91int SYSTEM DebugErrorBox(ULONG iErrorCode,
92 char* pszFormat,
93 ...);
94
95//To use private logfiles for dlls, you must have these functions and call
96//them when the dll is loaded (open) and the exitlist handler is called (close)
97void OpenPrivateLogFiles();
98void ClosePrivateLogFiles();
99
100/* enable support for the _interrupt() statement */
101#if defined(__IBMCPP__) || defined(__IBMC__) || defined(__GNUC__)
102
103#ifndef __GNUC__
104# include <builtin.h>
105#endif
106
107#ifdef DEBUG
108
109#ifdef __cplusplus
110
111#ifdef PRIVATE_LOGGING
112#define DebugInt3() do { \
113 dprintf((LOG, "BREAKPOINT %s %s %d", __FILE__, __FUNCTION__, __LINE__)); \
114 _interrupt(3); \
115} while (0)
116#else
117#define DebugInt3() do { \
118 dprintf(("BREAKPOINT %s %s %d", __FILE__, __FUNCTION__, __LINE__)); \
119 _interrupt(3); \
120} while (0)
121#endif
122
123#else /* __cplusplus */
124 #define DebugInt3() _interrupt(3)
125#endif
126
127#else /* DEBUG */
128 #define DebugInt3()
129#endif
130
131#else /* defined(__IBMCPP__) || defined(__IBMC__) || defined(__GNUC__) */
132
133#ifdef DEBUG
134 #define DebugInt3() _asm int 3;
135#else
136 #define DebugInt3()
137#endif
138
139#endif /* defined(__IBMCPP__) || defined(__IBMC__) || defined(__GNUC__) */
140
141#ifdef __cplusplus
142 }
143#endif
144
145
146#endif //__DBGLOG_H__
147
Note: See TracBrowser for help on using the repository browser.