1
0
mirror of https://github.com/wolfpld/tracy.git synced 2025-03-20 07:40:02 +08:00

Also retrieve external thread names.

This commit is contained in:
Bartosz Taudul
2019-08-16 19:49:16 +02:00
parent 134a8c5d2a
commit e975c4d7bf
6 changed files with 62 additions and 14 deletions
+21
View File
@@ -158,9 +158,24 @@ void SysTraceWorker( void* ptr )
void SysTraceSendExternalName( uint64_t thread )
{
bool threadSent = false;
const auto hnd = OpenThread( THREAD_QUERY_LIMITED_INFORMATION, FALSE, thread );
if( hnd != INVALID_HANDLE_VALUE )
{
#if defined NTDDI_WIN10_RS2 && NTDDI_VERSION >= NTDDI_WIN10_RS2
PWSTR tmp;
GetThreadDescription( hnd, &tmp );
char buf[256];
if( tmp )
{
auto ret = wcstombs( buf, tmp, 256 );
if( ret != 0 )
{
GetProfiler().SendString( thread, buf, QueueType::ExternalThreadName );
threadSent = true;
}
}
#endif
const auto pid = GetProcessIdOfThread( hnd );
CloseHandle( hnd );
if( pid != 0 )
@@ -173,6 +188,10 @@ void SysTraceSendExternalName( uint64_t thread )
CloseHandle( phnd );
if( sz != 0 )
{
if( !threadSent )
{
GetProfiler().SendString( thread, "???", QueueType::ExternalThreadName );
}
auto ptr = buf + sz - 1;
while( ptr > buf && *ptr != '\\' ) ptr--;
if( *ptr == '\\' ) ptr++;
@@ -183,6 +202,7 @@ void SysTraceSendExternalName( uint64_t thread )
}
}
GetProfiler().SendString( thread, "???", QueueType::ExternalThreadName );
GetProfiler().SendString( thread, "???", QueueType::ExternalName );
}
@@ -374,6 +394,7 @@ void SysTraceWorker( void* ptr )
void SysTraceSendExternalName( uint64_t thread )
{
// TODO
GetProfiler().SendString( thread, "???", QueueType::ExternalThreadName );
GetProfiler().SendString( thread, "???", QueueType::ExternalName );
}