37#pragma comment(linker,"/include:___DebugIncludeInLink1")
87 const unsigned char *m_startPtr;
89 unsigned m_bytePerItem;
96 MemDump(
const void *ptr,
unsigned num,
unsigned bpi,
bool absAddr,
bool withChars):
97 m_startPtr((
const unsigned char *)ptr), m_numItems(num),
98 m_bytePerItem(bpi), m_absAddr(absAddr), m_withChars(withChars) {}
108 static MemDump
Raw(
const void *startPtr,
unsigned numItems,
unsigned bytePerItem=1)
110 return MemDump(startPtr,numItems,bytePerItem,
true,
false);
120 static MemDump
RawRel(
const void *startPtr,
unsigned numItems,
unsigned bytePerItem=1)
122 return MemDump(startPtr,numItems,bytePerItem,
false,
false);
132 static MemDump
Char(
const void *startPtr,
unsigned numItems,
unsigned bytePerItem=1)
134 return MemDump(startPtr,numItems,bytePerItem,
true,
true);
144 static MemDump
CharRel(
const void *startPtr,
unsigned numItems,
unsigned bytePerItem=1)
146 return MemDump(startPtr,numItems,bytePerItem,
false,
true);
178 explicit HResult(
long hresult): m_hresult(hresult) {}
190 LogDescription& operator=(
const LogDescription&);
252 explicit Width(
int width): m_width(width) {}
297 explicit RepeatChar(
char ch,
int count): m_char(ch), m_count(count) {}
315 Format(
const Format &);
316 Format& operator=(
const Format&);
322 explicit Format(
const char *format, ...);
378 static Debug &
AssertBegin(
const char *file,
int line,
const char *expr);
406 static Debug &
CheckBegin(
const char *file,
int line,
const char *expr);
430 static Debug &
LogBegin(
const char *fileOrGroup);
456 static Debug &
CrashBegin(
const char *file,
int line);
666 static bool AddIOFactory(
const char *io_id,
const char *descr,
703 static void Command(
const char *cmd);
720 static bool SimpleMatch(
const char *str,
const char *pattern);
732 const char *internalVersion,
733 const char *buildDate);
743 Debug& operator=(
const Debug&);
761 static void PreStaticInit(
void);
768 static void PostStaticInit(
void);
776 static void StaticExit(
void);
783 static Debug Instance;
790 static void *PreStatic;
797 static void *PostStatic;
800 struct HResultTranslatorEntry
813 HResultTranslatorEntry *hrTranslators;
816 unsigned numHrTranslators;
819 struct IOFactoryListEntry
822 IOFactoryListEntry *next;
852 IOFactoryListEntry *firstIOFactory;
855 struct CmdInterfaceListEntry
858 CmdInterfaceListEntry *next;
864 DebugCmdInterface *cmdif;
873 CmdInterfaceListEntry *firstCmdGroup;
876 static unsigned curStackFrame;
888 FrameTypeAssert = 0x00000001,
891 FrameTypeCheck = 0x00000002,
894 FrameTypeLog = 0x00000004
918 struct FrameHashEntry
921 FrameHashEntry *next;
930 const char *fileOrGroup;
943 enum { FRAME_HASH_SIZE = 10007 };
946 FrameHashEntry *frameHash[FRAME_HASH_SIZE];
949 enum { FRAME_HASH_ALLOC_COUNT = 100 };
952 FrameHashEntry *nextUnusedFrameHash;
955 unsigned numAvailableFrameHash;
964 __forceinline FrameHashEntry *LookupFrame(
unsigned addr)
966 for (FrameHashEntry *e=frameHash[addr%FRAME_HASH_SIZE];e;e=e->next)
967 if (e->frameAddr==addr)
984 FrameHashEntry *AddFrameEntry(
unsigned addr,
unsigned type,
985 const char *fileOrGroup,
int line);
994 void UpdateFrameStatus(FrameHashEntry &entry);
1006 FrameHashEntry *GetFrameEntry(
unsigned addr,
unsigned type,
1007 const char *fileOrGroup,
int line)
1009 FrameHashEntry *e=LookupFrame(addr);
1011 e=AddFrameEntry(addr,type,fileOrGroup,line);
1012 if (e->status==Unknown)
1013 UpdateFrameStatus(*e);
1026 struct KnownLogGroupList
1029 KnownLogGroupList *next;
1039 KnownLogGroupList *firstLogGroup;
1053 const char *AddLogGroup(
const char *fileOrGroup,
const char *descr);
1075 char curSource[256];
1078 int disableAssertsEtc;
1096 void AddOutput(
const char *str,
unsigned len);
1105 void FlushOutput(
bool defaultLog=
true);
1108 FrameHashEntry *curFrameEntry;
1111 struct PatternListEntry
1114 PatternListEntry *next;
1117 unsigned frameTypes;
1132 PatternListEntry *firstPatternEntry;
1135 PatternListEntry *lastPatternEntry;
1146 void AddPatternEntry(
unsigned types,
bool isActive,
const char *pattern);
1155 void ExecCommand(
const char *cmdstart,
const char *cmdend);
1165 bool IsWindowed(
void);
1168 char curCommandGroup[100];
1177 DebugStackwalk m_stackWalk;
1189 char m_intVersion[64];
1192 char m_buildDate[64];
Switches integer output to binary format.
Switches integer output to decimal format.
FillChar(char ch=' ')
Sets new fill character.
Helper class for writing HRESULTs to the debug stream.
Switches integer output to hexadecimal format.
Helper class for performing a raw memory dump.
static MemDump CharRel(const void *startPtr, unsigned numItems, unsigned bytePerItem=1)
static MemDump Raw(const void *startPtr, unsigned numItems, unsigned bytePerItem=1)
static MemDump Char(const void *startPtr, unsigned numItems, unsigned bytePerItem=1)
static MemDump RawRel(const void *startPtr, unsigned numItems, unsigned bytePerItem=1)
RepeatChar(char ch, int count)
Repeats a given character N times.
Sets output width for the next insertion.
Width(int width)
Sets new output width (next insertion only).
Debug command group interface.
Debug module main class (singleton).
void WriteBuildInfo(void)
Write build information into log.
static void Command(const char *cmd)
Issues a debug command.
unsigned used
used buffer size
Debug & operator<<(const Format &f)
static void RemoveCommands(DebugCmdInterface *cmdif)
Removes a command group.
Debug & operator<<(Hex &)
static void Update(void)
Update method, must be called on a regular basis.
static Debug & AssertBegin(const char *file, int line, const char *expr)
Debug & operator<<(Width &w)
static bool IsLogEnabled(const char *fileOrGroup)
Debug & operator<<(Dec &)
static void AddHResultTranslator(unsigned prio, HResultTranslator func, void *user=0)
Adds a HRESULT translator.
static bool AddCommands(const char *cmdgroup, DebugCmdInterface *cmdif)
Adds a new command group.
static bool AddIOFactory(const char *io_id, const char *descr, DebugIOInterface *(*func)(void))
Registers a new I/O class factory function.
bool(* HResultTranslator)(Debug &debug, long hresult, void *user)
HRESULT translator callback function type.
friend class LogDescription
static void RemoveHResultTranslator(HResultTranslator func, void *user=0)
Removes a HRESULT translator.
Debug & operator<<(FillChar &c)
static void InstallExceptionHandler(void)
Installs exception handler for current thread.
Debug & operator<<(Bin &)
static Debug & CheckBegin(const char *file, int line, const char *expr)
void SetPrefixAndRadix(const char *prefix, int radix)
static Debug & LogBegin(const char *fileOrGroup)
friend class DebugExceptionhandler
friend class DebugCmdInterfaceDebug
unsigned alloc
allocated buffer size
static bool SimpleMatch(const char *str, const char *pattern)
@ MAX_CHECK_HITS
maximum number of times a check can be hit before it is turned off
static Debug & CrashBegin(const char *file, int line)
static bool SkipNext(void)
bool lastWasCR
has last character been CR?
static void SetBuildInfo(const char *version, const char *internalVersion, const char *buildDate)
Tell debug module about build info.
StringType
List of possible log string types.
const char * DebugGetDefaultCommands(void)
Determines default commands to be executed at startup.