From 278330af5b3c850b59ae0f7621b88b973050b2af Mon Sep 17 00:00:00 2001 From: Jeff Burnett Date: Fri, 22 Mar 2024 09:34:51 -0500 Subject: [PATCH 1/2] Fix build warnings for TRACY_NO_CALLSTACK Fix build warnings about undefined TRACY_HAS_CALLSTACK and an unused argument for Callstack() when TRACY_NO_CALLSTACK is defined. --- public/TracyClient.cpp | 28 +++++++++++++++------------- public/client/TracyCallstack.hpp | 18 +++++++++--------- 2 files changed, 24 insertions(+), 22 deletions(-) diff --git a/public/TracyClient.cpp b/public/TracyClient.cpp index 26387b76..74811901 100644 --- a/public/TracyClient.cpp +++ b/public/TracyClient.cpp @@ -31,20 +31,22 @@ #include "client/TracyAlloc.cpp" #include "client/TracyOverride.cpp" -#if TRACY_HAS_CALLSTACK == 2 || TRACY_HAS_CALLSTACK == 3 || TRACY_HAS_CALLSTACK == 4 || TRACY_HAS_CALLSTACK == 6 -# include "libbacktrace/alloc.cpp" -# include "libbacktrace/dwarf.cpp" -# include "libbacktrace/fileline.cpp" -# include "libbacktrace/mmapio.cpp" -# include "libbacktrace/posix.cpp" -# include "libbacktrace/sort.cpp" -# include "libbacktrace/state.cpp" -# if TRACY_HAS_CALLSTACK == 4 -# include "libbacktrace/macho.cpp" -# else -# include "libbacktrace/elf.cpp" +#if defined(TRACY_HAS_CALLSTACK) +# if TRACY_HAS_CALLSTACK == 2 || TRACY_HAS_CALLSTACK == 3 || TRACY_HAS_CALLSTACK == 4 || TRACY_HAS_CALLSTACK == 6 +# include "libbacktrace/alloc.cpp" +# include "libbacktrace/dwarf.cpp" +# include "libbacktrace/fileline.cpp" +# include "libbacktrace/mmapio.cpp" +# include "libbacktrace/posix.cpp" +# include "libbacktrace/sort.cpp" +# include "libbacktrace/state.cpp" +# if TRACY_HAS_CALLSTACK == 4 +# include "libbacktrace/macho.cpp" +# else +# include "libbacktrace/elf.cpp" +# endif +# include "common/TracyStackFrames.cpp" # endif -# include "common/TracyStackFrames.cpp" #endif #ifdef _MSC_VER diff --git a/public/client/TracyCallstack.hpp b/public/client/TracyCallstack.hpp index e1de3821..fdc9345d 100644 --- a/public/client/TracyCallstack.hpp +++ b/public/client/TracyCallstack.hpp @@ -5,6 +5,15 @@ #include "../common/TracyForceInline.hpp" #include "TracyCallstack.h" +#ifndef TRACY_HAS_CALLSTACK + +namespace tracy +{ +static tracy_force_inline void* Callstack( int /*depth*/ ) { return nullptr; } +} + +#else + #if TRACY_HAS_CALLSTACK == 2 || TRACY_HAS_CALLSTACK == 5 # include #elif TRACY_HAS_CALLSTACK >= 3 @@ -17,15 +26,6 @@ # endif #endif -#ifndef TRACY_HAS_CALLSTACK - -namespace tracy -{ -static tracy_force_inline void* Callstack( int depth ) { return nullptr; } -} - -#else - #ifdef TRACY_DEBUGINFOD # include #endif From 18352366f71f3b9fbadd78ba7b61d875cb594569 Mon Sep 17 00:00:00 2001 From: Jeff Burnett Date: Thu, 21 Mar 2024 07:53:27 -0500 Subject: [PATCH 2/2] Still use named mem pool if no callstacks Forward MemAllocCallstackNamed() and MemFreeCallstackNamed() to MemAllocNamed() and MemFreeNamed if callstack capture is off. --- public/client/TracyProfiler.hpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/public/client/TracyProfiler.hpp b/public/client/TracyProfiler.hpp index 69ef70df..6d4629ea 100644 --- a/public/client/TracyProfiler.hpp +++ b/public/client/TracyProfiler.hpp @@ -605,8 +605,7 @@ public: profiler.m_serialLock.unlock(); #else static_cast(depth); // unused - static_cast(name); // unused - MemAlloc( ptr, size, secure ); + MemAllocNamed( ptr, size, secure, name ); #endif } @@ -629,8 +628,7 @@ public: profiler.m_serialLock.unlock(); #else static_cast(depth); // unused - static_cast(name); // unused - MemFree( ptr, secure ); + MemFreeNamed( ptr, secure, name ); #endif }