From 4509412efb337d4c18903490202df69ca39ad9cc Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Tue, 5 Mar 2019 18:56:39 +0100 Subject: [PATCH] Fast callstack retrieval for linux. --- client/TracyCallstack.cpp | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/client/TracyCallstack.cpp b/client/TracyCallstack.cpp index f618eee3..b3d75495 100644 --- a/client/TracyCallstack.cpp +++ b/client/TracyCallstack.cpp @@ -314,12 +314,28 @@ static inline char* CopyString( const char* src ) return dst; } +static int FastCallstackDataCb( void* data, uintptr_t pc, const char* fn, int lineno, const char* function ) +{ + if( function ) + { + strcpy( data, function ); + } + else + { + *data = '\0'; + } + return 1; +} + +static void FastCallstackErrorCb( void* data, const char* /*msg*/, int /*errnum*/ ) +{ + *data = '\0'; +} + const char* DecodeCallstackPtrFast( uint64_t ptr ) { static char ret[1024]; - - // TODO - + backtrace_pcinfo( cb_bts, ptr, FastCallstackDataCb, FastCallstackErrorCb, ret ); return ret; }