Changeset: 175f3fa63046 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/175f3fa63046
Modified Files:
cmake/monetdb-defines.cmake
gdk/gdk_system.c
monetdb_config.h.in
Branch: default
Log Message:
Debugging help: tell OS the names of our threads. The debuggers then show them.
diffs (57 lines):
diff --git a/cmake/monetdb-defines.cmake b/cmake/monetdb-defines.cmake
--- a/cmake/monetdb-defines.cmake
+++ b/cmake/monetdb-defines.cmake
@@ -121,6 +121,7 @@ function(monetdb_configure_defines)
cmake_push_check_state()
set(CMAKE_REQUIRED_LIBRARIES "${CMAKE_THREAD_LIBS_INIT}")
check_function_exists("pthread_kill" HAVE_PTHREAD_KILL)
+ check_function_exists("pthread_setname_np" HAVE_PTHREAD_SETNAME_NP)
check_function_exists("pthread_sigmask" HAVE_PTHREAD_SIGMASK)
cmake_pop_check_state()
check_symbol_exists("regcomp" "regex.h" HAVE_POSIX_REGEX)
diff --git a/gdk/gdk_system.c b/gdk/gdk_system.c
--- a/gdk/gdk_system.c
+++ b/gdk/gdk_system.c
@@ -48,6 +48,8 @@
#include <string.h> /* for strerror */
#include <unistd.h> /* for sysconf symbols */
+#include "mutils.h"
+
#ifdef LOCK_STATS
ATOMIC_TYPE GDKlockcnt = ATOMIC_VAR_INIT(0);
@@ -692,6 +694,22 @@ thread_starter(void *arg)
struct mtthread *self = (struct mtthread *) arg;
void *data = self->data;
+#ifdef HAVE_PTHREAD_H
+#ifdef HAVE_PTHREAD_SETNAME_NP
+ /* name can be at most 16 chars including \0 */
+ char *name = GDKstrndup(self->threadname, 15);
+ if (name != NULL) {
+ pthread_setname_np(pthread_self(), name);
+ GDKfree(name);
+ }
+#endif
+#else
+ wchar_t *wname = utf8towchar(self->threadname);
+ if (wname != NULL) {
+ SetThreadDescription(GetCurrentThread(), wname);
+ free(wname);
+ }
+#endif
self->data = NULL;
self->sp = THRsp();
thread_setself(self);
diff --git a/monetdb_config.h.in b/monetdb_config.h.in
--- a/monetdb_config.h.in
+++ b/monetdb_config.h.in
@@ -170,6 +170,7 @@
#cmakedefine HAVE_UNAME 1
// #cmakedefine HAVE_SEMTIMEDOP
#cmakedefine HAVE_PTHREAD_KILL 1
+#cmakedefine HAVE_PTHREAD_SETNAME_NP 1
#cmakedefine HAVE_PTHREAD_SIGMASK 1
#cmakedefine HAVE_GETOPT 1
// End Section: monetdb configure defines
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]