mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-10 10:41:50 +00:00
Add lock marking.
This commit is contained in:
parent
21c1533d8b
commit
dcd89f894c
@ -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<type> varname { [] () -> const tracy::SourceLocation* { static const tracy::SourceLocation srcloc { #type " " #varname, __FILE__, __LINE__, 0 }; return &srcloc; }() };
|
||||
#define LockableBase( type ) tracy::Lockable<type>
|
||||
#define LockMark( varname ) static const tracy::SourceLocation __tracy_lock_location_#varname { __FUNCTION__, __FILE__, (uint32_t)__LINE__, 0 }; varname.Mark( &__tracy_lock_location_#varname );
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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" );
|
||||
|
Loading…
Reference in New Issue
Block a user