[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()
|
---|
| 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
|
---|
[21601] | 69 | #if !defined(NO_ULONG) && !defined(OS2DEF_INCLUDED)
|
---|
[8384] | 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 |
|
---|
[21916] | 80 | int SYSTEM WriteLog(const char *tekst, ...);
|
---|
| 81 | int SYSTEM WriteLogNoEOL(const char *tekst, ...);
|
---|
| 82 | int SYSTEM WritePrivateLog(void *logfile, const char *tekst, ...);
|
---|
[8384] | 83 |
|
---|
| 84 | void SYSTEM DecreaseLogCount();
|
---|
| 85 | void SYSTEM IncreaseLogCount();
|
---|
| 86 |
|
---|
| 87 | void SYSTEM CheckVersion(ULONG version, char *modname);
|
---|
| 88 |
|
---|
| 89 | void SYSTEM CheckVersionFromHMOD(ULONG version, HMODULE hModule);
|
---|
| 90 |
|
---|
| 91 | int 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)
|
---|
| 97 | void OpenPrivateLogFiles();
|
---|
| 98 | void ClosePrivateLogFiles();
|
---|
| 99 |
|
---|
| 100 | /* enable support for the _interrupt() statement */
|
---|
[21916] | 101 | #if defined(__IBMCPP__) || defined(__IBMC__) || defined(__GNUC__)
|
---|
| 102 |
|
---|
| 103 | #ifndef __GNUC__
|
---|
[8384] | 104 | # include <builtin.h>
|
---|
[21916] | 105 | #endif
|
---|
| 106 |
|
---|
[8384] | 107 | #ifdef DEBUG
|
---|
[21916] | 108 |
|
---|
[8384] | 109 | #ifdef __cplusplus
|
---|
[10504] | 110 |
|
---|
[21916] | 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
|
---|
[10504] | 122 |
|
---|
[21916] | 123 | #else /* __cplusplus */
|
---|
[8384] | 124 | #define DebugInt3() _interrupt(3)
|
---|
| 125 | #endif
|
---|
[21916] | 126 |
|
---|
| 127 | #else /* DEBUG */
|
---|
[8384] | 128 | #define DebugInt3()
|
---|
| 129 | #endif
|
---|
| 130 |
|
---|
[21916] | 131 | #else /* defined(__IBMCPP__) || defined(__IBMC__) || defined(__GNUC__) */
|
---|
| 132 |
|
---|
[8384] | 133 | #ifdef DEBUG
|
---|
| 134 | #define DebugInt3() _asm int 3;
|
---|
| 135 | #else
|
---|
| 136 | #define DebugInt3()
|
---|
| 137 | #endif
|
---|
| 138 |
|
---|
[21916] | 139 | #endif /* defined(__IBMCPP__) || defined(__IBMC__) || defined(__GNUC__) */
|
---|
[8384] | 140 |
|
---|
| 141 | #ifdef __cplusplus
|
---|
| 142 | }
|
---|
| 143 | #endif
|
---|
| 144 |
|
---|
| 145 |
|
---|
| 146 | #endif //__DBGLOG_H__
|
---|
| 147 |
|
---|