[8384] | 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
|
---|
[10435] | 19 | #define DEBUG_LOGGING 1
|
---|
[8384] | 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
|
---|
[10435] | 34 | #define eprintf(a) WriteLog a
|
---|
[9707] | 35 | #define dassert(a, b) if(!(a)) dprintf b
|
---|
[8384] | 36 | #define dbgCheckObj(a) a->checkObject()
|
---|
[22041] | 37 | #define dprintfLock() WriteLogLock()
|
---|
| 38 | #define dprintfUnlock() WriteLogUnlock()
|
---|
[8384] | 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)
|
---|
[22041] | 60 | #define dprintfLock()
|
---|
| 61 | #define dprintfUnlock()
|
---|
[8384] | 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
|
---|
[21601] | 73 | #if !defined(NO_ULONG) && !defined(OS2DEF_INCLUDED)
|
---|
[8384] | 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 |
|
---|
[21916] | 84 | int SYSTEM WriteLog(const char *tekst, ...);
|
---|
| 85 | int SYSTEM WriteLogNoEOL(const char *tekst, ...);
|
---|
| 86 | int SYSTEM WritePrivateLog(void *logfile, const char *tekst, ...);
|
---|
[8384] | 87 |
|
---|
[22041] | 88 | void SYSTEM WriteLogLock();
|
---|
| 89 | void SYSTEM WriteLogUnlock();
|
---|
| 90 |
|
---|
[8384] | 91 | void SYSTEM DecreaseLogCount();
|
---|
| 92 | void SYSTEM IncreaseLogCount();
|
---|
| 93 |
|
---|
| 94 | void SYSTEM CheckVersion(ULONG version, char *modname);
|
---|
| 95 |
|
---|
| 96 | void SYSTEM CheckVersionFromHMOD(ULONG version, HMODULE hModule);
|
---|
| 97 |
|
---|
| 98 | int 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)
|
---|
| 104 | void OpenPrivateLogFiles();
|
---|
| 105 | void ClosePrivateLogFiles();
|
---|
| 106 |
|
---|
| 107 | /* enable support for the _interrupt() statement */
|
---|
[21916] | 108 | #if defined(__IBMCPP__) || defined(__IBMC__) || defined(__GNUC__)
|
---|
| 109 |
|
---|
| 110 | #ifndef __GNUC__
|
---|
[8384] | 111 | # include <builtin.h>
|
---|
[21916] | 112 | #endif
|
---|
| 113 |
|
---|
[8384] | 114 | #ifdef DEBUG
|
---|
[21916] | 115 |
|
---|
[8384] | 116 | #ifdef __cplusplus
|
---|
[10504] | 117 |
|
---|
[21916] | 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
|
---|
[10504] | 129 |
|
---|
[21916] | 130 | #else /* __cplusplus */
|
---|
[8384] | 131 | #define DebugInt3() _interrupt(3)
|
---|
| 132 | #endif
|
---|
[21916] | 133 |
|
---|
| 134 | #else /* DEBUG */
|
---|
[8384] | 135 | #define DebugInt3()
|
---|
| 136 | #endif
|
---|
| 137 |
|
---|
[21916] | 138 | #else /* defined(__IBMCPP__) || defined(__IBMC__) || defined(__GNUC__) */
|
---|
| 139 |
|
---|
[8384] | 140 | #ifdef DEBUG
|
---|
| 141 | #define DebugInt3() _asm int 3;
|
---|
| 142 | #else
|
---|
| 143 | #define DebugInt3()
|
---|
| 144 | #endif
|
---|
| 145 |
|
---|
[21916] | 146 | #endif /* defined(__IBMCPP__) || defined(__IBMC__) || defined(__GNUC__) */
|
---|
[8384] | 147 |
|
---|
| 148 | #ifdef __cplusplus
|
---|
| 149 | }
|
---|
| 150 | #endif
|
---|
| 151 |
|
---|
| 152 |
|
---|
| 153 | #endif //__DBGLOG_H__
|
---|
| 154 |
|
---|