From dcd89f894cd645e75a8a32407e7ab9eb0cb8710e Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Fri, 6 Oct 2017 16:32:32 +0200 Subject: [PATCH] Add lock marking. --- client/Tracy.hpp | 2 ++ client/TracyLock.hpp | 12 ++++++++++++ common/TracyQueue.hpp | 10 ++++++++++ 3 files changed, 24 insertions(+) diff --git a/client/Tracy.hpp b/client/Tracy.hpp index ab11722b..104e1376 100755 --- a/client/Tracy.hpp +++ b/client/Tracy.hpp @@ -13,6 +13,7 @@ #define TracyLockable( type, varname ) type varname; #define LockableBase( type ) type +#define LockMark(x) #else @@ -30,6 +31,7 @@ #define TracyLockable( type, varname ) tracy::Lockable varname { [] () -> const tracy::SourceLocation* { static const tracy::SourceLocation srcloc { #type " " #varname, __FILE__, __LINE__, 0 }; return &srcloc; }() }; #define LockableBase( type ) tracy::Lockable +#define LockMark( varname ) static const tracy::SourceLocation __tracy_lock_location_#varname { __FUNCTION__, __FILE__, (uint32_t)__LINE__, 0 }; varname.Mark( &__tracy_lock_location_#varname ); #endif diff --git a/client/TracyLock.hpp b/client/TracyLock.hpp index 56f1d67e..5cd6e143 100755 --- a/client/TracyLock.hpp +++ b/client/TracyLock.hpp @@ -92,6 +92,18 @@ public: return ret; } + void Mark( const SourceLocation* srcloc ) + { + Magic magic; + auto& token = s_token; + auto item = s_queue.enqueue_begin( token, magic ); + item->hdr.type = QueueType::LockMark; + item->lockMark.id = m_id; + item->lockMark.thread = GetThreadHandle(); + item->lockMark.srcloc = (uint64_t)srcloc; + s_queue.enqueue_finish( token, magic ); + } + private: T m_lockable; uint64_t m_id; diff --git a/common/TracyQueue.hpp b/common/TracyQueue.hpp index dc12df93..4b1a2965 100755 --- a/common/TracyQueue.hpp +++ b/common/TracyQueue.hpp @@ -21,6 +21,7 @@ enum class QueueType : uint8_t LockWait, LockObtain, LockRelease, + LockMark, NUM_TYPES }; @@ -99,6 +100,13 @@ struct QueueLockRelease uint64_t thread; }; +struct QueueLockMark +{ + uint64_t id; + uint64_t thread; + uint64_t srcloc; // ptr +}; + struct QueueHeader { union @@ -124,6 +132,7 @@ struct QueueItem QueueLockWait lockWait; QueueLockObtain lockObtain; QueueLockRelease lockRelease; + QueueLockMark lockMark; }; }; @@ -145,6 +154,7 @@ static const size_t QueueDataSize[] = { sizeof( QueueHeader ) + sizeof( QueueLockWait ), sizeof( QueueHeader ) + sizeof( QueueLockObtain ), sizeof( QueueHeader ) + sizeof( QueueLockRelease ), + sizeof( QueueHeader ) + sizeof( QueueLockMark ), }; static_assert( sizeof( QueueDataSize ) / sizeof( size_t ) == (uint8_t)QueueType::NUM_TYPES, "QueueDataSize mismatch" );