mirror of
https://github.com/wolfpld/tracy
synced 2025-04-30 04:43:53 +00:00
Always collect thread names.
This fixes an issue when a thread was destroyed before its name could be retrieved.
This commit is contained in:
parent
5e199d1ab3
commit
71b54dd48a
@ -874,9 +874,7 @@ struct ProfilerData
|
|||||||
Profiler profiler;
|
Profiler profiler;
|
||||||
std::atomic<uint32_t> lockCounter { 0 };
|
std::atomic<uint32_t> lockCounter { 0 };
|
||||||
std::atomic<uint8_t> gpuCtxCounter { 0 };
|
std::atomic<uint8_t> gpuCtxCounter { 0 };
|
||||||
# ifdef TRACY_COLLECT_THREAD_NAMES
|
|
||||||
std::atomic<ThreadNameData*> threadNameData { nullptr };
|
std::atomic<ThreadNameData*> threadNameData { nullptr };
|
||||||
#endif
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ProducerWrapper
|
struct ProducerWrapper
|
||||||
@ -924,10 +922,7 @@ TRACY_API std::atomic<uint32_t>& GetLockCounter() { return GetProfilerData().loc
|
|||||||
TRACY_API std::atomic<uint8_t>& GetGpuCtxCounter() { return GetProfilerData().gpuCtxCounter; }
|
TRACY_API std::atomic<uint8_t>& GetGpuCtxCounter() { return GetProfilerData().gpuCtxCounter; }
|
||||||
TRACY_API GpuCtxWrapper& GetGpuCtx() { return GetProfilerThreadData().gpuCtx; }
|
TRACY_API GpuCtxWrapper& GetGpuCtx() { return GetProfilerThreadData().gpuCtx; }
|
||||||
TRACY_API uint64_t GetThreadHandle() { return detail::GetThreadHandleImpl(); }
|
TRACY_API uint64_t GetThreadHandle() { return detail::GetThreadHandleImpl(); }
|
||||||
|
|
||||||
# ifdef TRACY_COLLECT_THREAD_NAMES
|
|
||||||
TRACY_API std::atomic<ThreadNameData*>& GetThreadNameData() { return GetProfilerData().threadNameData; }
|
TRACY_API std::atomic<ThreadNameData*>& GetThreadNameData() { return GetProfilerData().threadNameData; }
|
||||||
# endif
|
|
||||||
|
|
||||||
# ifdef TRACY_ON_DEMAND
|
# ifdef TRACY_ON_DEMAND
|
||||||
TRACY_API LuaZoneState& GetLuaZoneState() { return GetProfilerThreadData().luaZoneState; }
|
TRACY_API LuaZoneState& GetLuaZoneState() { return GetProfilerThreadData().luaZoneState; }
|
||||||
@ -965,11 +960,9 @@ std::atomic<uint8_t> init_order(104) s_gpuCtxCounter( 0 );
|
|||||||
|
|
||||||
thread_local GpuCtxWrapper init_order(104) s_gpuCtx { nullptr };
|
thread_local GpuCtxWrapper init_order(104) s_gpuCtx { nullptr };
|
||||||
|
|
||||||
# ifdef TRACY_COLLECT_THREAD_NAMES
|
|
||||||
struct ThreadNameData;
|
struct ThreadNameData;
|
||||||
static std::atomic<ThreadNameData*> init_order(104) s_threadNameDataInstance( nullptr );
|
static std::atomic<ThreadNameData*> init_order(104) s_threadNameDataInstance( nullptr );
|
||||||
std::atomic<ThreadNameData*>& s_threadNameData = s_threadNameDataInstance;
|
std::atomic<ThreadNameData*>& s_threadNameData = s_threadNameDataInstance;
|
||||||
# endif
|
|
||||||
|
|
||||||
# ifdef TRACY_ON_DEMAND
|
# ifdef TRACY_ON_DEMAND
|
||||||
thread_local LuaZoneState init_order(104) s_luaZoneState { 0, false };
|
thread_local LuaZoneState init_order(104) s_luaZoneState { 0, false };
|
||||||
@ -991,9 +984,7 @@ TRACY_API uint64_t GetThreadHandle() { return detail::GetThreadHandleImpl(); }
|
|||||||
TRACY_API uint64_t GetThreadHandle() { return s_threadHandle.val; }
|
TRACY_API uint64_t GetThreadHandle() { return s_threadHandle.val; }
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
# ifdef TRACY_COLLECT_THREAD_NAMES
|
|
||||||
TRACY_API std::atomic<ThreadNameData*>& GetThreadNameData() { return s_threadNameData; }
|
TRACY_API std::atomic<ThreadNameData*>& GetThreadNameData() { return s_threadNameData; }
|
||||||
# endif
|
|
||||||
|
|
||||||
# ifdef TRACY_ON_DEMAND
|
# ifdef TRACY_ON_DEMAND
|
||||||
TRACY_API LuaZoneState& GetLuaZoneState() { return s_luaZoneState; }
|
TRACY_API LuaZoneState& GetLuaZoneState() { return s_luaZoneState; }
|
||||||
|
@ -30,7 +30,7 @@
|
|||||||
|
|
||||||
#include "TracySystem.hpp"
|
#include "TracySystem.hpp"
|
||||||
|
|
||||||
#ifdef TRACY_COLLECT_THREAD_NAMES
|
#ifdef TRACY_ENABLE
|
||||||
# include <atomic>
|
# include <atomic>
|
||||||
# include "TracyAlloc.hpp"
|
# include "TracyAlloc.hpp"
|
||||||
#endif
|
#endif
|
||||||
@ -38,7 +38,7 @@
|
|||||||
namespace tracy
|
namespace tracy
|
||||||
{
|
{
|
||||||
|
|
||||||
#ifdef TRACY_COLLECT_THREAD_NAMES
|
#ifdef TRACY_ENABLE
|
||||||
struct ThreadNameData
|
struct ThreadNameData
|
||||||
{
|
{
|
||||||
uint64_t id;
|
uint64_t id;
|
||||||
@ -99,7 +99,7 @@ void SetThreadName( const char* name )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#ifdef TRACY_COLLECT_THREAD_NAMES
|
#ifdef TRACY_ENABLE
|
||||||
{
|
{
|
||||||
InitRPMallocThread();
|
InitRPMallocThread();
|
||||||
const auto sz = strlen( name );
|
const auto sz = strlen( name );
|
||||||
@ -118,7 +118,7 @@ void SetThreadName( const char* name )
|
|||||||
const char* GetThreadName( uint64_t id )
|
const char* GetThreadName( uint64_t id )
|
||||||
{
|
{
|
||||||
static char buf[256];
|
static char buf[256];
|
||||||
#ifdef TRACY_COLLECT_THREAD_NAMES
|
#ifdef TRACY_ENABLE
|
||||||
auto ptr = GetThreadNameData().load( std::memory_order_relaxed );
|
auto ptr = GetThreadNameData().load( std::memory_order_relaxed );
|
||||||
while( ptr )
|
while( ptr )
|
||||||
{
|
{
|
||||||
|
@ -1,12 +1,6 @@
|
|||||||
#ifndef __TRACYSYSTEM_HPP__
|
#ifndef __TRACYSYSTEM_HPP__
|
||||||
#define __TRACYSYSTEM_HPP__
|
#define __TRACYSYSTEM_HPP__
|
||||||
|
|
||||||
#ifdef TRACY_ENABLE
|
|
||||||
# if defined __ANDROID__ || defined __CYGWIN__ || defined __APPLE__ || defined _GNU_SOURCE || ( defined _WIN32 && ( !defined NTDDI_WIN10_RS2 || NTDDI_VERSION < NTDDI_WIN10_RS2 ) )
|
|
||||||
# define TRACY_COLLECT_THREAD_NAMES
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined _WIN32 || defined __CYGWIN__
|
#if defined _WIN32 || defined __CYGWIN__
|
||||||
# ifndef _WINDOWS_
|
# ifndef _WINDOWS_
|
||||||
extern "C" __declspec(dllimport) unsigned long __stdcall GetCurrentThreadId(void);
|
extern "C" __declspec(dllimport) unsigned long __stdcall GetCurrentThreadId(void);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user