📄 dbug32.h
字号:
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//
// Use of this source code is subject to the terms of the Microsoft shared
// source or premium shared source license agreement under which you licensed
// this source code. If you did not accept the terms of the license agreement,
// you are not authorized to use this source code. For the terms of the license,
// please see the license agreement between you and Microsoft or, if applicable,
// see the SOURCE.RTF on your install media or the root of your tools installation.
// THE SOURCE CODE IS PROVIDED "AS IS", WITH NO WARRANTIES.
//
//DBUG.DLL main header
#ifndef DBUG_H
#define DBUG_H
#define DllExport __declspec(dllexport)
#define DllImport __declspec(dllimport)
//USERDBUG is defined by users who want to use IMallocSpy
//but not the rest of the stuff in here.
#ifdef USERDBUG
#if defined(DEBUG) || defined(_DEBUG)
#ifdef __cplusplus
extern "C"
{
DllImport BOOL WINAPI InstallIMallocSpy(void);
DllImport void WINAPI RemoveIMallocSpy(BOOL fCheck);
DllImport void WINAPI IMallocSpyReport(void);
}
#else
DllImport BOOL WINAPI InstallIMallocSpy(void);
DllImport void WINAPI RemoveIMallocSpy(BOOL fCheck);
DllImport void WINAPI IMallocSpyReport(void);
#endif //_cplusplus
//Macros for Install/Remove IMallocSpy
#define INSTALLIMALLOCSPY() InstallIMallocSpy()
#define REMOVEIMALLOCSPY(f) RemoveIMallocSpy(f)
#define IMALLOCSPYREPORT() IMallocSpyReport()
#else
#define INSTALLIMALLOCSPY()
#define REMOVEIMALLOCSPY(f)
#define IMALLOCSPYREPORT()
#endif //DEBUG
#else //USERDBUG
//
//This is stuff from dbugit.h that is here for compatibility
//with existing code.
//
#if defined(DEBUG) || defined(MEMCHECK) || defined(_DEBUG)
typedef struct _assertfile
{
char *szFile;
INT ifte;
} ASSERTFILE;
#if !defined(MACPORT)
#define ASSERTDATA static char _szFile[] = __FILE__; \
static ASSERTFILE _asfile = {_szFile, -1};
#else
#ifdef AssertData // Mso's version of AssertData to work with its asserts.
#define ASSERTDATA AssertData
#else
need to include msodebug.h before DBUG32.h
#endif
#endif
#else // DEBUG || MEMCHECK
#define ASSERTDATA
#endif // DEBUG || MEMCHECK, else
#if defined(DEBUG) || defined(_DEBUG)
#define FFromTag FALSE
//TODO this isn't used and references should be removed.
extern BOOL fInAssert;
#endif
//
//This is new stuff for dbug32.dll
//
// GuyBark: Problems finding dbug32.dll at runtime on the desktop, so remove dbug32.dll calls.
//#if !defined(PEGASUS) && !defined(MACPORT) && (defined(DEBUG) || defined(_DEBUG))
#if defined NEVER
//macport change until dbug32 accessed
//we are also not doing this for WinCE right now
//#if defined(DEBUG) || defined(_DEBUG) //orig code
//This is the buffer length used for building messages
#define MAXDEBUGSTRLEN (MAX_PATH + MAX_PATH)
//The following constants are used to specify and interpret
//packed values in the DWORD flags parameter passed to TraceMsg.
//Each of these is held in a 4-bit field in the DWORD.
//Subsystem field values
#define TRCSUBSYSNONE 0x0
#define TRCSUBSYSDISP 0x1
#define TRCSUBSYSWRAP 0x2
#define TRCSUBSYSEDIT 0x3
#define TRCSUBSYSTS 0x4
#define TRCSUBSYSTOM 0x5
#define TRCSUBSYSOLE 0x6
#define TRCSUBSYSBACK 0x7
#define TRCSUBSYSSEL 0x8
#define TRCSUBSYSHOST 0x9
#define TRCSUBSYSDTE 0xa
#define TRCSUBSYSUNDO 0xb
#define TRCSUBSYSRANG 0xc
#define TRCSUBSYSUTIL 0xd
#define TRCSUBSYSNOTM 0xe
#define TRCSUBSYSRTFR 0xf
#define TRCSUBSYSRTFW 0x10
#define TRCSUBSYSPRT 0x11
#define TRCSUBSYSFE 0x12
#define TRCSUBSYSFONT 0x13
//Severity field values
#define TRCSEVNONE 0x0
#define TRCSEVWARN 0x1
#define TRCSEVERR 0x2
#define TRCSEVASSERT 0x3
#define TRCSEVINFO 0x4
#define TRCSEVMEM 0x5
//Scope field values
#define TRCSCOPENONE 0x0
#define TRCSCOPEEXTERN 0x1
#define TRCSCOPEINTERN 0x2
//Data field values
#define TRCDATANONE 0x0
#define TRCDATAHRESULT 0x1
#define TRCDATASTRING 0x2
#define TRCDATAPARAM 0x3
#define TRCDATADEFAULT 0x4
//Debug option flags. See the macros in this header for setting and testing
//these option flags.
#define OPTUSEDEFAULTS 0x00000001 //Use defaults from win.ini
//(used only with InitDebugServices).
#define OPTHEAPVALON 0x00000002 //Heap validation for all traces
#define OPTHEAPVALEXT 0x00000004 //Heap validation for external traces only
#define OPTLOGGINGON 0x00000008 //Logging of trace output
#define OPTVERBOSEON 0x00000010 //Subsys, Scope & PID/TID
#define OPTINFOON 0x00000020 //Informational messages
#define OPTTRACEON 0x00000040 //All function tracing on
#define OPTTRACEEXT 0x00000080 //Function tracing only for external functions
#define OPTMEMORYON 0x00000100 //Memory alloc/free tracing on
//The following options allow tracing to be enabled for one or more
//specific subsystems. If OPTTRACEON is set, these will have no effect.
//if OPTTRACEEXT is set, they will enable tracing for all functions in
//the designated subsystem in addition to external functions.
//The SETOPT and ISOPTSET macros should be used for setting and checking
//these options. INITDEBUGSERVICES can also be used.
#define OPTTRACEDISP 0x00001000 //Function tracing for Display subsystem
#define OPTTRACEWRAP 0x00002000 //Function tracing for Wrapper subsystem
#define OPTTRACEEDIT 0x00004000 //Function tracing for Edit subsystem
#define OPTTRACETS 0x00008000 //Function tracing for TextServices subsystem
#define OPTTRACETOM 0x00010000 //Function tracing for TOM subsystem
#define OPTTRACEOLE 0x00020000 //Function tracing for OLE support subsystem
#define OPTTRACEBACK 0x00040000 //Function tracing for Backing Store subsystem
#define OPTTRACESEL 0x00080000 //Function tracing for Selection subsystem
#define OPTTRACEHOST 0x00100000 //Function tracing for WinHost subsystem
#define OPTTRACEDTE 0x00200000 //Function tracing for DataXfer subsystem
#define OPTTRACEUNDO 0x00400000 //Function tracing for Muli-undo subsystem
#define OPTTRACERANG 0x00800000 //Function tracing for Range subsystem
#define OPTTRACEUTIL 0x01000000 //Function tracing for Utility subsystem
#define OPTTRACENOTM 0x02000000 //Function tracing for Notification Mgr subsystem
#define OPTTRACERTFR 0x04000000 //Function tracing for RTF reader subsystem
#define OPTTRACERTFW 0x08000000 //Function tracing for RTF writer subsystem
#define OPTTRACEPRT 0x10000000 //Function tracing for Printing subsystem
#define OPTTRACEFE 0x20000000 //Function tracing for Far East subsystem
#define OPTTRACEFONT 0x40000000 //Function tracing for Font Cache
//Union for handling tracing flags
//This union is used to decode the
//packed DWORD passed to TraceMsg.
typedef union
{
struct
{
unsigned uData2 :4;
unsigned uData1 :4;
unsigned uScope :4;
unsigned uSeverity :4;
unsigned uSubSystem :8;
unsigned uUnused1 :4;
unsigned uUnused2 :4;
} fields;
DWORD dw;
} TrcFlags;
//Exported classes and functions.
//Generally, these should not be used directly by the user.
//They should be used via the macros defined in this header.
//This helps to ensure that the parameter lists are well
//formed and keeps references to them from showing up in
//in non-debug builds.
//This class is used to implement the function Entry/Exit
//tracing. By declaring it on the stack at the beginning
//of a function, Entry and Exit messages are automatically
//generated by the constructor and destructor.
class DllExport CTrace
{
public:
CTrace(DWORD, DWORD, DWORD, LPSTR);
~CTrace();
private:
TrcFlags trcf;
char szFileName[MAXDEBUGSTRLEN];
char szFuncName[80];
};
typedef BOOL (CALLBACK * PFNASSERTHOOK)(LPSTR, LPSTR, int*);
typedef BOOL (CALLBACK * PFNTRACEHOOK)(DWORD*, DWORD*, DWORD*, LPSTR, int*);
DllImport PFNASSERTHOOK pfnAssert;
DllImport PFNTRACEHOOK pfnTrace;
DllImport DWORD dwDebugOptions;
DllImport void WINAPI Dbug32AssertSzFn(LPSTR, LPSTR, int);
DllImport void WINAPI TraceMsg(DWORD, DWORD, DWORD, LPSTR, int);
DllImport void WINAPI InitDebugServices(DWORD, PFNASSERTHOOK, PFNTRACEHOOK);
DllImport void WINAPI SetLogging(BOOL);
DllImport void WINAPI Tracef(DWORD, LPSTR szFmt, ...);
DllImport void WINAPI TraceError(LPSTR sz, LONG sc);
extern "C"
{
DllImport BOOL WINAPI InstallIMallocSpy(void);
DllImport void WINAPI RemoveIMallocSpy(BOOL fCheck);
DllImport void WINAPI IMallocSpyReport(void);
DllImport void WINAPI TrackBlock(void *pMem);
}
//This is a utility macro for internal use. The user should not need this.
#define MAKEFLAGS(ss, sv, sc, d1, d2) ((ss << 16) + (sv << 12) + (sc << 8)\
+ (d1 << 4) + (d2))
//The following macros provide access to the debug services in this dll.
//Assert macros pop a dialog. Trace macros output to debug output and
//logfile if enabled.
//Macro for InitDebugServices
#define INITDEBUGSERVICES(f, pfnA, pfnT) InitDebugServices(f, pfnA, pfnT)
//Macros for Install/Remove IMallocSpy
#define INSTALLIMALLOCSPY() InstallIMallocSpy()
#define REMOVEIMALLOCSPY(f) RemoveIMallocSpy(f)
#define IMALLOCSPYREPORT() IMallocSpyReport()
//Macro for TraceError
#define TRACEERRSZSC(sz, sc) TraceError(sz, sc)
//Assert based on boolean f.
#ifndef Assert
#define Assert(f) AssertSz((f), NULL)
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -