DebugInfo
Posted: Sun Feb 01, 2015 12:56 am
Just stumbled again across this DebugInfo. However i have not yet checked if DeusEx it was compiled with support for it, but oo summarize the appereances i found on first glance:
Core\Inc\DbgInfoCpp.h
Core\Inc\UDebugInfo.h
Core\Classes\DebugInfo.uc
DeusEx\Classes\DeusExPlayer.uc
Anyone actually tried using this?
Core\Inc\DbgInfoCpp.h
Code: Select all
// $Header: DbgInfoCpp.h$
// Include this file in any CPP file from which you want to use the debug object
// this has #defines to use to add data to the timing system
// and if you change the state of the master define, it will take out all code
// associated with this system....
#ifndef __INCLUDED_DBGINFOCPP_H
#define __INCLUDED_DBGINFOCPP_H
// for now... this could simply be its own #define, if we wanted
//#ifdef PLAYTEST
//#define USE_DEBUG_SYSTEM
//#endif
#ifdef USE_DEBUG_SYSTEM
// get the actual debug object class definition
#include "UDebugInfo.h"
// go and get the debug object itself, so we can do things with it...
#define GetDebugObj() (&GDebugSys)
// these declare and use a timer named iTimer to get the timing data
#define DbgDeclareTimer(iTimer) int iTimer=0;
#define DbgClock(iTimer) do { clock(iTimer); } while (0)
#define DbgUnclock(iTimer) do { unclock(iTimer); } while (0)
// actual calls to the debug object functions
#define DbgAddTiming(sObj,sEv,iTime) GetDebugObj()->AddTimingData(sObj,sEv,iTime,this)
#define DbgAddTimingAnon(sObj,sEv,iTime) GetDebugObj()->AddTimingData(sObj,sEv,iTime)
#define DbgClearTiming() GetDebugObj()->ClearTimingData()
#define DbgShowTiming() GetDebugObj()->ShowTimingData()
#define DbgTickTiming() GetDebugObj()->TickTimingData()
#define DbgCommandTiming(iCmd,sParam) GetDebugObj()->CommandTimingData(iCmd,sParam)
// if you rather save one step, the finish here "Auto-Adds" the timing data too
#define DbgStartTimer(iTimer) DbgDeclareTimer(iTimer); DbgClock(iTimer)
#define DbgFinishTimer(sObj,sEv,iTimer) do { DbgUnclock(iTimer); DbgAddTiming(sObj,sEv,iTimer); } while (0)
// this expression should be compiled in in a DEBUG_SYSTEM build
#define DbgExp(x) x
#define DbgSetString(key,val) GetDebugObj()->SetString(key,val)
#define DbgGetString(key) GetDebugObj()->GetString(key)
#define DbgGetBool(key) ((GetDebugObj()->GetString(key)!=NULL)&&(GetDebugObj()->GetValue(key)!=0))
#define DbgGetValue(key) GetDebugObj()->GetValue(key)
#define DbgSetCallback(fCallback) GetDebugObj()->RegisterCallback(fCallback)
#define DbgClearCallback(fCallback) GetDebugObj()->RemoveCallback(fCallback)
#define DbgLoadConfig(tstr) \
do { \
TCHAR _CfgStr[256]; \
if (GConfig->GetString(TEXT("Debug.Vars"),tstr,_CfgStr,256)) \
DbgSetString(tstr,_CfgStr); \
} while (0)
#define DbgLoadVars(vars) do { GetDebugObj()->LoadVars(vars,sizeof(vars)/sizeof(vars[0])); } while (0)
#define DbgScanVars(vars) do { GetDebugObj()->ScanVars(vars,sizeof(vars)/sizeof(vars[0])); } while (0)
// and, for the really hardcore
// so you dont need to put stupid finishes on every damn return statement....
// the correct solution
class CORE_API UDebugAutoTimer
{
private:
int m_iTimer;
UObject *m_pMe;
const TCHAR *m_psObj;
const TCHAR *m_psEvent;
int m_iReleased;
public:
// pass this as me, or, if you want to be anon, just dont
UDebugAutoTimer(const TCHAR *psObj, const TCHAR *psEvent, UObject *me=NULL)
{
m_psObj=psObj;
m_psEvent=psEvent;
m_pMe=me;
m_iTimer=0;
m_iReleased=0;
clock(m_iTimer);
}
void StoreTimer(void)
{
unclock(m_iTimer);
GDebugSys.AddTimingData(m_psObj, m_psEvent, m_iTimer, m_pMe);
m_iReleased=1;
}
~UDebugAutoTimer()
{
if (m_iReleased==0)
StoreTimer();
}
};
#define DbgDeclTimer(tag,sObj,sEv,self) UDebugAutoTimer cAutoTimer##tag##(sObj,sEv,self)
#define DbgDeclTimerAnon(tag,sObj,sEv) UDebugAutoTimer cAutoTimer##tag##(sObj,sEv)
#define DbgStoreTimer(tag) cAutoTimer##tag##.StoreTimer()
enum eDebugCmds {
kDebugCmd_ListVars,
};
#else // USE_DEBUG_SYSTEM
#define GetTheDebugObject() NULL
#define DbgDeclareTimer(iTimer)
#define DbgClock(iTimer)
#define DbgUnclock(iTimer)
#define DbgAddTiming(sObj,sEvent,iTime)
#define DbgClearTiming()
#define DbgShowTiming()
#define DbgTickTiming()
#define DbgCommandTiming(iCmd,sParam)
#define DbgStartTimer(iTimer)
#define DbgFinishTimer(sObj,sEvent,iTimer)
#define DbgExp(x)
#define DbgSetString(key,val)
#define DbgGetString(key) NULL
#define DbgGetBool(key) (0)
#define DbgGetValue(key) (0)
#define DbgSetCallback(fCallback)
#define DbgClearCallback(fCallback)
#define DbgLoadConfig(tstr)
#define DbgLoadVars(vars)
#define DbgScanVars(vars)
#define DbgDeclTimer(tag,sObj,sEve,self)
#define DbgDeclTimerAnon(tag,sObj,sEv)
#define DbgStoreTimer(tag)
#endif // USE_DEBUG_SYSTEM
#endif // __INCLUDED_DBGINFOCPP_H
Code: Select all
// ----------------------------------------------------------------------
// File Name : UDebugInfo.h
// Programmer : Chris Norden
// Description : Header for global debug object (duh)
// ----------------------------------------------------------------------
// Copyright ©1999 ION Storm, L.P. This software is a trade secret.
// ----------------------------------------------------------------------
#ifndef __INCLUDED_UDEBUGINFO_H
#define __INCLUDED_UDEBUGINFO_H
////////////////////////////
// UDebugInfo
// is really a bridge class to connect UC to Cpp
class CORE_API UDebugInfo: public UObject
{
DECLARE_CLASS(UDebugInfo, UObject, 0)
public:
UDebugInfo();
public:
DECLARE_FUNCTION(execAddTimingData)
DECLARE_FUNCTION(execCommand)
DECLARE_FUNCTION(execSetString)
DECLARE_FUNCTION(execGetString)
};
enum
{
CORE_DebugInfo_AddTimingData=4000,
CORE_DebugInfo_Command=4001,
CORE_DebugInfo_SetString=4002,
CORE_DebugInfo_GetString=4003,
};
// this typedef is for callbacks out of debug changes
typedef void (*fDbgCallback)(const TCHAR *changed);
////////////
// helper code to allow you to simply declare an array of "DebugControls"
// which map debug system string/value pairs with variables in your code
// you can then just call helper functions in the DebugSys to
// a) parse the ini file and load up the debug vars
// b) map the debug vars into your variables
// what sort of timing variable you have declared
enum eTimingType
{
kTiming_Str,
kTiming_Int,
kTiming_Bool
};
// the actual variables themselves
struct sDebugControls {
TCHAR Str[32];
eTimingType Type;
void *Var;
};
/////////////////////////////
// UDebugSys
// is the actual class holding the current situation for the debug system
class CORE_API UDebugSys
{
public:
// da constructor
UDebugSys();
/////////////////
// ways to add data for timing/profiling of systems
// obj is what to associate the timing with
// event is what subclass of things the timing is for
// i.e. AddTimingData("Player","Tick") or ("Player","Physics") or whatever
void AddTimingData(const TCHAR *obj, const TCHAR *event, int Time, UObject *me);
void ClearTimingData(void);
void ShowTimingData(void);
void TickTimingData(void);
/////////////////
// these are for "configuration" of debugging
// i.e. you set "AIDebugObj" to "MaggieChow" or something
// takes a cmd from the enum in DbgInfoCpp.h
void Command(int cmd, const TCHAR *param);
// Set a value string to attach to the name string
void SetString(const TCHAR *str, const TCHAR *val);
// Gets the value string attached to str, or NULL if not attached
const TCHAR *GetString(const TCHAR *str);
const TCHAR *GetString(const TCHAR rawstr);
// returns 0 if undefined, else tries to ASCII->Int the string
int GetValue(const TCHAR *str);
int GetValue(const TCHAR rawstr);
// register a function to call when the debug variables change
void RegisterCallback(fDbgCallback pfCallback);
void RemoveCallback(fDbgCallback pfCallback);
// for managing and mapping the debugcontrol variables for your code
void LoadVars(sDebugControls *pCtrlList, int iCnt);
void ScanVars(sDebugControls *pCtrlList, int iCnt);
};
#endif // __INCLUDED_UDEBUGINFO_H
Code: Select all
//=============================================================================
// DebugInfo
//=============================================================================
class DebugInfo extends Object
transient
native
noexport;
native(4000) final function AddTimingData(string obj, string objName, int time);
native(4001) final function Command(string cmd);
native(4002) final function SetString(string Hash, string Value);
native(4003) final function string GetString(string Hash);
defaultproperties
{
}
Code: Select all
// ----------------------------------------------------------------------
// DebugInfo test functions
// ----------------------------------------------------------------------
exec function DebugCommand(string teststr)
{
if (!bCheatsEnabled)
return;
if (GlobalDebugObj == None)
GlobalDebugObj = new(Self) class'DebugInfo';
if (GlobalDebugObj != None)
GlobalDebugObj.Command(teststr);
}
exec function SetDebug(name cmd, name val)
{
if (!bCheatsEnabled)
return;
if (GlobalDebugObj == None)
GlobalDebugObj = new(Self) class'DebugInfo';
Log("Want to setting Debug String " $ cmd $ " to " $ val);
if (GlobalDebugObj != None)
GlobalDebugObj.SetString(String(cmd),String(val));
}
exec function GetDebug(name cmd)
{
local string temp;
if (!bCheatsEnabled)
return;
if (GlobalDebugObj == None)
GlobalDebugObj = new(Self) class'DebugInfo';
if (GlobalDebugObj != None)
{
temp=GlobalDebugObj.GetString(String(cmd));
Log("Debug String " $ cmd $ " has value " $ temp);
}
}