From fc8040d695644aaca4596adebeca4ea1369ef630 Mon Sep 17 00:00:00 2001 From: Fox Caminiti Date: Fri, 22 Jul 2022 20:45:08 -0400 Subject: first --- debug.h | 78 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 debug.h (limited to 'debug.h') diff --git a/debug.h b/debug.h new file mode 100644 index 0000000..6128627 --- /dev/null +++ b/debug.h @@ -0,0 +1,78 @@ +#if DEBUG + +global_variable int32 *debugnull = NULL; +#define Assert(Expression) if(!(Expression)) {*debugnull = 21;} + +enum valtype { + d_float, + d_uint, + d_int +}; + +union debugval { + real32 f; + uint32 u; + int32 i; +}; + +struct project_debug +{ + uint32 Markers[8]; + uint32 MarkerIndex = 0; + uint64 CycleCount[8]; + uint64 EndCycleCount[8]; + uint64 ExecutionAmount[8]; + + valtype DebugPropertyType[6]; + debugval Val[6]; + char *String[6]; + uint32 WatchedProperties; + bool32 ToggleWindow; +}; + +global_variable project_debug Debug; + +#if ARM +#define DEBUG_CycleCountStart(ID) +#define DEBUG_CycleCountEnd(ID) +#else +#define DEBUG_CycleCountStart(ID) Debug.CycleCount[ID] = __rdtsc(); +#define DEBUG_CycleCountEnd(ID) Debug.EndCycleCount[ID] += __rdtsc() - Debug.CycleCount[ID]; Debug.ExecutionAmount[ID]++; +#endif + +internal void +DebugWatchVar(char *Name, void *Address, valtype Type) { + uint32 i = Debug.WatchedProperties; + Debug.String[i] = Name; + if (Type == d_float) + Debug.Val[i].f = *(real32 *)Address; + if (Type == d_uint) + Debug.Val[i].u = *(uint32 *)Address; + if (Type == d_int) + Debug.Val[i].i = *(int32 *)Address; + Debug.DebugPropertyType[i] = Type; + Debug.WatchedProperties++; +} + +#else + +#define Assert(Expression) + +enum valtype { +}; + +union debugval { +}; + +struct project_debug +{ +}; + +#define DEBUG_CycleCountStart(ID) +#define DEBUG_CycleCountEnd(ID) + +internal void +DebugWatchVar(char *Name, void *Address, valtype Type) { +} +#endif + -- cgit v1.2.3