Store RingBuffer identifier.

This commit is contained in:
Bartosz Taudul 2021-05-19 01:25:13 +02:00 committed by Bartosz Taudul
parent 07778badcc
commit b7d52d2eab
No known key found for this signature in database
GPG Key ID: B7FE2008B7575DF3
2 changed files with 10 additions and 2 deletions

View File

@ -5,8 +5,9 @@ template<size_t Size>
class RingBuffer
{
public:
RingBuffer( int fd )
RingBuffer( int fd, int id )
: m_fd( fd )
, m_id( id )
{
const auto pageSize = uint32_t( getpagesize() );
assert( Size >= pageSize );
@ -49,6 +50,7 @@ public:
}
bool IsValid() const { return m_metadata != nullptr; }
int GetId() const { return m_id; }
void Enable()
{
@ -111,6 +113,7 @@ private:
size_t m_mapSize;
int m_fd;
int m_id;
};
}

View File

@ -675,6 +675,11 @@ static int perf_event_open( struct perf_event_attr* hw_event, pid_t pid, int cpu
return syscall( __NR_perf_event_open, hw_event, pid, cpu, group_fd, flags );
}
enum TraceEventId
{
EventCallstack
};
static void SetupSampling( int64_t& samplingPeriod )
{
#ifndef CLOCK_MONOTONIC_RAW
@ -715,7 +720,7 @@ static void SetupSampling( int64_t& samplingPeriod )
tracy_free( s_ring );
return;
}
new( s_ring+i ) RingBuffer<RingBufSize>( fd );
new( s_ring+i ) RingBuffer<RingBufSize>( fd, EventCallstack );
}
s_threadSampling = (Thread*)tracy_malloc( sizeof( Thread ) );