From 13370dc01c0055c365a7bfa64376a4255f94c97c Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Sat, 25 Jan 2020 16:49:29 +0100 Subject: [PATCH] Hide RtlWalkFrameChain inside library. --- client/TracyCallstack.cpp | 14 +++++++++++++- client/TracyCallstack.hpp | 18 +++++------------- 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/client/TracyCallstack.cpp b/client/TracyCallstack.cpp index 0e694b45..9280922d 100644 --- a/client/TracyCallstack.cpp +++ b/client/TracyCallstack.cpp @@ -36,7 +36,11 @@ enum { MaxCbTrace = 16 }; int cb_num; CallstackEntry cb_data[MaxCbTrace]; -extern "C" { t_RtlWalkFrameChain RtlWalkFrameChain = 0; } +extern "C" +{ + typedef unsigned long (__stdcall *t_RtlWalkFrameChain)( void**, unsigned long, unsigned long ); + t_RtlWalkFrameChain RtlWalkFrameChain = 0; +} #if defined __MINGW32__ && API_VERSION_NUMBER < 12 extern "C" { @@ -62,6 +66,14 @@ void InitCallstack() SymSetOptions( SYMOPT_LOAD_LINES ); } +TRACY_API tracy_force_inline uintptr_t* CallTrace( int depth ) +{ + auto trace = (uintptr_t*)tracy_malloc( ( 1 + depth ) * sizeof( uintptr_t ) ); + const auto num = RtlWalkFrameChain( (void**)( trace + 1 ), depth, 0 ); + *trace = num; + return trace; +} + const char* DecodeCallstackPtrFast( uint64_t ptr ) { static char ret[1024]; diff --git a/client/TracyCallstack.hpp b/client/TracyCallstack.hpp index 17e514ac..7a88c32b 100644 --- a/client/TracyCallstack.hpp +++ b/client/TracyCallstack.hpp @@ -1,15 +1,10 @@ #ifndef __TRACYCALLSTACK_HPP__ #define __TRACYCALLSTACK_HPP__ +#include "../common/TracyApi.h" #include "TracyCallstack.h" -#if TRACY_HAS_CALLSTACK == 1 -extern "C" -{ - typedef unsigned long (__stdcall *t_RtlWalkFrameChain)( void**, unsigned long, unsigned long ); - extern t_RtlWalkFrameChain RtlWalkFrameChain; -} -#elif TRACY_HAS_CALLSTACK == 2 || TRACY_HAS_CALLSTACK == 5 +#if TRACY_HAS_CALLSTACK == 2 || TRACY_HAS_CALLSTACK == 5 # include #elif TRACY_HAS_CALLSTACK >= 3 # include @@ -46,15 +41,12 @@ void InitCallstack(); #if TRACY_HAS_CALLSTACK == 1 +TRACY_API uintptr_t* CallTrace( int depth ); + static tracy_force_inline void* Callstack( int depth ) { assert( depth >= 1 && depth < 63 ); - - auto trace = (uintptr_t*)tracy_malloc( ( 1 + depth ) * sizeof( uintptr_t ) ); - const auto num = RtlWalkFrameChain( (void**)( trace + 1 ), depth, 0 ); - *trace = num; - - return trace; + return CallTrace( depth ); } #elif TRACY_HAS_CALLSTACK == 2 || TRACY_HAS_CALLSTACK == 5