Allow skipping functions on top of call stack.

Note that this is on-client performance intensive and shouldn't be used,
except in special situations, like processing crashes.
This commit is contained in:
Bartosz Taudul 2018-08-20 22:20:44 +02:00
parent b371003336
commit d1adf9e8d6
2 changed files with 39 additions and 0 deletions

View File

@ -1526,6 +1526,43 @@ void Profiler::CalibrateDelay()
}
}
void Profiler::SendCallstack( int depth, uint64_t thread, const char* skipBefore )
{
#ifdef TRACY_HAS_CALLSTACK
auto ptr = Callstack( depth );
auto data = (uintptr_t*)ptr;
const auto sz = *data++;
int i;
for( i=0; i<sz; i++ )
{
auto frame = DecodeCallstackPtr( uint64_t( data[i] ) );
const bool found = strcmp( frame.name, skipBefore ) == 0;
tracy_free( (void*)frame.name );
tracy_free( (void*)frame.file );
if( found )
{
i++;
break;
}
}
if( i != sz )
{
memmove( data, data + i, ( sz - i ) * sizeof( uintptr_t* ) );
*--data = sz - i;
}
Magic magic;
auto& token = s_token.ptr;
auto& tail = token->get_tail_index();
auto item = token->enqueue_begin<tracy::moodycamel::CanAlloc>( magic );
MemWrite( &item->hdr.type, QueueType::Callstack );
MemWrite( &item->callstack.ptr, ptr );
MemWrite( &item->callstack.thread, thread );
tail.store( magic + 1, std::memory_order_release );
#endif
}
}
#endif

View File

@ -325,6 +325,8 @@ public:
#endif
}
void SendCallstack( int depth, uint64_t thread, const char* skipBefore );
static bool ShouldExit();
#ifdef TRACY_ON_DEMAND