From bfa7c1722aa832dd7a28d71d01cdb6333c0c5e15 Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Wed, 3 Jan 2024 18:22:13 +0900 Subject: [PATCH] [build] Implement tracy memory zones This proved to be quite the challenge, and is probably rather fragile, but it does seem to work, and might help with tracking down memory leaks. --- Makefile.am | 2 +- hw/source/Makemodule.am | 2 +- include/qftracy.h | 27 ++++++ libs/audio/test/Makemodule.am | 2 +- libs/console/test/Makemodule.am | 3 +- libs/ecs/test/Makemodule.am | 20 ++-- libs/gamecode/test/Makemodule.am | 96 ++++++++++++------- libs/models/test/Makemodule.am | 9 +- libs/scene/test/Makemodule.am | 3 +- libs/ui/test/Makemodule.am | 10 +- libs/util/test/Makemodule.am | 54 +++++------ libs/video/renderer/vulkan/test/Makemodule.am | 3 +- qw/source/Makemodule.am | 2 +- ruamoko/qwaq/Makemodule.am | 6 +- tools/bsp2img/Makemodule.am | 2 +- tools/carne/Makemodule.am | 2 +- tools/pak/Makemodule.am | 2 +- tools/qfbsp/source/Makemodule.am | 3 +- tools/qfcc/source/Makemodule.am | 6 +- tools/qfcc/test/Makemodule.am | 9 +- tools/qflight/source/Makemodule.am | 3 +- tools/qflmp/Makemodule.am | 2 +- tools/qfmodelgen/source/Makemodule.am | 3 +- tools/qfspritegen/Makemodule.am | 2 +- tools/qfvis/source/Makemodule.am | 3 +- tools/tracy/qftracy_mem.c | 81 ++++++++++++++++ tools/wad/Makemodule.am | 2 +- tools/wav/Makemodule.am | 2 +- 28 files changed, 263 insertions(+), 98 deletions(-) create mode 100644 tools/tracy/qftracy_mem.c diff --git a/Makefile.am b/Makefile.am index da4d1c551..9e5007881 100644 --- a/Makefile.am +++ b/Makefile.am @@ -62,7 +62,7 @@ PTHREAD_LDFLAGS=@PTHREAD_LDFLAGS@ PTHREAD_CFLAGS=@PTHREAD_CFLAGS@ if HAVE_TRACY -tracy_src=tools/tracy/qftracy.cc +tracy_src=tools/tracy/qftracy.cc tools/tracy/qftracy_mem.c tracyvk_src=tools/tracy/qftracyvk.cc else tracy_src= diff --git a/hw/source/Makemodule.am b/hw/source/Makemodule.am index 9f86d3283..61426158e 100644 --- a/hw/source/Makemodule.am +++ b/hw/source/Makemodule.am @@ -40,4 +40,4 @@ hw_master_libs= \ hw_master_LDFLAGS= $(common_ldflags) hw_master_LDADD= $(hw_master_libs) $(NET_LIBS) hw_master_DEPENDENCIES= $(hw_master_libs) -hw_master_SOURCES= hw/source/master.c +hw_master_SOURCES= hw/source/master.c $(tracy_src) diff --git a/include/qftracy.h b/include/qftracy.h index ee3d13a89..cd562497b 100644 --- a/include/qftracy.h +++ b/include/qftracy.h @@ -41,6 +41,33 @@ static inline void __qfZoneEnd (TracyCZoneCtx **ctxptr) #define qfMessageL(msg) TracyCMessageL(msg) +#ifndef __cplusplus +#define aligned_alloc(a, s) qf_aligned_alloc(a, s) +#define malloc(s) qf_malloc(s) +#define calloc(c,s) qf_calloc(c,s) +#define realloc(p,s) qf_realloc(p,s) +#define free(p) qf_free(p) +#define strdup(s) qf_strdup(s) +#include +#undef aligned_alloc +#undef malloc +#undef calloc +#undef realloc +#undef free +#undef strdup +#define getcwd(b,s) qf_getcwd(b,s) +#include +#undef getcwd + +void *aligned_alloc (size_t a, size_t s) asm("__qf_aligned_alloc"); +void *malloc (size_t s) asm("__qf_malloc"); +void *calloc (size_t c, size_t s) asm("__qf_calloc"); +void *realloc (void *p, size_t s) asm("__qf_realloc"); +void free (void *p) asm("__qf_free"); +char *strdup (const char *s) asm("__qf_strdup"); +char *getcwd (char *b, size_t s) asm("__qf_getcwd"); +#endif + #else #define qfFrameMark diff --git a/libs/audio/test/Makemodule.am b/libs/audio/test/Makemodule.am index 6b97b2e53..2070159eb 100644 --- a/libs/audio/test/Makemodule.am +++ b/libs/audio/test/Makemodule.am @@ -8,6 +8,6 @@ testaudio_libs= \ libs/ruamoko/libQFruamoko.la \ libs/util/libQFutil.la -libs_audio_test_testsound_SOURCES= libs/audio/test/testsound.c +libs_audio_test_testsound_SOURCES= libs/audio/test/testsound.c $(tracy_src) libs_audio_test_testsound_LDADD= $(testaudio_libs) libs_audio_test_testsound_DEPENDENCIES= $(testaudio_libs) diff --git a/libs/console/test/Makemodule.am b/libs/console/test/Makemodule.am index 2116b5919..9ab372a09 100644 --- a/libs/console/test/Makemodule.am +++ b/libs/console/test/Makemodule.am @@ -10,6 +10,7 @@ test_console_libs= \ libs/util/libQFutil.la libs_console_test_test_buffer_SOURCES= \ - libs/console/test/test-buffer.c + libs/console/test/test-buffer.c \ + $(tracy_src) libs_console_test_test_buffer_LDADD= $(test_console_libs) libs_console_test_test_buffer_DEPENDENCIES=$(test_console_libs) diff --git a/libs/ecs/test/Makemodule.am b/libs/ecs/test/Makemodule.am index f21722f55..e5f707153 100644 --- a/libs/ecs/test/Makemodule.am +++ b/libs/ecs/test/Makemodule.am @@ -15,42 +15,48 @@ libs_ecs_test_libs= \ libs/util/libQFutil.la libs_ecs_test_test_components_SOURCES= \ - libs/ecs/test/test-components.c -libs_ecs_test_test_components_LDADD= \ + libs/ecs/test/test-components.c \ + $(tracy_src) +libs_ecs_test_test_components_LDADD= \ $(libs_ecs_test_libs) libs_ecs_test_test_components_DEPENDENCIES= \ $(libs_ecs_test_libs) libs_ecs_test_test_compops_SOURCES= \ - libs/ecs/test/test-compops.c + libs/ecs/test/test-compops.c \ + $(tracy_src) libs_ecs_test_test_compops_LDADD= \ $(libs_ecs_test_libs) libs_ecs_test_test_compops_DEPENDENCIES= \ $(libs_ecs_test_libs) libs_ecs_test_test_hierarchy_SOURCES= \ - libs/ecs/test/test-hierarchy.c + libs/ecs/test/test-hierarchy.c \ + $(tracy_src) libs_ecs_test_test_hierarchy_LDADD= \ $(libs_ecs_test_libs) libs_ecs_test_test_hierarchy_DEPENDENCIES= \ $(libs_ecs_test_libs) libs_ecs_test_test_registry_SOURCES= \ - libs/ecs/test/test-registry.c + libs/ecs/test/test-registry.c \ + $(tracy_src) libs_ecs_test_test_registry_LDADD= \ $(libs_ecs_test_libs) libs_ecs_test_test_registry_DEPENDENCIES= \ $(libs_ecs_test_libs) libs_ecs_test_test_subpools_SOURCES= \ - libs/ecs/test/test-subpools.c + libs/ecs/test/test-subpools.c \ + $(tracy_src) libs_ecs_test_test_subpools_LDADD= \ $(libs_ecs_test_libs) libs_ecs_test_test_subpools_DEPENDENCIES= \ $(libs_ecs_test_libs) libs_ecs_test_test_treehierarchy_SOURCES= \ - libs/ecs/test/test-treehierarchy.c + libs/ecs/test/test-treehierarchy.c \ + $(tracy_src) libs_ecs_test_test_treehierarchy_LDADD= \ $(libs_ecs_test_libs) libs_ecs_test_test_treehierarchy_DEPENDENCIES= \ diff --git a/libs/gamecode/test/Makemodule.am b/libs/gamecode/test/Makemodule.am index dfccd91ae..bc215ddc9 100644 --- a/libs/gamecode/test/Makemodule.am +++ b/libs/gamecode/test/Makemodule.am @@ -43,160 +43,192 @@ test_gamecode_libs= \ libs/util/libQFutil.la libs_gamecode_test_test_branch_SOURCES= \ - libs/gamecode/test/test-branch.c + libs/gamecode/test/test-branch.c \ + $(tracy_src) libs_gamecode_test_test_branch_LDADD= $(test_gamecode_libs) libs_gamecode_test_test_branch_DEPENDENCIES=$(test_gamecode_libs) libs_gamecode_test_test_bitops_SOURCES= \ - libs/gamecode/test/test-bitops.c + libs/gamecode/test/test-bitops.c \ + $(tracy_src) libs_gamecode_test_test_bitops_LDADD= $(test_gamecode_libs) libs_gamecode_test_test_bitops_DEPENDENCIES=$(test_gamecode_libs) libs_gamecode_test_test_callret_SOURCES= \ - libs/gamecode/test/test-callret.c + libs/gamecode/test/test-callret.c \ + $(tracy_src) libs_gamecode_test_test_callret_LDADD= $(test_gamecode_libs) libs_gamecode_test_test_callret_DEPENDENCIES=$(test_gamecode_libs) libs_gamecode_test_test_conv0_SOURCES= \ - libs/gamecode/test/test-conv0.c + libs/gamecode/test/test-conv0.c \ + $(tracy_src) libs_gamecode_test_test_conv0_LDADD= $(test_gamecode_libs) libs_gamecode_test_test_conv0_DEPENDENCIES= $(test_gamecode_libs) libs_gamecode_test_test_conv1_SOURCES= \ - libs/gamecode/test/test-conv1.c + libs/gamecode/test/test-conv1.c \ + $(tracy_src) libs_gamecode_test_test_conv1_LDADD= $(test_gamecode_libs) libs_gamecode_test_test_conv1_DEPENDENCIES= $(test_gamecode_libs) libs_gamecode_test_test_conv2_SOURCES= \ - libs/gamecode/test/test-conv2.c + libs/gamecode/test/test-conv2.c \ + $(tracy_src) libs_gamecode_test_test_conv2_LDADD= $(test_gamecode_libs) libs_gamecode_test_test_conv2_DEPENDENCIES= $(test_gamecode_libs) libs_gamecode_test_test_conv3_SOURCES= \ - libs/gamecode/test/test-conv3.c + libs/gamecode/test/test-conv3.c \ + $(tracy_src) libs_gamecode_test_test_conv3_LDADD= $(test_gamecode_libs) libs_gamecode_test_test_conv3_DEPENDENCIES= $(test_gamecode_libs) libs_gamecode_test_test_conv4_SOURCES= \ - libs/gamecode/test/test-conv4.c + libs/gamecode/test/test-conv4.c \ + $(tracy_src) libs_gamecode_test_test_conv4_LDADD= $(test_gamecode_libs) libs_gamecode_test_test_conv4_DEPENDENCIES= $(test_gamecode_libs) libs_gamecode_test_test_conv5_SOURCES= \ - libs/gamecode/test/test-conv5.c + libs/gamecode/test/test-conv5.c \ + $(tracy_src) libs_gamecode_test_test_conv5_LDADD= $(test_gamecode_libs) libs_gamecode_test_test_conv5_DEPENDENCIES= $(test_gamecode_libs) libs_gamecode_test_test_conv6_SOURCES= \ - libs/gamecode/test/test-conv6.c + libs/gamecode/test/test-conv6.c \ + $(tracy_src) libs_gamecode_test_test_conv6_LDADD= $(test_gamecode_libs) libs_gamecode_test_test_conv6_DEPENDENCIES= $(test_gamecode_libs) libs_gamecode_test_test_conv7_SOURCES= \ - libs/gamecode/test/test-conv7.c + libs/gamecode/test/test-conv7.c \ + $(tracy_src) libs_gamecode_test_test_conv7_LDADD= $(test_gamecode_libs) libs_gamecode_test_test_conv7_DEPENDENCIES= $(test_gamecode_libs) libs_gamecode_test_test_double_SOURCES= \ - libs/gamecode/test/test-double.c + libs/gamecode/test/test-double.c \ + $(tracy_src) libs_gamecode_test_test_double_LDADD= $(test_gamecode_libs) libs_gamecode_test_test_double_DEPENDENCIES=$(test_gamecode_libs) libs_gamecode_test_test_extend_SOURCES= \ - libs/gamecode/test/test-extend.c + libs/gamecode/test/test-extend.c \ + $(tracy_src) libs_gamecode_test_test_extend_LDADD= $(test_gamecode_libs) libs_gamecode_test_test_extend_DEPENDENCIES= $(test_gamecode_libs) libs_gamecode_test_test_float_SOURCES= \ - libs/gamecode/test/test-float.c + libs/gamecode/test/test-float.c \ + $(tracy_src) libs_gamecode_test_test_float_LDADD= $(test_gamecode_libs) libs_gamecode_test_test_float_DEPENDENCIES= $(test_gamecode_libs) libs_gamecode_test_test_hops_SOURCES= \ - libs/gamecode/test/test-hops.c + libs/gamecode/test/test-hops.c \ + $(tracy_src) libs_gamecode_test_test_hops_LDADD= $(test_gamecode_libs) libs_gamecode_test_test_hops_DEPENDENCIES= $(test_gamecode_libs) libs_gamecode_test_test_int_SOURCES= \ - libs/gamecode/test/test-int.c + libs/gamecode/test/test-int.c \ + $(tracy_src) libs_gamecode_test_test_int_LDADD= $(test_gamecode_libs) libs_gamecode_test_test_int_DEPENDENCIES= $(test_gamecode_libs) libs_gamecode_test_test_jump_SOURCES= \ - libs/gamecode/test/test-jump.c + libs/gamecode/test/test-jump.c \ + $(tracy_src) libs_gamecode_test_test_jump_LDADD= $(test_gamecode_libs) libs_gamecode_test_test_jump_DEPENDENCIES= $(test_gamecode_libs) libs_gamecode_test_test_lea_SOURCES= \ - libs/gamecode/test/test-lea.c + libs/gamecode/test/test-lea.c \ + $(tracy_src) libs_gamecode_test_test_lea_LDADD= $(test_gamecode_libs) libs_gamecode_test_test_lea_DEPENDENCIES= $(test_gamecode_libs) libs_gamecode_test_test_load_SOURCES= \ - libs/gamecode/test/test-load.c + libs/gamecode/test/test-load.c \ + $(tracy_src) libs_gamecode_test_test_load_LDADD= $(test_gamecode_libs) libs_gamecode_test_test_load_DEPENDENCIES= $(test_gamecode_libs) libs_gamecode_test_test_load64_SOURCES= \ - libs/gamecode/test/test-load64.c + libs/gamecode/test/test-load64.c \ + $(tracy_src) libs_gamecode_test_test_load64_LDADD= $(test_gamecode_libs) libs_gamecode_test_test_load64_DEPENDENCIES=$(test_gamecode_libs) libs_gamecode_test_test_long_SOURCES= \ - libs/gamecode/test/test-long.c + libs/gamecode/test/test-long.c \ + $(tracy_src) libs_gamecode_test_test_long_LDADD= $(test_gamecode_libs) libs_gamecode_test_test_long_DEPENDENCIES= $(test_gamecode_libs) libs_gamecode_test_test_mem_SOURCES= \ - libs/gamecode/test/test-mem.c + libs/gamecode/test/test-mem.c \ + $(tracy_src) libs_gamecode_test_test_mem_LDADD= $(test_gamecode_libs) libs_gamecode_test_test_mem_DEPENDENCIES= $(test_gamecode_libs) libs_gamecode_test_test_scale_SOURCES= \ - libs/gamecode/test/test-scale.c + libs/gamecode/test/test-scale.c \ + $(tracy_src) libs_gamecode_test_test_scale_LDADD= $(test_gamecode_libs) libs_gamecode_test_test_scale_DEPENDENCIES= $(test_gamecode_libs) libs_gamecode_test_test_stack_SOURCES= \ - libs/gamecode/test/test-stack.c + libs/gamecode/test/test-stack.c \ + $(tracy_src) libs_gamecode_test_test_stack_LDADD= $(test_gamecode_libs) libs_gamecode_test_test_stack_DEPENDENCIES= $(test_gamecode_libs) libs_gamecode_test_test_state_SOURCES= \ - libs/gamecode/test/test-state.c + libs/gamecode/test/test-state.c \ + $(tracy_src) libs_gamecode_test_test_state_LDADD= $(test_gamecode_libs) libs_gamecode_test_test_store_SOURCES= \ - libs/gamecode/test/test-store.c + libs/gamecode/test/test-store.c \ + $(tracy_src) libs_gamecode_test_test_store_LDADD= $(test_gamecode_libs) libs_gamecode_test_test_store_DEPENDENCIES= $(test_gamecode_libs) libs_gamecode_test_test_store64_SOURCES= \ - libs/gamecode/test/test-store64.c + libs/gamecode/test/test-store64.c \ + $(tracy_src) libs_gamecode_test_test_store64_LDADD= $(test_gamecode_libs) libs_gamecode_test_test_store64_DEPENDENCIES= $(test_gamecode_libs) libs_gamecode_test_test_string_SOURCES= \ - libs/gamecode/test/test-string.c + libs/gamecode/test/test-string.c \ + $(tracy_src) libs_gamecode_test_test_string_LDADD= $(test_gamecode_libs) libs_gamecode_test_test_string_DEPENDENCIES= $(test_gamecode_libs) libs_gamecode_test_test_swizzle_SOURCES= \ - libs/gamecode/test/test-swizzle.c + libs/gamecode/test/test-swizzle.c \ + $(tracy_src) libs_gamecode_test_test_swizzle_LDADD= $(test_gamecode_libs) libs_gamecode_test_test_swizzle_DEPENDENCIES= $(test_gamecode_libs) libs_gamecode_test_test_unsigned_SOURCES= \ - libs/gamecode/test/test-unsigned.c + libs/gamecode/test/test-unsigned.c \ + $(tracy_src) libs_gamecode_test_test_unsigned_LDADD= $(test_gamecode_libs) libs_gamecode_test_test_unsigned_DEPENDENCIES= $(test_gamecode_libs) libs_gamecode_test_test_vector_SOURCES= \ - libs/gamecode/test/test-vector.c + libs/gamecode/test/test-vector.c \ + $(tracy_src) libs_gamecode_test_test_vector_LDADD= $(test_gamecode_libs) libs_gamecode_test_test_vector_DEPENDENCIES= $(test_gamecode_libs) libs_gamecode_test_test_with_SOURCES= \ - libs/gamecode/test/test-with.c + libs/gamecode/test/test-with.c \ + $(tracy_src) libs_gamecode_test_test_with_LDADD= $(test_gamecode_libs) libs_gamecode_test_test_with_DEPENDENCIES= $(test_gamecode_libs) diff --git a/libs/models/test/Makemodule.am b/libs/models/test/Makemodule.am index 15cbe5e35..f43a9cce6 100644 --- a/libs/models/test/Makemodule.am +++ b/libs/models/test/Makemodule.am @@ -19,18 +19,21 @@ test_libs= \ libs_models_test_testclip_SOURCES= \ libs/models/test/testclip.c \ - libs/models/test/hulls.c + libs/models/test/hulls.c \ + $(tracy_src) libs_models_test_testclip_LDADD= $(test_libs) libs_models_test_testclip_DEPENDENCIES= $(test_libs) libs_models_test_testcontents_SOURCES= \ libs/models/test/testcontents.c \ - libs/models/test/hulls.c + libs/models/test/hulls.c \ + $(tracy_src) libs_models_test_testcontents_LDADD= $(test_libs) libs_models_test_testcontents_DEPENDENCIES= $(test_libs) libs_models_test_testportals_SOURCES= \ libs/models/test/testportals.c \ - libs/models/test/hulls.c + libs/models/test/hulls.c \ + $(tracy_src) libs_models_test_testportals_LDADD= $(test_libs) libs_models_test_testportals_DEPENDENCIES= $(test_libs) diff --git a/libs/scene/test/Makemodule.am b/libs/scene/test/Makemodule.am index d1074ed13..99006afdb 100644 --- a/libs/scene/test/Makemodule.am +++ b/libs/scene/test/Makemodule.am @@ -11,7 +11,8 @@ libs_scene_test_libs= \ libs/util/libQFutil.la libs_scene_test_test_transform_SOURCES= \ - libs/scene/test/test-transform.c + libs/scene/test/test-transform.c \ + $(tracy_src) libs_scene_test_test_transform_LDADD= \ $(libs_scene_test_libs) libs_scene_test_test_transform_DEPENDENCIES= \ diff --git a/libs/ui/test/Makemodule.am b/libs/ui/test/Makemodule.am index 2e9ac62f1..5335f0b16 100644 --- a/libs/ui/test/Makemodule.am +++ b/libs/ui/test/Makemodule.am @@ -11,22 +11,22 @@ XFAIL_TESTS += $(libs_ui_xfail_tests) check_PROGRAMS += $(libs_ui_tests) $(libs_ui_xfail_tests) -libs_ui_test_test_flow_SOURCES=libs/ui/test/test-flow.c +libs_ui_test_test_flow_SOURCES=libs/ui/test/test-flow.c $(tracy_src) libs_ui_test_test_flow_LDADD=libs/ui/libQFui.la libs/ecs/libQFecs.la libs_ui_test_test_flow_DEPENDENCIES=libs/ui/libQFui.la -libs_ui_test_test_flow_size_SOURCES=libs/ui/test/test-flow-size.c +libs_ui_test_test_flow_size_SOURCES=libs/ui/test/test-flow-size.c $(tracy_src) libs_ui_test_test_flow_size_LDADD=libs/ui/libQFui.la libs/ecs/libQFecs.la libs_ui_test_test_flow_size_DEPENDENCIES=libs/ui/libQFui.la -libs_ui_test_test_passage_SOURCES=libs/ui/test/test-passage.c +libs_ui_test_test_passage_SOURCES=libs/ui/test/test-passage.c $(tracy_src) libs_ui_test_test_passage_LDADD=libs/ui/libQFui.la libs/ecs/libQFecs.la libs_ui_test_test_passage_DEPENDENCIES=libs/ui/libQFui.la libs/ecs/libQFecs.la -libs_ui_test_test_txtbuffer_SOURCES=libs/ui/test/test-txtbuffer.c +libs_ui_test_test_txtbuffer_SOURCES=libs/ui/test/test-txtbuffer.c $(tracy_src) libs_ui_test_test_txtbuffer_LDADD=libs/ui/libQFui.la libs_ui_test_test_txtbuffer_DEPENDENCIES=libs/ui/libQFui.la -libs_ui_test_test_vrect_SOURCES=libs/ui/test/test-vrect.c +libs_ui_test_test_vrect_SOURCES=libs/ui/test/test-vrect.c $(tracy_src) libs_ui_test_test_vrect_LDADD=libs/ui/libQFui.la libs_ui_test_test_vrect_DEPENDENCIES=libs/ui/libQFui.la diff --git a/libs/util/test/Makemodule.am b/libs/util/test/Makemodule.am index 64cc8b9e4..6d6df0b10 100644 --- a/libs/util/test/Makemodule.am +++ b/libs/util/test/Makemodule.am @@ -31,111 +31,111 @@ TESTS += $(libs_util_tests) check_PROGRAMS += $(libs_util_tests) -libs_util_test_test_bary_SOURCES=libs/util/test/test-bary.c +libs_util_test_test_bary_SOURCES=libs/util/test/test-bary.c $(tracy_src) libs_util_test_test_bary_LDADD=libs/util/libQFutil.la libs_util_test_test_bary_DEPENDENCIES=libs/util/libQFutil.la -libs_util_test_test_baryvf_SOURCES=libs/util/test/test-baryvf.c +libs_util_test_test_baryvf_SOURCES=libs/util/test/test-baryvf.c $(tracy_src) libs_util_test_test_baryvf_LDADD=libs/util/libQFutil.la libs_util_test_test_baryvf_DEPENDENCIES=libs/util/libQFutil.la -libs_util_test_test_bitop_SOURCES=libs/util/test/test-bitop.c +libs_util_test_test_bitop_SOURCES=libs/util/test/test-bitop.c $(tracy_src) libs_util_test_test_bitop_LDADD=libs/util/libQFutil.la libs_util_test_test_bitop_DEPENDENCIES=libs/util/libQFutil.la -libs_util_test_test_bsearch_SOURCES=libs/util/test/test-bsearch.c +libs_util_test_test_bsearch_SOURCES=libs/util/test/test-bsearch.c $(tracy_src) libs_util_test_test_bsearch_LDADD=libs/util/libQFutil.la libs_util_test_test_bsearch_DEPENDENCIES=libs/util/libQFutil.la -libs_util_test_test_cexpr_SOURCES=libs/util/test/test-cexpr.c +libs_util_test_test_cexpr_SOURCES=libs/util/test/test-cexpr.c $(tracy_src) libs_util_test_test_cexpr_LDADD=libs/util/libQFutil.la libs_util_test_test_cexpr_DEPENDENCIES=libs/util/libQFutil.la -libs_util_test_test_cmem_SOURCES=libs/util/test/test-cmem.c +libs_util_test_test_cmem_SOURCES=libs/util/test/test-cmem.c $(tracy_src) libs_util_test_test_cmem_LDADD=libs/util/libQFutil.la libs_util_test_test_cmem_DEPENDENCIES=libs/util/libQFutil.la -libs_util_test_test_cs_SOURCES=libs/util/test/test-cs.c +libs_util_test_test_cs_SOURCES=libs/util/test/test-cs.c $(tracy_src) libs_util_test_test_cs_LDADD=libs/util/libQFutil.la libs_util_test_test_cs_DEPENDENCIES=libs/util/libQFutil.la -libs_util_test_test_csvf_SOURCES=libs/util/test/test-csvf.c +libs_util_test_test_csvf_SOURCES=libs/util/test/test-csvf.c $(tracy_src) libs_util_test_test_csvf_LDADD=libs/util/libQFutil.la libs_util_test_test_csvf_DEPENDENCIES=libs/util/libQFutil.la -libs_util_test_test_darray_SOURCES=libs/util/test/test-darray.c +libs_util_test_test_darray_SOURCES=libs/util/test/test-darray.c $(tracy_src) libs_util_test_test_darray_LDADD=libs/util/libQFutil.la libs_util_test_test_darray_DEPENDENCIES=libs/util/libQFutil.la -libs_util_test_test_dq_SOURCES=libs/util/test/test-dq.c +libs_util_test_test_dq_SOURCES=libs/util/test/test-dq.c $(tracy_src) libs_util_test_test_dq_LDADD=libs/util/libQFutil.la libs_util_test_test_dq_DEPENDENCIES=libs/util/libQFutil.la -libs_util_test_test_half_SOURCES=libs/util/test/test-half.c +libs_util_test_test_half_SOURCES=libs/util/test/test-half.c $(tracy_src) libs_util_test_test_half_LDADD=libs/util/libQFutil.la libs_util_test_test_half_DEPENDENCIES=libs/util/libQFutil.la -libs_util_test_test_heapsort_SOURCES=libs/util/test/test-heapsort.c +libs_util_test_test_heapsort_SOURCES=libs/util/test/test-heapsort.c $(tracy_src) libs_util_test_test_heapsort_LDADD=libs/util/libQFutil.la libs_util_test_test_heapsort_DEPENDENCIES=libs/util/libQFutil.la -libs_util_test_test_listener_SOURCES=libs/util/test/test-listener.c +libs_util_test_test_listener_SOURCES=libs/util/test/test-listener.c $(tracy_src) libs_util_test_test_listener_LDADD=libs/util/libQFutil.la libs_util_test_test_listener_DEPENDENCIES=libs/util/libQFutil.la -libs_util_test_test_mat3_SOURCES=libs/util/test/test-mat3.c +libs_util_test_test_mat3_SOURCES=libs/util/test/test-mat3.c $(tracy_src) libs_util_test_test_mat3_LDADD=libs/util/libQFutil.la libs_util_test_test_mat3_DEPENDENCIES=libs/util/libQFutil.la -libs_util_test_test_mat4_SOURCES=libs/util/test/test-mat4.c +libs_util_test_test_mat4_SOURCES=libs/util/test/test-mat4.c $(tracy_src) libs_util_test_test_mat4_LDADD=libs/util/libQFutil.la libs_util_test_test_mat4_DEPENDENCIES=libs/util/libQFutil.la -libs_util_test_test_plist_SOURCES=libs/util/test/test-plist.c +libs_util_test_test_plist_SOURCES=libs/util/test/test-plist.c $(tracy_src) libs_util_test_test_plist_LDADD=libs/util/libQFutil.la libs_util_test_test_plist_DEPENDENCIES=libs/util/libQFutil.la -libs_util_test_test_pqueue_SOURCES=libs/util/test/test-pqueue.c +libs_util_test_test_pqueue_SOURCES=libs/util/test/test-pqueue.c $(tracy_src) libs_util_test_test_pqueue_LDADD=libs/util/libQFutil.la libs_util_test_test_pqueue_DEPENDENCIES=libs/util/libQFutil.la -libs_util_test_test_qfs_SOURCES=libs/util/test/test-qfs.c +libs_util_test_test_qfs_SOURCES=libs/util/test/test-qfs.c $(tracy_src) libs_util_test_test_qfs_LDADD=libs/util/libQFutil.la libs_util_test_test_qfs_DEPENDENCIES=libs/util/libQFutil.la -libs_util_test_test_quat_SOURCES=libs/util/test/test-quat.c +libs_util_test_test_quat_SOURCES=libs/util/test/test-quat.c $(tracy_src) libs_util_test_test_quat_LDADD=libs/util/libQFutil.la libs_util_test_test_quat_DEPENDENCIES=libs/util/libQFutil.la -libs_util_test_test_ringbuffer_SOURCES=libs/util/test/test-ringbuffer.c +libs_util_test_test_ringbuffer_SOURCES=libs/util/test/test-ringbuffer.c $(tracy_src) libs_util_test_test_ringbuffer_LDADD=libs/util/libQFutil.la libs_util_test_test_ringbuffer_LDFLAGS=-pthread libs_util_test_test_ringbuffer_DEPENDENCIES=libs/util/libQFutil.la -libs_util_test_test_seb_SOURCES=libs/util/test/test-seb.c +libs_util_test_test_seb_SOURCES=libs/util/test/test-seb.c $(tracy_src) libs_util_test_test_seb_LDADD=libs/util/libQFutil.la libs_util_test_test_seb_DEPENDENCIES=libs/util/libQFutil.la -libs_util_test_test_sebvf_SOURCES=libs/util/test/test-sebvf.c +libs_util_test_test_sebvf_SOURCES=libs/util/test/test-sebvf.c $(tracy_src) libs_util_test_test_sebvf_LDADD=libs/util/libQFutil.la libs_util_test_test_sebvf_DEPENDENCIES=libs/util/libQFutil.la -libs_util_test_test_seg_SOURCES=libs/util/test/test-seg.c +libs_util_test_test_seg_SOURCES=libs/util/test/test-seg.c $(tracy_src) libs_util_test_test_seg_LDADD=libs/util/libQFutil.la libs_util_test_test_seg_DEPENDENCIES=libs/util/libQFutil.la -libs_util_test_test_set_SOURCES=libs/util/test/test-set.c +libs_util_test_test_set_SOURCES=libs/util/test/test-set.c $(tracy_src) libs_util_test_test_set_LDADD=libs/util/libQFutil.la libs_util_test_test_set_DEPENDENCIES=libs/util/libQFutil.la -libs_util_test_test_simd_SOURCES=libs/util/test/test-simd.c +libs_util_test_test_simd_SOURCES=libs/util/test/test-simd.c $(tracy_src) libs_util_test_test_simd_LDADD=libs/util/libQFutil.la libs_util_test_test_simd_DEPENDENCIES=libs/util/libQFutil.la -libs_util_test_test_utf8_SOURCES=libs/util/test/test-utf8.c +libs_util_test_test_utf8_SOURCES=libs/util/test/test-utf8.c $(tracy_src) libs_util_test_test_utf8_LDADD=libs/util/libQFutil.la libs_util_test_test_utf8_DEPENDENCIES=libs/util/libQFutil.la -libs_util_test_test_zone_SOURCES=libs/util/test/test-zone.c +libs_util_test_test_zone_SOURCES=libs/util/test/test-zone.c $(tracy_src) libs_util_test_test_zone_LDADD=libs/util/libQFutil.la libs_util_test_test_zone_DEPENDENCIES=libs/util/libQFutil.la diff --git a/libs/video/renderer/vulkan/test/Makemodule.am b/libs/video/renderer/vulkan/test/Makemodule.am index 8d4f8f77a..9940de4ac 100644 --- a/libs/video/renderer/vulkan/test/Makemodule.am +++ b/libs/video/renderer/vulkan/test/Makemodule.am @@ -13,7 +13,8 @@ libs_video_renderer_vulkan_test_libs= \ libs/util/libQFutil.la libs_video_renderer_vulkan_test_test_staging_SOURCES= \ - libs/video/renderer/vulkan/test/test-staging.c + libs/video/renderer/vulkan/test/test-staging.c \ + $(tracy_src) libs_video_renderer_vulkan_test_test_staging_LDADD= \ $(libs_video_renderer_vulkan_test_libs) libs_video_renderer_vulkan_test_test_staging_DEPENDENCIES= \ diff --git a/qw/source/Makemodule.am b/qw/source/Makemodule.am index b9d7c061b..a061b74a4 100644 --- a/qw/source/Makemodule.am +++ b/qw/source/Makemodule.am @@ -76,7 +76,7 @@ qw_server_LDFLAGS= $(common_ldflags) qw_server_DEPENDENCIES= $(qw_server_deps) qw_master_deps=libs/util/libQFutil.la -qw_master_SOURCES= qw/source/master.c +qw_master_SOURCES= qw/source/master.c $(tracy_src) qw_master_LDADD= $(qw_master_deps) $(NET_LIBS) qw_master_DEPENDENCIES= $(qw_master_deps) qw_master_LDFLAGS= $(common_ldflags) diff --git a/ruamoko/qwaq/Makemodule.am b/ruamoko/qwaq/Makemodule.am index fbce5a53f..225d7953b 100644 --- a/ruamoko/qwaq/Makemodule.am +++ b/ruamoko/qwaq/Makemodule.am @@ -77,7 +77,8 @@ ruamoko_qwaq_qwaq_curses_SOURCES= \ ruamoko/qwaq/builtins/editbuffer.c \ ruamoko/qwaq/builtins/qwaq-curses.c \ ruamoko/qwaq/builtins/term-input.c \ - ruamoko/qwaq/builtins/threading.c + ruamoko/qwaq/builtins/threading.c \ + $(tracy_src) ruamoko_qwaq_qwaq_curses_LDADD= $(qwaq_curses_libs) $(QWAQ_LIBS) \ $(PANEL_LIBS) $(NCURSES_LIBS) $(PTHREAD_LDFLAGS) $(DL_LIBS) @@ -88,7 +89,8 @@ qwaq_cmd_libs= ruamoko_qwaq_qwaq_cmd_SOURCES= \ ruamoko/qwaq/builtins/main.c \ - ruamoko/qwaq/builtins/qwaq-cmd.c + ruamoko/qwaq/builtins/qwaq-cmd.c \ + $(tracy_src) ruamoko_qwaq_qwaq_cmd_LDADD= $(qwaq_cmd_libs) $(QWAQ_LIBS) \ $(PTHREAD_LDFLAGS) $(DL_LIBS) diff --git a/tools/bsp2img/Makemodule.am b/tools/bsp2img/Makemodule.am index 24b6594c2..2011116e7 100644 --- a/tools/bsp2img/Makemodule.am +++ b/tools/bsp2img/Makemodule.am @@ -5,6 +5,6 @@ BSP2IMG_INCS=@BSP2IMG_INCS@ EXTRA_PROGRAMS += bsp2img bin_PROGRAMS += @BSP2IMG_TARGETS@ -bsp2img_SOURCES= tools/bsp2img/bsp2img.c +bsp2img_SOURCES= tools/bsp2img/bsp2img.c $(tracy_src) bsp2img_LDADD= $(BSP2IMG_LIBS) bsp2img_DEPENDENCIES= $(BSP2IMG_DEPS) diff --git a/tools/carne/Makemodule.am b/tools/carne/Makemodule.am index fe5862c0e..968248ba7 100644 --- a/tools/carne/Makemodule.am +++ b/tools/carne/Makemodule.am @@ -4,6 +4,6 @@ CARNE_DEPS=@CARNE_DEPS@ EXTRA_PROGRAMS += carne noinst_PROGRAMS += @CARNE_TARGETS@ -carne_SOURCES= tools/carne/main.c +carne_SOURCES= tools/carne/main.c $(tracy_src) carne_LDADD= $(CARNE_LIBS) carne_DEPENDENCIES= $(CARNE_DEPS) diff --git a/tools/pak/Makemodule.am b/tools/pak/Makemodule.am index 3716b0b17..ccd54f0a5 100644 --- a/tools/pak/Makemodule.am +++ b/tools/pak/Makemodule.am @@ -8,7 +8,7 @@ bin_SCRIPTS += tools/pak/zpak man_MANS += tools/pak/pak.1 tools/pak/zpak.1 -pak_SOURCES= tools/pak/pak.c +pak_SOURCES= tools/pak/pak.c $(tracy_src) pak_LDADD= $(PAK_LIBS) pak_DEPENDENCIES= $(PAK_DEPS) diff --git a/tools/qfbsp/source/Makemodule.am b/tools/qfbsp/source/Makemodule.am index 084a1ecf9..ca6265857 100644 --- a/tools/qfbsp/source/Makemodule.am +++ b/tools/qfbsp/source/Makemodule.am @@ -21,7 +21,8 @@ qfbsp_SOURCES= \ tools/qfbsp/source/solidbsp.c \ tools/qfbsp/source/surfaces.c \ tools/qfbsp/source/tjunc.c \ - tools/qfbsp/source/writebsp.c + tools/qfbsp/source/writebsp.c \ + $(tracy_src) qfbsp_LDADD= $(QFBSP_LIBS) qfbsp_DEPENDENCIES= $(QFBSP_DEPS) diff --git a/tools/qfcc/source/Makemodule.am b/tools/qfcc/source/Makemodule.am index 61a0babaa..04b4c84ea 100644 --- a/tools/qfcc/source/Makemodule.am +++ b/tools/qfcc/source/Makemodule.am @@ -61,7 +61,8 @@ qfcc_SOURCES = \ tools/qfcc/source/switch.c \ tools/qfcc/source/symtab.c \ tools/qfcc/source/type.c \ - tools/qfcc/source/value.c + tools/qfcc/source/value.c \ + $(tracy_src) qfcc_LDADD= $(QFCC_LIBS) qfcc_DEPENDENCIES= $(QFCC_DEPS) @@ -76,7 +77,8 @@ qfprogs_SOURCES= \ tools/qfcc/source/qfprogs.c \ tools/qfcc/source/strpool.c \ tools/qfcc/source/stub.c \ - tools/qfcc/source/type.c + tools/qfcc/source/type.c \ + $(tracy_src) qfprogs_LDADD= $(QFCC_LIBS) qfprogs_DEPENDENCIES= $(QFCC_DEPS) diff --git a/tools/qfcc/test/Makemodule.am b/tools/qfcc/test/Makemodule.am index b4c2dd853..fbb88cc8c 100644 --- a/tools/qfcc/test/Makemodule.am +++ b/tools/qfcc/test/Makemodule.am @@ -128,11 +128,16 @@ check_PROGRAMS += \ qfcc-tests: tools/qfcc/test/test-harness $(test_progs_dat) $(test_bins) -tools_qfcc_test_test_defspace_SOURCES= tools/qfcc/test/test-defspace.c $(test_defspace_src) +tools_qfcc_test_test_defspace_SOURCES= \ + tools/qfcc/test/test-defspace.c \ + $(test_defspace_src) \ + $(tracy_src) tools_qfcc_test_test_defspace_LDADD= $(QFCC_LIBS) tools_qfcc_test_test_defspace_DEPENDENCIES= $(QFCC_DEPS) -tools_qfcc_test_test_harness_SOURCES= tools/qfcc/test/test-bi.c tools/qfcc/test/test-harness.c +tools_qfcc_test_test_harness_SOURCES= \ + tools/qfcc/test/test-bi.c tools/qfcc/test/test-harness.c \ + $(tracy_src) tools_qfcc_test_test_harness_LDADD= $(QFCC_TEST_LIBS) tools_qfcc_test_test_harness_DEPENDENCIES= $(QFCC_TEST_DEPS) diff --git a/tools/qflight/source/Makemodule.am b/tools/qflight/source/Makemodule.am index 8990cea7a..1d4a1de7d 100644 --- a/tools/qflight/source/Makemodule.am +++ b/tools/qflight/source/Makemodule.am @@ -14,7 +14,8 @@ qflight_SOURCES=\ tools/qflight/source/qflight.c \ tools/qflight/source/threads.c \ tools/qflight/source/trace.c \ - tools/qflight/source/vis.c + tools/qflight/source/vis.c \ + $(tracy_src) qflight_LDFLAGS= $(PTHREAD_LDFLAGS) qflight_LDADD= $(QFLIGHT_LIBS) diff --git a/tools/qflmp/Makemodule.am b/tools/qflmp/Makemodule.am index f1a07221a..295e6b10e 100644 --- a/tools/qflmp/Makemodule.am +++ b/tools/qflmp/Makemodule.am @@ -8,7 +8,7 @@ bin_PROGRAMS += @QFLMP_TARGETS@ #mans=qflmp.1 man_MANS += $(mans) -qflmp_SOURCES= tools/qflmp/lmp.c +qflmp_SOURCES= tools/qflmp/lmp.c $(tracy_src) qflmp_LDADD= $(QFLMP_LIBS) qflmp_DEPENDENCIES= $(QFLMP_DEPS) diff --git a/tools/qfmodelgen/source/Makemodule.am b/tools/qfmodelgen/source/Makemodule.am index 86d40702e..996c3515d 100644 --- a/tools/qfmodelgen/source/Makemodule.am +++ b/tools/qfmodelgen/source/Makemodule.am @@ -8,7 +8,8 @@ bin_PROGRAMS += @QFMODELGEN_TARGETS@ qfmodelgen_SOURCES = \ tools/qfmodelgen/source/lbmlib.c \ tools/qfmodelgen/source/modelgen.c \ - tools/qfmodelgen/source/trilib.c + tools/qfmodelgen/source/trilib.c \ + $(tracy_src) qfmodelgen_LDADD= $(QFMODELGEN_LIBS) qfmodelgen_DEPENDENCIES= $(QFMODELGEN_DEPS) diff --git a/tools/qfspritegen/Makemodule.am b/tools/qfspritegen/Makemodule.am index ae36299e5..abb5237e4 100644 --- a/tools/qfspritegen/Makemodule.am +++ b/tools/qfspritegen/Makemodule.am @@ -5,7 +5,7 @@ QFSPRITEGEN_INCS=@QFSPRITEGEN_INCS@ EXTRA_PROGRAMS += qfspritegen bin_PROGRAMS += @QFSPRITEGEN_TARGETS@ -qfspritegen_SOURCES= tools/qfspritegen/spritegen.c +qfspritegen_SOURCES= tools/qfspritegen/spritegen.c $(tracy_src) qfspritegen_LDADD= $(QFSPRITEGEN_LIBS) qfspritegen_DEPENDENCIES= $(QFSPRITEGEN_DEPS) diff --git a/tools/qfvis/source/Makemodule.am b/tools/qfvis/source/Makemodule.am index 7efb7bbe2..8f7151fb6 100644 --- a/tools/qfvis/source/Makemodule.am +++ b/tools/qfvis/source/Makemodule.am @@ -11,7 +11,8 @@ qfvis_SOURCES = \ tools/qfvis/source/flow.c \ tools/qfvis/source/options.c \ tools/qfvis/source/qfvis.c \ - tools/qfvis/source/soundphs.c + tools/qfvis/source/soundphs.c \ + $(tracy_src) qfvis_LDFLAGS= $(PTHREAD_LDFLAGS) qfvis_LDADD= $(QFVIS_LIBS) diff --git a/tools/tracy/qftracy_mem.c b/tools/tracy/qftracy_mem.c new file mode 100644 index 000000000..32325288b --- /dev/null +++ b/tools/tracy/qftracy_mem.c @@ -0,0 +1,81 @@ +#ifdef TRACY_ENABLE + +#include + +void *qf_aligned_alloc (size_t a, size_t s) asm("aligned_alloc"); +void *qf_malloc (size_t s) asm("malloc"); +void *qf_calloc (size_t c, size_t s) asm("calloc"); +void *qf_realloc (void *p, size_t s) asm("realloc"); +void qf_free (void *p) asm("free"); +char *qf_strdup (const char *s) asm("strdup"); +char *qf_getcwd (char *b, size_t s) asm("getcwd"); + +void *aligned_alloc (size_t a, size_t s) +{ + void *p = qf_aligned_alloc (a, s); + if (p) { + TracyCAlloc (p, s); + } + return p; +} + +void *malloc (size_t s) +{ + void *p = qf_malloc (s); + if (p) { + TracyCAlloc (p, s); + } + return p; +} + +void *calloc (size_t c, size_t s) +{ + void *p = qf_calloc (c, s); + if (p) { + TracyCAlloc (p, c * s); + } + return p; +} + +void *realloc (void *p, size_t s) +{ + if (p) { + TracyCFree(p); + } + p = qf_realloc (p, s); + if (p) { + TracyCAlloc (p, s); + } + return p; +} + +void free (void *p) +{ + if (p) { + TracyCFree(p); + } + qf_free (p); +} + +char *strdup (const char *s) +{ + char *p = qf_strdup (s); + if (p) { + TracyCAlloc (p, strlen (p) + 1); + } + return p; +} + +char *getcwd (char *b, size_t s) +{ + if (!b) { + char *p = qf_getcwd (b, s); + if (p) { + TracyCAlloc (p, strlen (p) + 1); + } + return p; + } else { + return qf_getcwd (b, s); + } +} +#endif diff --git a/tools/wad/Makemodule.am b/tools/wad/Makemodule.am index 13fcf3a43..b259fb6e1 100644 --- a/tools/wad/Makemodule.am +++ b/tools/wad/Makemodule.am @@ -7,7 +7,7 @@ bin_PROGRAMS += @WAD_TARGETS@ man_MANS += tools/wad/wad.1 -wad_SOURCES= tools/wad/grab.c tools/wad/script.c tools/wad/wad.c +wad_SOURCES= tools/wad/grab.c tools/wad/script.c tools/wad/wad.c $(tracy_src) wad_LDADD= $(WAD_LIBS) wad_DEPENDENCIES= $(WAD_DEPS) diff --git a/tools/wav/Makemodule.am b/tools/wav/Makemodule.am index 6eb727ad0..16e9015f9 100644 --- a/tools/wav/Makemodule.am +++ b/tools/wav/Makemodule.am @@ -7,6 +7,6 @@ bin_PROGRAMS += @WAV_TARGETS@ #man_MANS += tools/wav/qfwavinfo.1 -qfwavinfo_SOURCES= tools/wav/qfwavinfo.c +qfwavinfo_SOURCES= tools/wav/qfwavinfo.c $(tracy_src) qfwavinfo_LDADD= $(WAV_LIBS) qfwavinfo_DEPENDENCIES= $(WAV_DEPS)