mirror of
https://github.com/wolfpld/tracy
synced 2025-04-29 04:23:51 +00:00
Better thread name retrieval.
This commit is contained in:
parent
3ea18dcbfd
commit
340bf80435
@ -27,7 +27,25 @@ namespace tracy
|
||||
|
||||
static inline const char* GetThreadName( uint64_t id )
|
||||
{
|
||||
static char buf[64];
|
||||
static char buf[256];
|
||||
#ifdef _MSC_VER
|
||||
# ifdef NTDDI_WIN10_RS2
|
||||
auto hnd = OpenThread( THREAD_QUERY_LIMITED_INFORMATION, FALSE, id );
|
||||
PWSTR tmp;
|
||||
GetThreadDescription( hnd, &tmp );
|
||||
auto ret = wcstombs( buf, tmp, 256 );
|
||||
CloseHandle( hnd );
|
||||
if( ret != 0 )
|
||||
{
|
||||
return buf;
|
||||
}
|
||||
# endif
|
||||
#else
|
||||
if( pthread_getname_np( (pthread_t)id, buf, 256 ) == 0 )
|
||||
{
|
||||
return buf;
|
||||
}
|
||||
#endif
|
||||
sprintf( buf, "%" PRIu64, id );
|
||||
return buf;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user