Merge pull request #499 from ReplayCoding/other_thread_name

Always fallback to using native thread name...
This commit is contained in:
Bartosz Taudul 2022-11-29 22:24:56 +01:00 committed by GitHub
commit a27ecd7135
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -205,8 +205,9 @@ TRACY_API const char* GetThreadName( uint32_t id )
} }
ptr = ptr->next; ptr = ptr->next;
} }
#else #endif
# if defined _WIN32
#if defined _WIN32
# ifdef TRACY_UWP # ifdef TRACY_UWP
static auto _GetThreadDescription = &::GetThreadDescription; static auto _GetThreadDescription = &::GetThreadDescription;
# else # else
@ -227,15 +228,10 @@ TRACY_API const char* GetThreadName( uint32_t id )
} }
} }
} }
# elif defined __linux__ #elif defined __linux__
int cs, fd; int cs, fd;
char path[32]; char path[32];
# ifdef __ANDROID__ snprintf( path, sizeof( path ), "/proc/self/task/%d/comm", id );
int tid = gettid();
# else
int tid = (int) syscall( SYS_gettid );
# endif
snprintf( path, sizeof( path ), "/proc/self/task/%d/comm", tid );
sprintf( buf, "%" PRIu32, id ); sprintf( buf, "%" PRIu32, id );
# ifndef __ANDROID__ # ifndef __ANDROID__
pthread_setcancelstate( PTHREAD_CANCEL_DISABLE, &cs ); pthread_setcancelstate( PTHREAD_CANCEL_DISABLE, &cs );
@ -256,8 +252,8 @@ TRACY_API const char* GetThreadName( uint32_t id )
pthread_setcancelstate( cs, 0 ); pthread_setcancelstate( cs, 0 );
# endif # endif
return buf; return buf;
# endif
#endif #endif
sprintf( buf, "%" PRIu32, id ); sprintf( buf, "%" PRIu32, id );
return buf; return buf;
} }