Define internal function mythreadname() -- revised
This new function returns the name of the calling thread; works for both cygthreads and pthreads. All calls to cygthread::name(/*void*/) replaced by calls to mythreadname(/*void*/).
This commit is contained in:
parent
c17b0f0082
commit
29af5b27cf
@ -200,7 +200,7 @@ cygwin_exception::dump_exception ()
|
|||||||
small_printf ("r14=%016X r15=%016X\r\n", ctx->R14, ctx->R15);
|
small_printf ("r14=%016X r15=%016X\r\n", ctx->R14, ctx->R15);
|
||||||
small_printf ("rbp=%016X rsp=%016X\r\n", ctx->Rbp, ctx->Rsp);
|
small_printf ("rbp=%016X rsp=%016X\r\n", ctx->Rbp, ctx->Rsp);
|
||||||
small_printf ("program=%W, pid %u, thread %s\r\n",
|
small_printf ("program=%W, pid %u, thread %s\r\n",
|
||||||
myself->progname, myself->pid, cygthread::name ());
|
myself->progname, myself->pid, mythreadname ());
|
||||||
#else
|
#else
|
||||||
if (exception_name)
|
if (exception_name)
|
||||||
small_printf ("Exception: %s at eip=%08x\r\n", exception_name, ctx->Eip);
|
small_printf ("Exception: %s at eip=%08x\r\n", exception_name, ctx->Eip);
|
||||||
@ -210,7 +210,7 @@ cygwin_exception::dump_exception ()
|
|||||||
ctx->Eax, ctx->Ebx, ctx->Ecx, ctx->Edx, ctx->Esi, ctx->Edi);
|
ctx->Eax, ctx->Ebx, ctx->Ecx, ctx->Edx, ctx->Esi, ctx->Edi);
|
||||||
small_printf ("ebp=%08x esp=%08x program=%W, pid %u, thread %s\r\n",
|
small_printf ("ebp=%08x esp=%08x program=%W, pid %u, thread %s\r\n",
|
||||||
ctx->Ebp, ctx->Esp, myself->progname, myself->pid,
|
ctx->Ebp, ctx->Esp, myself->progname, myself->pid,
|
||||||
cygthread::name ());
|
mythreadname ());
|
||||||
#endif
|
#endif
|
||||||
small_printf ("cs=%04x ds=%04x es=%04x fs=%04x gs=%04x ss=%04x\r\n",
|
small_printf ("cs=%04x ds=%04x es=%04x fs=%04x gs=%04x ss=%04x\r\n",
|
||||||
ctx->SegCs, ctx->SegDs, ctx->SegEs, ctx->SegFs,
|
ctx->SegCs, ctx->SegDs, ctx->SegEs, ctx->SegFs,
|
||||||
|
@ -106,7 +106,7 @@ fhandler_pty_common::__acquire_output_mutex (const char *fn, int ln,
|
|||||||
#else
|
#else
|
||||||
ostack[osi].fn = fn;
|
ostack[osi].fn = fn;
|
||||||
ostack[osi].ln = ln;
|
ostack[osi].ln = ln;
|
||||||
ostack[osi].tname = cygthread::name ();
|
ostack[osi].tname = mythreadname ();
|
||||||
termios_printf ("acquired for %s:%d, osi %d", fn, ln, osi);
|
termios_printf ("acquired for %s:%d, osi %d", fn, ln, osi);
|
||||||
osi++;
|
osi++;
|
||||||
#endif
|
#endif
|
||||||
|
@ -138,7 +138,7 @@ strace::vsprntf (char *buf, const char *func, const char *infmt, va_list ap)
|
|||||||
char fmt[80];
|
char fmt[80];
|
||||||
static NO_COPY bool nonewline = false;
|
static NO_COPY bool nonewline = false;
|
||||||
DWORD err = GetLastError ();
|
DWORD err = GetLastError ();
|
||||||
const char *tn = cygthread::name ();
|
const char *tn = mythreadname ();
|
||||||
|
|
||||||
int microsec = microseconds ();
|
int microsec = microseconds ();
|
||||||
lmicrosec = microsec;
|
lmicrosec = microsec;
|
||||||
|
@ -2682,6 +2682,20 @@ pthread_setname_np (pthread_t thread, const char *name)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Returns running thread's name; works for both cygthreads and pthreads */
|
||||||
|
char *
|
||||||
|
mythreadname (void)
|
||||||
|
{
|
||||||
|
char *result = (char *) cygthread::name ();
|
||||||
|
|
||||||
|
if (result == _my_tls.locals.unknown_thread_name)
|
||||||
|
{
|
||||||
|
result[0] = '\0';
|
||||||
|
pthread_getname_np (pthread_self (), result, (size_t) THRNAMELEN);
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
#undef THRNAMELEN
|
#undef THRNAMELEN
|
||||||
|
|
||||||
/* provided for source level compatability.
|
/* provided for source level compatability.
|
||||||
|
@ -17,6 +17,9 @@ details. */
|
|||||||
/* resource.cc */
|
/* resource.cc */
|
||||||
extern size_t get_rlimit_stack (void);
|
extern size_t get_rlimit_stack (void);
|
||||||
|
|
||||||
|
/* thread.cc */
|
||||||
|
char *mythreadname (void);
|
||||||
|
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include "security.h"
|
#include "security.h"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user