Configurable callstack depth.

This commit is contained in:
Bartosz Taudul 2018-06-19 18:49:13 +02:00
parent 5368f386ce
commit d2a98c3090

View File

@ -10,6 +10,7 @@ extern "C" __declspec(dllimport) unsigned short __stdcall RtlCaptureStackBackTra
#ifdef TRACY_HAS_CALLSTACK #ifdef TRACY_HAS_CALLSTACK
#include <assert.h>
#include <stdint.h> #include <stdint.h>
#include <string.h> #include <string.h>
@ -31,13 +32,12 @@ struct CallstackEntry
void InitCallstack(); void InitCallstack();
CallstackEntry DecodeCallstackPtr( uint64_t ptr ); CallstackEntry DecodeCallstackPtr( uint64_t ptr );
static tracy_force_inline void* Callstack() static tracy_force_inline void* Callstack( int depth )
{ {
enum { StackDepth = 24 }; assert( depth >= 1 && depth <= 63 );
static_assert( StackDepth <= 63, "Stack depth can't be greater than 63." );
auto trace = (uintptr_t*)tracy_malloc( ( 1 + StackDepth ) * sizeof( uintptr_t ) ); auto trace = (uintptr_t*)tracy_malloc( ( 1 + depth ) * sizeof( uintptr_t ) );
const auto num = RtlCaptureStackBackTrace( 0, StackDepth, (void**)( trace+1 ), nullptr ); const auto num = RtlCaptureStackBackTrace( 0, depth, (void**)( trace+1 ), nullptr );
*trace = num; *trace = num;
return trace; return trace;