Richard Boegli's CnC_Generals_Zero_Hour Fork WIP
This is documentation of Richard Boegil's Zero Hour Fork
 
Loading...
Searching...
No Matches
Debug Class Reference

Debug module main class (singleton). More...

#include <rts/debug.h>

Classes

class  Bin
 Switches integer output to binary format. More...
 
class  Dec
 Switches integer output to decimal format. More...
 
class  FillChar
 Sets new fill character. More...
 
class  Format
 Old printf style formatting. More...
 
class  Hex
 Switches integer output to hexadecimal format. More...
 
class  HResult
 Helper class for writing HRESULTs to the debug stream. More...
 
class  LogDescription
 
class  MemDump
 Helper class for performing a raw memory dump. More...
 
class  RepeatChar
 Repeats a given character N times. More...
 
class  Width
 Sets output width for the next insertion. More...
 

Public Types

enum  { MAX_CHECK_HITS = 20 }
 
typedef bool(* HResultTranslator) (Debug &debug, long hresult, void *user)
 HRESULT translator callback function type.
 

Public Member Functions

Debugoperator<< (Hex &)
 
Debugoperator<< (Dec &)
 
Debugoperator<< (Bin &)
 
Debugoperator<< (Width &w)
 
Debugoperator<< (FillChar &c)
 
Debugoperator<< (RepeatChar &c)
 
Debugoperator<< (const Format &f)
 
 ~Debug ()
 
bool AssertDone (void)
 
bool CheckDone (void)
 
bool LogDone (void)
 
bool CrashDone (bool die)
 
Debugoperator<< (const char *str)
 
void SetPrefixAndRadix (const char *prefix, int radix)
 
Debugoperator<< (int val)
 
Debugoperator<< (unsigned val)
 
Debugoperator<< (long val)
 
Debugoperator<< (unsigned long val)
 
Debugoperator<< (bool val)
 
Debugoperator<< (float val)
 
Debugoperator<< (double val)
 
Debugoperator<< (short val)
 
Debugoperator<< (unsigned short val)
 
Debugoperator<< (__int64 val)
 
Debugoperator<< (unsigned __int64 val)
 
Debugoperator<< (const void *ptr)
 
Debugoperator<< (const MemDump &dump)
 
Debugoperator<< (HResult hres)
 
void WriteBuildInfo (void)
 Write build information into log.
 

Static Public Member Functions

static void InstallExceptionHandler (void)
 Installs exception handler for current thread.
 
static bool SkipNext (void)
 
static DebugAssertBegin (const char *file, int line, const char *expr)
 
static DebugCheckBegin (const char *file, int line, const char *expr)
 
static DebugLogBegin (const char *fileOrGroup)
 
static DebugCrashBegin (const char *file, int line)
 
static bool IsLogEnabled (const char *fileOrGroup)
 
static void AddHResultTranslator (unsigned prio, HResultTranslator func, void *user=0)
 Adds a HRESULT translator.
 
static void RemoveHResultTranslator (HResultTranslator func, void *user=0)
 Removes a HRESULT translator.
 
static bool AddIOFactory (const char *io_id, const char *descr, DebugIOInterface *(*func)(void))
 Registers a new I/O class factory function.
 
static bool AddCommands (const char *cmdgroup, DebugCmdInterface *cmdif)
 Adds a new command group.
 
static void RemoveCommands (DebugCmdInterface *cmdif)
 Removes a command group.
 
static void Command (const char *cmd)
 Issues a debug command.
 
static void Update (void)
 Update method, must be called on a regular basis.
 
static bool SimpleMatch (const char *str, const char *pattern)
 
static void SetBuildInfo (const char *version, const char *internalVersion, const char *buildDate)
 Tell debug module about build info.
 

Friends

class DebugCmdInterfaceDebug
 
class DebugExceptionhandler
 
class LogDescription
 

Detailed Description

Debug module main class (singleton).

Definition at line 44 of file debug_debug.h.

Member Typedef Documentation

◆ HResultTranslator

typedef bool(* Debug::HResultTranslator) (Debug &debug, long hresult, void *user)

HRESULT translator callback function type.

See Debug::AddHResultTranslator for more information.

Parameters
debugDebug instance where info can be written to
hresultcurrent HRESULT value
useruser value passed into AddHResultTranslator
Returns
true if value translated and no more translators should be called, false if next translator should be tried

Definition at line 70 of file debug_debug.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
MAX_CHECK_HITS 

maximum number of times a check can be hit before it is turned off

Definition at line 53 of file debug_debug.h.

Constructor & Destructor Documentation

◆ ~Debug()

Debug::~Debug ( )

Definition at line 247 of file debug_debug.cpp.

Member Function Documentation

◆ AddCommands()

bool Debug::AddCommands ( const char * cmdgroup,
DebugCmdInterface * cmdif )
static

Adds a new command group.

If the command group already exists the new command interface is added at the end of the list. A command issued for that group is first passed to the 'old' command interface. If that DebugCmdInterface::Execute call fails the command is passed on to the next interface within the same command group.

The only exception is the 'help' command. Here all Execute functions are always called.

Ownership of the interface pointer is passed to the Debug module i.e. the interface is destroyed when the Debug module shuts down (unless the interface is removed using RemoveCommands).

Parameters
cmdgroupcommand group this interface implements
cmdifcommand group interface instance
Returns
true (so function can be used in static initializers)

Definition at line 1034 of file debug_debug.cpp.

◆ AddHResultTranslator()

void Debug::AddHResultTranslator ( unsigned prio,
HResultTranslator func,
void * user = 0 )
static

Adds a HRESULT translator.

A HRESULT translator is called whenever a HResult descriptor is passed into the Debug log stream. Such a translator can translate the numeric value into something more meaningful.

Translators are differentiated by both function address and user pointer. There is however no harm in adding the same translator/user pointer pair twice.

Parameters
priopriority, translators with a higher priority get called first
functranslator address
useroptional user pointer which will be passed to the given translator
See also
RemoveHResultTranslator

Definition at line 961 of file debug_debug.cpp.

◆ AddIOFactory()

bool Debug::AddIOFactory ( const char * io_id,
const char * descr,
DebugIOInterface *(* func )(void) )
static

Registers a new I/O class factory function.

This is typically used internally by the DEBUG_IMPLEMENT_IO_INTERFACE macro. If there is already an I/O class with the same name registered the new one overwrites the old.

Parameters
io_idname of I/O class as it should be registered with Debug module
descrshort class description
funcfactory function
Returns
true (so function can be used in static initializers)

Definition at line 1010 of file debug_debug.cpp.

◆ AssertBegin()

Debug & Debug::AssertBegin ( const char * file,
int line,
const char * expr )
static

Definition at line 294 of file debug_debug.cpp.

◆ AssertDone()

bool Debug::AssertDone ( void )
Todo
replace MessageBox with custom dialog w/ 4 options: abort, skip 1, skip all, break

Definition at line 325 of file debug_debug.cpp.

◆ CheckBegin()

Debug & Debug::CheckBegin ( const char * file,
int line,
const char * expr )
static

Definition at line 423 of file debug_debug.cpp.

◆ CheckDone()

bool Debug::CheckDone ( void )

Definition at line 454 of file debug_debug.cpp.

◆ Command()

void Debug::Command ( const char * cmd)
static

Issues a debug command.

Parameters
cmdcommand to execute

Definition at line 1089 of file debug_debug.cpp.

◆ CrashBegin()

Debug & Debug::CrashBegin ( const char * file,
int line )
static

Definition at line 549 of file debug_debug.cpp.

◆ CrashDone()

bool Debug::CrashDone ( bool die)

Definition at line 582 of file debug_debug.cpp.

◆ InstallExceptionHandler()

void Debug::InstallExceptionHandler ( void )
static

Installs exception handler for current thread.

For the main thread this is already done, but for any additional threads being created this function must be called.

Definition at line 258 of file debug_debug.cpp.

◆ IsLogEnabled()

bool Debug::IsLogEnabled ( const char * fileOrGroup)
static

Definition at line 947 of file debug_debug.cpp.

◆ LogBegin()

Debug & Debug::LogBegin ( const char * fileOrGroup)
static

Definition at line 506 of file debug_debug.cpp.

◆ LogDone()

bool Debug::LogDone ( void )

Definition at line 539 of file debug_debug.cpp.

◆ operator<<() [1/22]

Debug & Debug::operator<< ( __int64 val)

Definition at line 818 of file debug_debug.cpp.

◆ operator<<() [2/22]

Debug & Debug::operator<< ( Bin & )
inline

Definition at line 234 of file debug_debug.h.

◆ operator<<() [3/22]

Debug & Debug::operator<< ( bool val)

Definition at line 777 of file debug_debug.cpp.

◆ operator<<() [4/22]

Debug & Debug::operator<< ( const char * str)

Definition at line 700 of file debug_debug.cpp.

◆ operator<<() [5/22]

Debug & Debug::operator<< ( const Format & f)
inline

Definition at line 326 of file debug_debug.h.

◆ operator<<() [6/22]

Debug & Debug::operator<< ( const MemDump & dump)

Definition at line 851 of file debug_debug.cpp.

◆ operator<<() [7/22]

Debug & Debug::operator<< ( const void * ptr)

Definition at line 838 of file debug_debug.cpp.

◆ operator<<() [8/22]

Debug & Debug::operator<< ( Dec & )
inline

Definition at line 222 of file debug_debug.h.

◆ operator<<() [9/22]

Debug & Debug::operator<< ( double val)

@todo_opt shouldn't use snprintf here - brings in most of the old C IO lib...

Definition at line 790 of file debug_debug.cpp.

◆ operator<<() [10/22]

Debug & Debug::operator<< ( FillChar & c)
inline

Definition at line 278 of file debug_debug.h.

◆ operator<<() [11/22]

Debug & Debug::operator<< ( float val)

@todo_opt shouldn't use snprintf here - brings in most of the old C IO lib...

Definition at line 782 of file debug_debug.cpp.

◆ operator<<() [12/22]

Debug & Debug::operator<< ( Hex & )
inline

Definition at line 210 of file debug_debug.h.

◆ operator<<() [13/22]

Debug & Debug::operator<< ( HResult hres)

Definition at line 937 of file debug_debug.cpp.

◆ operator<<() [14/22]

Debug & Debug::operator<< ( int val)

Definition at line 737 of file debug_debug.cpp.

◆ operator<<() [15/22]

Debug & Debug::operator<< ( long val)

Definition at line 757 of file debug_debug.cpp.

◆ operator<<() [16/22]

Debug & Debug::operator<< ( RepeatChar & c)

Definition at line 225 of file debug_debug.cpp.

◆ operator<<() [17/22]

Debug & Debug::operator<< ( short val)

Definition at line 798 of file debug_debug.cpp.

◆ operator<<() [18/22]

Debug & Debug::operator<< ( unsigned __int64 val)

Definition at line 828 of file debug_debug.cpp.

◆ operator<<() [19/22]

Debug & Debug::operator<< ( unsigned long val)

Definition at line 767 of file debug_debug.cpp.

◆ operator<<() [20/22]

Debug & Debug::operator<< ( unsigned short val)

Definition at line 808 of file debug_debug.cpp.

◆ operator<<() [21/22]

Debug & Debug::operator<< ( unsigned val)

Definition at line 747 of file debug_debug.cpp.

◆ operator<<() [22/22]

Debug & Debug::operator<< ( Width & w)
inline

Definition at line 256 of file debug_debug.h.

◆ RemoveCommands()

void Debug::RemoveCommands ( DebugCmdInterface * cmdif)
static

Removes a command group.

Parameters
cmdifcommand group interface that will be removed

Definition at line 1063 of file debug_debug.cpp.

◆ RemoveHResultTranslator()

void Debug::RemoveHResultTranslator ( HResultTranslator func,
void * user = 0 )
static

Removes a HRESULT translator.

If the translator/user pointer pair does not exist nothing is done.

Parameters
functranslator address
useroptional user pointer
See also
AddHResultTranslator

Definition at line 990 of file debug_debug.cpp.

◆ SetBuildInfo()

void Debug::SetBuildInfo ( const char * version,
const char * internalVersion,
const char * buildDate )
static

Tell debug module about build info.

All these strings are free form and can be up to 63 chars long.

Parameters
versionofficial version
internalVersioninternal version
buildDatebuild date & time

Definition at line 1418 of file debug_debug.cpp.

◆ SetPrefixAndRadix()

void Debug::SetPrefixAndRadix ( const char * prefix,
int radix )

Definition at line 730 of file debug_debug.cpp.

◆ SimpleMatch()

bool Debug::SimpleMatch ( const char * str,
const char * pattern )
static

Definition at line 1394 of file debug_debug.cpp.

◆ SkipNext()

bool Debug::SkipNext ( void )
static

Definition at line 263 of file debug_debug.cpp.

◆ Update()

void Debug::Update ( void )
static

Update method, must be called on a regular basis.

Scans I/O classes for new command input and processes it.

Definition at line 1095 of file debug_debug.cpp.

◆ WriteBuildInfo()

void Debug::WriteBuildInfo ( void )

Write build information into log.

Definition at line 1430 of file debug_debug.cpp.

Friends And Related Symbol Documentation

◆ DebugCmdInterfaceDebug

friend class DebugCmdInterfaceDebug
friend

Definition at line 47 of file debug_debug.h.

◆ DebugExceptionhandler

friend class DebugExceptionhandler
friend

Definition at line 50 of file debug_debug.h.

◆ LogDescription

friend class LogDescription
friend

Definition at line 333 of file debug_debug.h.

Member Data Documentation

◆ alloc

unsigned Debug::alloc

allocated buffer size

Definition at line 1065 of file debug_debug.h.

◆ buffer

char* Debug::buffer

buffer

Definition at line 1059 of file debug_debug.h.

◆ lastWasCR

bool Debug::lastWasCR

has last character been CR?

Definition at line 1068 of file debug_debug.h.

◆ used

unsigned Debug::used

used buffer size

Definition at line 1062 of file debug_debug.h.


The documentation for this class was generated from the following files: