mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-10 02:31:48 +00:00
Store zone source location.
This commit is contained in:
parent
7446e27e60
commit
5065743bf0
@ -10,6 +10,7 @@ struct Event
|
||||
{
|
||||
int64_t start;
|
||||
int64_t end;
|
||||
uint32_t srcloc;
|
||||
|
||||
Vector<Event*> child;
|
||||
};
|
||||
|
37
server/TracySourceLocation.hpp
Executable file
37
server/TracySourceLocation.hpp
Executable file
@ -0,0 +1,37 @@
|
||||
#ifndef __TRACYSOURCELOCATION_HPP__
|
||||
#define __TRACYSOURCELOCATION_HPP__
|
||||
|
||||
#include <functional>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
|
||||
namespace tracy
|
||||
{
|
||||
|
||||
struct SourceLocation
|
||||
{
|
||||
uint64_t filename;
|
||||
uint64_t function;
|
||||
uint32_t line;
|
||||
|
||||
struct Hasher
|
||||
{
|
||||
size_t operator()( const SourceLocation& v ) const
|
||||
{
|
||||
const static std::hash<uint64_t> hash;
|
||||
return hash( v.filename ) ^ hash( v.function ) ^ hash( v.line );
|
||||
}
|
||||
};
|
||||
|
||||
struct Comparator
|
||||
{
|
||||
bool operator()( const SourceLocation& lhs, const SourceLocation& rhs ) const
|
||||
{
|
||||
return memcmp( &lhs, &rhs, sizeof( SourceLocation ) ) == 0;
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
@ -209,10 +209,27 @@ void View::ProcessZoneBegin( uint64_t id, const QueueZoneBegin& ev )
|
||||
{
|
||||
auto it = m_pendingEndZone.find( id );
|
||||
auto zone = m_slab.Alloc<Event>();
|
||||
|
||||
CheckString( ev.filename );
|
||||
CheckString( ev.function );
|
||||
zone->start = ev.time;
|
||||
|
||||
SourceLocation srcloc { ev.filename, ev.function, ev.line };
|
||||
auto lit = m_locationRef.find( srcloc );
|
||||
|
||||
std::unique_lock<std::mutex> lock( m_lock );
|
||||
if( lit == m_locationRef.end() )
|
||||
{
|
||||
const auto ref = uint32_t( m_srcFile.size() );
|
||||
zone->srcloc = ref;
|
||||
m_locationRef.emplace( srcloc, ref );
|
||||
m_srcFile.push_back( srcloc );
|
||||
}
|
||||
else
|
||||
{
|
||||
zone->srcloc = lit->second;
|
||||
}
|
||||
|
||||
if( it == m_pendingEndZone.end() )
|
||||
{
|
||||
zone->end = -1;
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include "../common/TracyQueue.hpp"
|
||||
#include "TracyEvent.hpp"
|
||||
#include "TracySlab.hpp"
|
||||
#include "TracySourceLocation.hpp"
|
||||
#include "TracyVector.hpp"
|
||||
|
||||
namespace tracy
|
||||
@ -71,6 +72,7 @@ private:
|
||||
std::mutex m_lock;
|
||||
Vector<Event*> m_timeline;
|
||||
Vector<uint64_t> m_frames;
|
||||
Vector<SourceLocation> m_srcFile;
|
||||
std::unordered_map<uint64_t, std::string> m_strings;
|
||||
|
||||
std::mutex m_mbpslock;
|
||||
@ -80,6 +82,7 @@ private:
|
||||
std::unordered_map<uint64_t, QueueZoneEnd> m_pendingEndZone;
|
||||
std::unordered_map<uint64_t, Event*> m_openZones;
|
||||
std::unordered_set<uint64_t> m_pendingStrings;
|
||||
std::unordered_map<SourceLocation, uint32_t, SourceLocation::Hasher, SourceLocation::Comparator> m_locationRef;
|
||||
|
||||
Slab<EventSize*1024*1024> m_slab;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user