Pack/unpack frame pointer to callstack frame id.

This commit is contained in:
Bartosz Taudul 2019-03-03 16:39:13 +01:00
parent 1feedb17ac
commit 664847211c
2 changed files with 16 additions and 0 deletions

View File

@ -40,6 +40,15 @@
namespace tracy namespace tracy
{ {
static inline CallstackFrameId PackPointer( uint64_t ptr )
{
assert( ( ( ptr & 0x4000000000000000 ) << 1 ) == ( ptr & 0x8000000000000000 ) );
CallstackFrameId id;
id.idx = ptr;
id.sel = 0;
return id;
}
static constexpr int FileVersion( uint8_t h5, uint8_t h6, uint8_t h7 ) static constexpr int FileVersion( uint8_t h5, uint8_t h6, uint8_t h7 )
{ {
return ( h5 << 16 ) | ( h6 << 8 ) | h7; return ( h5 << 16 ) | ( h6 << 8 ) | h7;
@ -2021,6 +2030,12 @@ void Worker::AddCustomString( uint64_t ptr, char* str, size_t sz )
m_pendingCustomStrings.emplace( ptr, StoreString( str, sz ) ); m_pendingCustomStrings.emplace( ptr, StoreString( str, sz ) );
} }
uint64_t Worker::GetCanonicalPointer( const CallstackFrameId& id ) const
{
assert( id.sel == 0 );
return ( id.idx & 0x7FFFFFFFFFFFFFFF ) | ( ( id.idx & 0x4000000000000000 ) << 1 );
}
void Worker::AddCallstackPayload( uint64_t ptr, char* _data, size_t sz ) void Worker::AddCallstackPayload( uint64_t ptr, char* _data, size_t sz )
{ {
assert( m_pendingCallstacks.find( ptr ) == m_pendingCallstacks.end() ); assert( m_pendingCallstacks.find( ptr ) == m_pendingCallstacks.end() );

View File

@ -246,6 +246,7 @@ public:
const VarArray<uint64_t>& GetCallstack( uint32_t idx ) const { return *m_data.callstackPayload[idx]; } const VarArray<uint64_t>& GetCallstack( uint32_t idx ) const { return *m_data.callstackPayload[idx]; }
const CallstackFrameData* GetCallstackFrame( uint64_t ptr ) const; const CallstackFrameData* GetCallstackFrame( uint64_t ptr ) const;
uint64_t GetCanonicalPointer( const CallstackFrameId& id ) const;
const CrashEvent& GetCrashEvent() const { return m_data.m_crashEvent; } const CrashEvent& GetCrashEvent() const { return m_data.m_crashEvent; }