Send thread names to debugger
GDB since commit 24cdb46e [1] can report and use these names. Add utility function SetThreadName(), which sends a thread name to the debugger. Use that: - to set the default thread name for main thread and newly created pthreads. - in pthread_setname_np() for user thread names. - for helper thread names in cygthread::create() - for helper threads which are created directly with CreateThread. Note that there can still be anonymous threads, created by system or injected DLLs. [1] https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=24cdb46e9f0a694b4fbc11085e094857f08c0419
This commit is contained in:
@@ -1992,6 +1992,9 @@ pthread::thread_init_wrapper (void *arg)
|
||||
_my_tls.sigmask = thread->parent_sigmask;
|
||||
thread->set_tls_self_pointer ();
|
||||
|
||||
// Give thread default name
|
||||
SetThreadName (GetCurrentThreadId (), program_invocation_short_name);
|
||||
|
||||
thread->mutex.lock ();
|
||||
|
||||
// if thread is detached force cleanup on exit
|
||||
@@ -2631,6 +2634,8 @@ pthread_setname_np (pthread_t thread, const char *name)
|
||||
oldname = thread->attr.name;
|
||||
thread->attr.name = cp;
|
||||
|
||||
SetThreadName (GetThreadId (thread->win32_obj_id), thread->attr.name);
|
||||
|
||||
if (oldname)
|
||||
free (oldname);
|
||||
|
||||
|
Reference in New Issue
Block a user