00001
00002
00003
00004
00005
00006 #ifndef __WXDEBUG__
00007 #define __WXDEBUG__
00008
00009 enum { LOG_TIMING = 0x01,
00010 LOG_TRACE = 0x02,
00011 LOG_MEMORY = 0x04,
00012 LOG_LOCKING = 0x08,
00013 LOG_ERROR = 0x10,
00014 LOG_CUSTOM1 = 0x20,
00015 LOG_CUSTOM2 = 0x40,
00016 LOG_CUSTOM3 = 0x80,
00017 LOG_CUSTOM4 = 0x100,
00018 LOG_CUSTOM5 = 0x200,
00019 };
00020
00021 #define LOG_FORCIBLY_SET 0x80000000
00022
00023 enum { CDISP_HEX = 0x01,
00024 CDISP_DEC = 0x02};
00025
00026 typedef struct tag_ObjectDesc {
00027 const CHAR *m_szName;
00028 const WCHAR *m_wszName;
00029 DWORD m_dwCookie;
00030 tag_ObjectDesc *m_pNext;
00031 } ObjectDesc;
00032
00033 #define DLLIMPORT __declspec(dllimport)
00034 #define DLLEXPORT __declspec(dllexport)
00035
00036 #ifdef DEBUG
00037
00038 #define NAME(x) TEXT(x)
00039
00040
00041
00042 void WINAPI DbgInitKeyLevels(HKEY hKey, bool fTakeMax);
00043 void WINAPI DbgInitGlobalSettings(bool fTakeMax);
00044 void WINAPI DbgInitModuleSettings(bool fTakeMax);
00045 void WINAPI DbgInitModuleName();
00046 DWORD WINAPI DbgRegisterObjectCreation(
00047 const CHAR *szObjectName, const WCHAR *wszObjectName);
00048
00049 BOOL WINAPI DbgRegisterObjectDestruction(DWORD dwCookie);
00050
00051
00052
00053 BOOL WINAPI DbgCheckModuleLevel(DWORD Type,DWORD Level);
00054 void WINAPI DbgSetModuleLevel(DWORD Type,DWORD Level);
00055 void WINAPI DbgSetAutoRefreshLevels(bool fAuto);
00056
00057
00058
00059 void WINAPI DbgInitialise(HINSTANCE hInst);
00060 void WINAPI DbgTerminate();
00061
00062 void WINAPI DbgDumpObjectRegister();
00063
00064
00065
00066 void WINAPI DbgAssert(const TCHAR *pCondition,const TCHAR *pFileName,INT iLine);
00067 void WINAPI DbgBreakPoint(const TCHAR *pCondition,const TCHAR *pFileName,INT iLine);
00068 void WINAPI DbgBreakPoint(const TCHAR *pFileName,INT iLine,const TCHAR* szFormatString,...);
00069
00070 void WINAPI DbgKernelAssert(const TCHAR *pCondition,const TCHAR *pFileName,INT iLine);
00071 void WINAPI DbgLogInfo(DWORD Type,DWORD Level,const TCHAR *pFormat,...);
00072 #ifdef UNICODE
00073 void WINAPI DbgLogInfo(DWORD Type,DWORD Level,const CHAR *pFormat,...);
00074 void WINAPI DbgAssert(const CHAR *pCondition,const CHAR *pFileName,INT iLine);
00075 void WINAPI DbgBreakPoint(const CHAR *pCondition,const CHAR *pFileName,INT iLine);
00076 void WINAPI DbgKernelAssert(const CHAR *pCondition,const CHAR *pFileName,INT iLine);
00077 #endif
00078 void WINAPI DbgOutString(LPCTSTR psz);
00079
00080
00081 DWORD WINAPI DbgWaitForSingleObject(HANDLE h);
00082 DWORD WINAPI DbgWaitForMultipleObjects(DWORD nCount,
00083 CONST HANDLE *lpHandles,
00084 BOOL bWaitAll);
00085 void WINAPI DbgSetWaitTimeout(DWORD dwTimeout);
00086
00087 #ifdef __strmif_h__
00088
00089 void WINAPI DisplayType(LPTSTR label, const AM_MEDIA_TYPE *pmtIn);
00090
00091
00092 void WINAPI DumpGraph(IFilterGraph *pGraph, DWORD dwLevel);
00093 #endif
00094
00095 #define KASSERT(_x_) if (!(_x_)) \
00096 DbgKernelAssert(TEXT(#_x_),TEXT(__FILE__),__LINE__)
00097
00098
00099
00100
00101 #define KDbgBreak(_x_) \
00102 DbgKernelAssert(TEXT(#_x_),TEXT(__FILE__),__LINE__)
00103
00104
00105
00106
00107
00108 #ifndef ASSERT
00109 #define ASSERT(_x_) if (!(_x_)) \
00110 DbgAssert(TEXT(#_x_),TEXT(__FILE__),__LINE__)
00111 #endif
00112
00113 #define DbgAssertAligned( _ptr_, _alignment_ ) ASSERT( ((DWORD_PTR) (_ptr_)) % (_alignment_) == 0)
00114
00115
00116
00117
00118 #define DbgBreak(_x_) \
00119 DbgBreakPoint(TEXT(#_x_),TEXT(__FILE__),__LINE__)
00120
00121 #define EXECUTE_ASSERT(_x_) ASSERT(_x_)
00122 #define DbgLog(_x_) DbgLogInfo _x_
00123
00124
00125 #define NOTE(_x_) DbgLog((LOG_TRACE,5,TEXT(_x_)))
00126 #define NOTE1(_x_,a) DbgLog((LOG_TRACE,5,TEXT(_x_),a))
00127 #define NOTE2(_x_,a,b) DbgLog((LOG_TRACE,5,TEXT(_x_),a,b))
00128 #define NOTE3(_x_,a,b,c) DbgLog((LOG_TRACE,5,TEXT(_x_),a,b,c))
00129 #define NOTE4(_x_,a,b,c,d) DbgLog((LOG_TRACE,5,TEXT(_x_),a,b,c,d))
00130 #define NOTE5(_x_,a,b,c,d,e) DbgLog((LOG_TRACE,5,TEXT(_x_),a,b,c,d,e))
00131
00132 #else
00133
00134
00135
00136
00137
00138
00139 #define NAME(_x_) ((TCHAR *) NULL)
00140
00141 #define DbgInitialise(hInst)
00142 #define DbgTerminate()
00143 #define DbgLog(_x_) 0
00144 #define DbgOutString(psz)
00145 #define DbgAssertAligned( _ptr_, _alignment_ ) 0
00146
00147 #define DbgRegisterObjectCreation(pObjectName)
00148 #define DbgRegisterObjectDestruction(dwCookie)
00149 #define DbgDumpObjectRegister()
00150
00151 #define DbgCheckModuleLevel(Type,Level)
00152 #define DbgSetModuleLevel(Type,Level)
00153 #define DbgSetAutoRefreshLevels(fAuto)
00154
00155 #define DbgWaitForSingleObject(h) WaitForSingleObject(h, INFINITE)
00156 #define DbgWaitForMultipleObjects(nCount, lpHandles, bWaitAll) \
00157 WaitForMultipleObjects(nCount, lpHandles, bWaitAll, INFINITE)
00158 #define DbgSetWaitTimeout(dwTimeout)
00159
00160 #define KDbgBreak(_x_)
00161 #define DbgBreak(_x_)
00162
00163 #define KASSERT(_x_) ((void)0)
00164 #ifndef ASSERT
00165 #define ASSERT(_x_) ((void)0)
00166 #endif
00167 #define EXECUTE_ASSERT(_x_) ((void)(_x_))
00168
00169
00170
00171 #define NOTE(_x_) ((void)0)
00172 #define NOTE1(_x_,a) ((void)0)
00173 #define NOTE2(_x_,a,b) ((void)0)
00174 #define NOTE3(_x_,a,b,c) ((void)0)
00175 #define NOTE4(_x_,a,b,c,d) ((void)0)
00176 #define NOTE5(_x_,a,b,c,d,e) ((void)0)
00177
00178 #define DisplayType(label, pmtIn) ((void)0)
00179 #define DumpGraph(pGraph, label) ((void)0)
00180 #endif
00181
00182 #define CheckPointer(p,ret) {if((p)==NULL) return (ret);}
00183
00184 #ifdef DEBUG
00185 #define VFWROBUST
00186 #endif
00187
00188 #ifdef VFWROBUST
00189
00190 #define ValidateReadPtr(p,cb) \
00191 {if(IsBadReadPtr((PVOID)p,cb) == TRUE) \
00192 DbgBreak("Invalid read pointer");}
00193
00194 #define ValidateWritePtr(p,cb) \
00195 {if(IsBadWritePtr((PVOID)p,cb) == TRUE) \
00196 DbgBreak("Invalid write pointer");}
00197
00198 #define ValidateReadWritePtr(p,cb) \
00199 {ValidateReadPtr(p,cb) ValidateWritePtr(p,cb)}
00200
00201 #define ValidateStringPtr(p) \
00202 {if(IsBadStringPtr((LPCTSTR)p,INFINITE) == TRUE) \
00203 DbgBreak("Invalid string pointer");}
00204
00205 #define ValidateStringPtrA(p) \
00206 {if(IsBadStringPtrA((LPCSTR)p,INFINITE) == TRUE) \
00207 DbgBreak("Invalid ANSI string pointer");}
00208
00209 #define ValidateStringPtrW(p) \
00210 {if(IsBadStringPtrW((LPCWSTR)p,INFINITE) == TRUE) \
00211 DbgBreak("Invalid UNICODE string pointer");}
00212
00213 #else
00214 #define ValidateReadPtr(p,cb) 0
00215 #define ValidateWritePtr(p,cb) 0
00216 #define ValidateReadWritePtr(p,cb) 0
00217 #define ValidateStringPtr(p) 0
00218 #define ValidateStringPtrA(p) 0
00219 #define ValidateStringPtrW(p) 0
00220 #endif
00221
00222 #ifdef _OBJBASE_H_
00223
00224
00225
00226
00227
00228
00229
00230
00231 typedef struct {
00232 CHAR *szName;
00233 GUID guid;
00234 } GUID_STRING_ENTRY;
00235
00236 class CGuidNameList {
00237 public:
00238 CHAR *operator [] (const GUID& guid);
00239 };
00240
00241 extern CGuidNameList GuidNames;
00242
00243 #endif
00244
00245 #ifndef REMIND
00246
00247
00248
00249
00250
00251 #define QUOTE(x) #x
00252 #define QQUOTE(y) QUOTE(y)
00253 #define REMIND(str) __FILE__ "(" QQUOTE(__LINE__) ") : " str
00254 #endif
00255
00256 class CDispBasic
00257 {
00258 public:
00259 CDispBasic() { m_pString = m_String; };
00260 ~CDispBasic();
00261 protected:
00262 PTCHAR m_pString;
00263 TCHAR m_String[50];
00264 };
00265 class CDisp : public CDispBasic
00266 {
00267 public:
00268 CDisp(LONGLONG ll, int Format = CDISP_HEX);
00269 CDisp(REFCLSID clsid);
00270 CDisp(double d);
00271 #ifdef __strmif_h__
00272 #ifdef __STREAMS__
00273 CDisp(CRefTime t);
00274 #endif
00275 CDisp(IPin *pPin);
00276 CDisp(IUnknown *pUnk);
00277 #endif
00278 ~CDisp();
00279
00280
00281 operator LPCTSTR()
00282 {
00283 return (LPCTSTR)m_pString;
00284 };
00285 };
00286
00287
00288 #if defined(DEBUG)
00289 class CAutoTrace
00290 {
00291 private:
00292 const TCHAR* _szBlkName;
00293 const int _level;
00294 static const TCHAR _szEntering[];
00295 static const TCHAR _szLeaving[];
00296 public:
00297 CAutoTrace(const TCHAR* szBlkName, const int level = 2)
00298 : _szBlkName(szBlkName), _level(level)
00299 {DbgLog((LOG_TRACE, _level, _szEntering, _szBlkName));}
00300
00301 ~CAutoTrace()
00302 {DbgLog((LOG_TRACE, _level, _szLeaving, _szBlkName));}
00303 };
00304
00305 #define AMTRACE(_x_) CAutoTrace __trace _x_
00306 #else
00307 #define AMTRACE(_x_)
00308 #endif
00309
00310 #endif
00311