Callstack frame map must not be touched by statistics.

This commit is contained in:
Bartosz Taudul 2020-02-29 19:49:33 +01:00
parent 8d5755521e
commit d1ff99d6e3
3 changed files with 21 additions and 2 deletions

View File

@ -13456,7 +13456,7 @@ void View::DrawSampleParents()
int bidx = 0;
for( auto& entry : cs )
{
auto frameData = m_worker.GetCallstackFrame( entry );
auto frameData = entry.custom ? m_worker.GetParentCallstackFrame( entry ) : m_worker.GetCallstackFrame( entry );
assert( frameData );
const auto fsz = frameData->size;
for( uint8_t f=0; f<fsz; f++ )

View File

@ -2041,6 +2041,7 @@ std::pair<int, int> Worker::GetFrameRange( const FrameData& fd, int64_t from, in
const CallstackFrameData* Worker::GetCallstackFrame( const CallstackFrameId& ptr ) const
{
assert( ptr.custom == 0 );
auto it = m_data.callstackFrameMap.find( ptr );
if( it == m_data.callstackFrameMap.end() )
{
@ -2052,6 +2053,22 @@ const CallstackFrameData* Worker::GetCallstackFrame( const CallstackFrameId& ptr
}
}
#ifndef TRACY_NO_STATISTICS
const CallstackFrameData* Worker::GetParentCallstackFrame( const CallstackFrameId& ptr ) const
{
assert( ptr.custom == 1 );
auto it = m_data.parentCallstackFrameMap.find( ptr );
if( it == m_data.parentCallstackFrameMap.end() )
{
return nullptr;
}
else
{
return it->second;
}
}
#endif
const SymbolData* Worker::GetSymbolData( uint64_t sym ) const
{
auto it = m_data.symbolMap.find( sym );
@ -5402,7 +5419,7 @@ void Worker::UpdateSampleStatisticsImpl( const CallstackFrameData** frames, uint
parentFrameId.idx = m_callstackParentNextIdx++;
parentFrameId.sel = 0;
parentFrameId.custom = 1;
m_data.callstackFrameMap.emplace( parentFrameId, frameData );
m_data.parentCallstackFrameMap.emplace( parentFrameId, frameData );
m_data.revParentFrameMap.emplace( frameData, parentFrameId );
}
else

View File

@ -229,6 +229,7 @@ private:
#ifndef TRACY_NO_STATISTICS
unordered_flat_map<VarArray<CallstackFrameId>*, uint32_t, VarArrayHasher<CallstackFrameId>, VarArrayComparator<CallstackFrameId>> parentCallstackMap;
Vector<short_ptr<VarArray<CallstackFrameId>>> parentCallstackPayload;
unordered_flat_map<CallstackFrameId, CallstackFrameData*, CallstackFrameIdHash, CallstackFrameIdCompare> parentCallstackFrameMap;
unordered_flat_map<CallstackFrameData*, CallstackFrameId, RevFrameHash, RevFrameComp> revParentFrameMap;
unordered_flat_map<uint32_t, uint32_t> postponedSamples;
bool newFramesWereReceived = false;
@ -407,6 +408,7 @@ public:
#ifndef TRACY_NO_STATISTICS
const VarArray<CallstackFrameId>& GetParentCallstack( uint32_t idx ) const { return *m_data.parentCallstackPayload[idx]; }
const CallstackFrameData* GetParentCallstackFrame( const CallstackFrameId& ptr ) const;
#endif
const CrashEvent& GetCrashEvent() const { return m_data.crashEvent; }