mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-14 12:04:35 +00:00
Store source location payloads.
No saving yet. No detection of duplicate entries.
This commit is contained in:
parent
4aa93f6285
commit
c6a7bcb086
@ -21,7 +21,8 @@ struct SourceLocation
|
|||||||
uint64_t function; // ptr
|
uint64_t function; // ptr
|
||||||
uint64_t file; // ptr
|
uint64_t file; // ptr
|
||||||
uint32_t line;
|
uint32_t line;
|
||||||
uint32_t color;
|
uint32_t color : 31;
|
||||||
|
uint32_t stringsAllocated : 1;
|
||||||
};
|
};
|
||||||
|
|
||||||
enum { SourceLocationSize = sizeof( SourceLocation ) };
|
enum { SourceLocationSize = sizeof( SourceLocation ) };
|
||||||
@ -31,7 +32,7 @@ struct ZoneEvent
|
|||||||
{
|
{
|
||||||
int64_t start;
|
int64_t start;
|
||||||
int64_t end;
|
int64_t end;
|
||||||
uint32_t srcloc;
|
int32_t srcloc;
|
||||||
int8_t cpu_start;
|
int8_t cpu_start;
|
||||||
int8_t cpu_end;
|
int8_t cpu_end;
|
||||||
|
|
||||||
@ -52,7 +53,7 @@ struct LockEvent
|
|||||||
};
|
};
|
||||||
|
|
||||||
int64_t time;
|
int64_t time;
|
||||||
uint32_t srcloc;
|
int32_t srcloc;
|
||||||
uint64_t waitList;
|
uint64_t waitList;
|
||||||
uint16_t thread : 6;
|
uint16_t thread : 6;
|
||||||
uint16_t lockingThread : 6;
|
uint16_t lockingThread : 6;
|
||||||
|
@ -983,7 +983,7 @@ void View::AddSourceLocation( const QueueSourceLocation& srcloc )
|
|||||||
CheckString( srcloc.function );
|
CheckString( srcloc.function );
|
||||||
uint32_t color = ( srcloc.r << 16 ) | ( srcloc.g << 8 ) | srcloc.b;
|
uint32_t color = ( srcloc.r << 16 ) | ( srcloc.g << 8 ) | srcloc.b;
|
||||||
std::lock_guard<std::mutex> lock( m_lock );
|
std::lock_guard<std::mutex> lock( m_lock );
|
||||||
m_sourceLocation.emplace( srcloc.ptr, SourceLocation { srcloc.function, srcloc.file, srcloc.line, color } );
|
m_sourceLocation.emplace( srcloc.ptr, SourceLocation { srcloc.function, srcloc.file, srcloc.line, color, 0 } );
|
||||||
}
|
}
|
||||||
|
|
||||||
void View::AddSourceLocationPayload( uint64_t ptr, const char* data, size_t sz )
|
void View::AddSourceLocationPayload( uint64_t ptr, const char* data, size_t sz )
|
||||||
@ -1007,10 +1007,18 @@ void View::AddSourceLocationPayload( uint64_t ptr, const char* data, size_t sz )
|
|||||||
memcpy( source, end, ssz );
|
memcpy( source, end, ssz );
|
||||||
source[ssz] = '\0';
|
source[ssz] = '\0';
|
||||||
|
|
||||||
std::unique_lock<std::mutex> lock( m_lock );
|
auto srcloc = m_slab.Alloc<SourceLocation>();
|
||||||
|
srcloc->function = (uint64_t)func;
|
||||||
|
srcloc->file = (uint64_t)source;
|
||||||
|
srcloc->line = line;
|
||||||
|
srcloc->color = color;
|
||||||
|
srcloc->stringsAllocated = 1;
|
||||||
|
|
||||||
|
std::unique_lock<std::mutex> lock( m_lock );
|
||||||
|
pit->second->srcloc = -int32_t( m_sourceLocationPayload.size() + 1 );
|
||||||
|
m_sourceLocationPayload.push_back( srcloc );
|
||||||
lock.unlock();
|
lock.unlock();
|
||||||
m_pendingSourceLocationPayload.erase( ptr );
|
m_pendingSourceLocationPayload.erase( pit );
|
||||||
}
|
}
|
||||||
|
|
||||||
void View::AddMessageData( uint64_t ptr, const char* str, size_t sz )
|
void View::AddMessageData( uint64_t ptr, const char* str, size_t sz )
|
||||||
@ -1367,12 +1375,19 @@ const char* View::GetThreadString( uint64_t id ) const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const SourceLocation& View::GetSourceLocation( uint32_t srcloc ) const
|
const SourceLocation& View::GetSourceLocation( int32_t srcloc ) const
|
||||||
{
|
{
|
||||||
static const SourceLocation empty = {};
|
if( srcloc < 0 )
|
||||||
const auto it = m_sourceLocation.find( m_sourceLocationExpand[srcloc] );
|
{
|
||||||
if( it == m_sourceLocation.end() ) return empty;
|
return *m_sourceLocationPayload[-srcloc-1];
|
||||||
return it->second;
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
static const SourceLocation empty = {};
|
||||||
|
const auto it = m_sourceLocation.find( m_sourceLocationExpand[srcloc] );
|
||||||
|
if( it == m_sourceLocation.end() ) return empty;
|
||||||
|
return it->second;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* View::ShortenNamespace( const char* name ) const
|
const char* View::ShortenNamespace( const char* name ) const
|
||||||
@ -3041,12 +3056,26 @@ void View::DrawMessages()
|
|||||||
|
|
||||||
const char* View::GetSrcLocFunction( const SourceLocation& srcloc )
|
const char* View::GetSrcLocFunction( const SourceLocation& srcloc )
|
||||||
{
|
{
|
||||||
return GetString( srcloc.function );
|
if( srcloc.stringsAllocated )
|
||||||
|
{
|
||||||
|
return (const char*)srcloc.function;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return GetString( srcloc.function );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* View::GetSrcLocFile( const SourceLocation& srcloc )
|
const char* View::GetSrcLocFile( const SourceLocation& srcloc )
|
||||||
{
|
{
|
||||||
return GetString( srcloc.file );
|
if( srcloc.stringsAllocated )
|
||||||
|
{
|
||||||
|
return (const char*)srcloc.file;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return GetString( srcloc.file );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t View::GetZoneColor( const ZoneEvent& ev )
|
uint32_t View::GetZoneColor( const ZoneEvent& ev )
|
||||||
|
@ -176,7 +176,7 @@ private:
|
|||||||
int64_t GetZoneEnd( const ZoneEvent& ev ) const;
|
int64_t GetZoneEnd( const ZoneEvent& ev ) const;
|
||||||
const char* GetString( uint64_t ptr ) const;
|
const char* GetString( uint64_t ptr ) const;
|
||||||
const char* GetThreadString( uint64_t id ) const;
|
const char* GetThreadString( uint64_t id ) const;
|
||||||
const SourceLocation& GetSourceLocation( uint32_t srcloc ) const;
|
const SourceLocation& GetSourceLocation( int32_t srcloc ) const;
|
||||||
|
|
||||||
const char* ShortenNamespace( const char* name ) const;
|
const char* ShortenNamespace( const char* name ) const;
|
||||||
|
|
||||||
@ -230,6 +230,7 @@ private:
|
|||||||
Vector<PlotData*> m_plots;
|
Vector<PlotData*> m_plots;
|
||||||
Vector<MessageData*> m_messages;
|
Vector<MessageData*> m_messages;
|
||||||
Vector<TextData*> m_textData;
|
Vector<TextData*> m_textData;
|
||||||
|
Vector<SourceLocation*> m_sourceLocationPayload;
|
||||||
std::unordered_map<uint64_t, std::string> m_strings;
|
std::unordered_map<uint64_t, std::string> m_strings;
|
||||||
std::unordered_map<uint64_t, std::string> m_threadNames;
|
std::unordered_map<uint64_t, std::string> m_threadNames;
|
||||||
std::unordered_set<const char*, charutil::Hasher, charutil::Comparator> m_customStrings;
|
std::unordered_set<const char*, charutil::Hasher, charutil::Comparator> m_customStrings;
|
||||||
|
Loading…
Reference in New Issue
Block a user