Move liblttng-ust-pthread-wrapper to 'src/lib/'
authorMichael Jeanson <mjeanson@efficios.com>
Wed, 14 Apr 2021 18:55:30 +0000 (14:55 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Fri, 16 Apr 2021 15:34:03 +0000 (11:34 -0400)
Change-Id: Id38841b2338de290f7dc9ec68c10411031fc3d58
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
.gitignore
configure.ac
src/lib/Makefile.am
src/lib/lttng-ust-libc-wrapper/Makefile.am
src/lib/lttng-ust-libc-wrapper/lttng-ust-pthread.c [deleted file]
src/lib/lttng-ust-libc-wrapper/ust_pthread.h [deleted file]
src/lib/lttng-ust-pthread-wrapper/Makefile.am [new file with mode: 0644]
src/lib/lttng-ust-pthread-wrapper/lttng-ust-pthread.c [new file with mode: 0644]
src/lib/lttng-ust-pthread-wrapper/ust_pthread.h [new file with mode: 0644]

index f409ce705c7353cd59f1a5e121a6888ec0aea693..326795a713efae29afffce7d54ce6420d96c1311 100644 (file)
@@ -143,6 +143,7 @@ cscope.*
 /src/lib/lttng-ust-java-agent/jni/log4j/Makefile
 /src/lib/lttng-ust-java/Makefile
 /src/lib/lttng-ust-libc-wrapper/Makefile
+/src/lib/lttng-ust-pthread-wrapper/Makefile
 /src/lib/lttng-ust-tracepoint/Makefile
 /src/lib/lttng-ust-python-agent/Makefile
 /src/lib/Makefile
index be707b0f7a1f3400425ccbc13ffece57b5b28a89..54b00dcc2343f2beacfe365d196ab23836cda15c 100644 (file)
@@ -537,6 +537,7 @@ AC_CONFIG_FILES([
   src/lib/lttng-ust-java-agent/Makefile
   src/lib/lttng-ust-java/Makefile
   src/lib/lttng-ust-libc-wrapper/Makefile
+  src/lib/lttng-ust-pthread-wrapper/Makefile
   src/lib/lttng-ust-tracepoint/Makefile
   src/lib/lttng-ust/Makefile
   src/lib/lttng-ust-python-agent/Makefile
index 49fbd75db06e43287426be5d1a064c2d1f70747a..fbd123585ad1655c2916d1aeae00a5e4dbc8f0c6 100644 (file)
@@ -8,7 +8,8 @@ SUBDIRS = \
        lttng-ust-fd \
        lttng-ust-fork \
        lttng-ust-cyg-profile \
-       lttng-ust-libc-wrapper
+       lttng-ust-libc-wrapper \
+       lttng-ust-pthread-wrapper
 
 if ENABLE_UST_DL
 SUBDIRS += lttng-ust-dl
index f3fcee6953600645e1f1697622bd4af6cdde9c7a..0507e4df0d0c47492b52464484f4cadce0ff33c8 100644 (file)
@@ -2,8 +2,7 @@
 
 AM_CFLAGS += -I$(srcdir) -fno-strict-aliasing
 
-lib_LTLIBRARIES = liblttng-ust-libc-wrapper.la \
-  liblttng-ust-pthread-wrapper.la
+lib_LTLIBRARIES = liblttng-ust-libc-wrapper.la
 
 liblttng_ust_libc_wrapper_la_SOURCES = \
        lttng-ust-malloc.c \
@@ -15,15 +14,5 @@ liblttng_ust_libc_wrapper_la_LIBADD = \
 
 liblttng_ust_libc_wrapper_la_LDFLAGS = -version-info $(LTTNG_UST_LIBRARY_VERSION)
 
-liblttng_ust_pthread_wrapper_la_SOURCES = \
-       lttng-ust-pthread.c \
-       ust_pthread.h
-
-liblttng_ust_pthread_wrapper_la_LIBADD = \
-       $(top_builddir)/src/lib/lttng-ust/liblttng-ust.la \
-       $(DL_LIBS)
-
-liblttng_ust_pthread_wrapper_la_LDFLAGS = -version-info $(LTTNG_UST_LIBRARY_VERSION)
-
 dist_noinst_SCRIPTS = run
 EXTRA_DIST = README
diff --git a/src/lib/lttng-ust-libc-wrapper/lttng-ust-pthread.c b/src/lib/lttng-ust-libc-wrapper/lttng-ust-pthread.c
deleted file mode 100644 (file)
index c6633fe..0000000
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- * SPDX-License-Identifier: LGPL-2.1-or-later
- *
- * Copyright (C) 2013  Mentor Graphics
- */
-
-/*
- * Do _not_ define _LGPL_SOURCE because we don't want to create a
- * circular dependency loop between this malloc wrapper, liburcu and
- * libc.
- */
-
-/* Has to be included first to override dlfcn.h */
-#include <common/compat/dlfcn.h>
-
-#include "common/macros.h"
-#include <pthread.h>
-
-#define TRACEPOINT_DEFINE
-#define TRACEPOINT_CREATE_PROBES
-#define TP_IP_PARAM ip
-#include "ust_pthread.h"
-
-static __thread int thread_in_trace;
-
-int pthread_mutex_lock(pthread_mutex_t *mutex)
-{
-       static int (*mutex_lock)(pthread_mutex_t *);
-       int retval;
-
-       if (!mutex_lock) {
-               mutex_lock = dlsym(RTLD_NEXT, "pthread_mutex_lock");
-               if (!mutex_lock) {
-                       if (thread_in_trace) {
-                               abort();
-                       }
-                       fprintf(stderr, "unable to initialize pthread wrapper library.\n");
-                       return EINVAL;
-               }
-       }
-       if (thread_in_trace) {
-               return mutex_lock(mutex);
-       }
-
-       thread_in_trace = 1;
-       tracepoint(lttng_ust_pthread, pthread_mutex_lock_req, mutex,
-               LTTNG_UST_CALLER_IP());
-       retval = mutex_lock(mutex);
-       tracepoint(lttng_ust_pthread, pthread_mutex_lock_acq, mutex,
-               retval, LTTNG_UST_CALLER_IP());
-       thread_in_trace = 0;
-       return retval;
-}
-
-int pthread_mutex_trylock(pthread_mutex_t *mutex)
-{
-       static int (*mutex_trylock)(pthread_mutex_t *);
-       int retval;
-
-       if (!mutex_trylock) {
-               mutex_trylock = dlsym(RTLD_NEXT, "pthread_mutex_trylock");
-               if (!mutex_trylock) {
-                       if (thread_in_trace) {
-                               abort();
-                       }
-                       fprintf(stderr, "unable to initialize pthread wrapper library.\n");
-                       return EINVAL;
-               }
-       }
-       if (thread_in_trace) {
-               return mutex_trylock(mutex);
-       }
-
-       thread_in_trace = 1;
-       retval = mutex_trylock(mutex);
-       tracepoint(lttng_ust_pthread, pthread_mutex_trylock, mutex,
-               retval, LTTNG_UST_CALLER_IP());
-       thread_in_trace = 0;
-       return retval;
-}
-
-int pthread_mutex_unlock(pthread_mutex_t *mutex)
-{
-       static int (*mutex_unlock)(pthread_mutex_t *);
-       int retval;
-
-       if (!mutex_unlock) {
-               mutex_unlock = dlsym(RTLD_NEXT, "pthread_mutex_unlock");
-               if (!mutex_unlock) {
-                       if (thread_in_trace) {
-                               abort();
-                       }
-                       fprintf(stderr, "unable to initialize pthread wrapper library.\n");
-                       return EINVAL;
-               }
-       }
-       if (thread_in_trace) {
-               return mutex_unlock(mutex);
-       }
-
-       thread_in_trace = 1;
-       retval = mutex_unlock(mutex);
-       tracepoint(lttng_ust_pthread, pthread_mutex_unlock, mutex,
-               retval, LTTNG_UST_CALLER_IP());
-       thread_in_trace = 0;
-       return retval;
-}
diff --git a/src/lib/lttng-ust-libc-wrapper/ust_pthread.h b/src/lib/lttng-ust-libc-wrapper/ust_pthread.h
deleted file mode 100644 (file)
index 4fdc11a..0000000
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * SPDX-License-Identifier: MIT
- *
- * Copyright (C) 2013  Mentor Graphics
- */
-
-#undef TRACEPOINT_PROVIDER
-#define TRACEPOINT_PROVIDER lttng_ust_pthread
-
-#if !defined(_TRACEPOINT_UST_PTHREAD_H) || defined(TRACEPOINT_HEADER_MULTI_READ)
-#define _TRACEPOINT_UST_PTHREAD_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include <lttng/tracepoint.h>
-
-TRACEPOINT_EVENT(lttng_ust_pthread, pthread_mutex_lock_req,
-       TP_ARGS(pthread_mutex_t *, mutex, void *, ip),
-       TP_FIELDS(
-               ctf_integer_hex(void *, mutex, mutex)
-               ctf_unused(ip)
-       )
-)
-
-TRACEPOINT_EVENT(lttng_ust_pthread, pthread_mutex_lock_acq,
-       TP_ARGS(pthread_mutex_t *, mutex, int, status, void *, ip),
-       TP_FIELDS(
-               ctf_integer_hex(void *, mutex, mutex)
-               ctf_integer(int, status, status)
-               ctf_unused(ip)
-       )
-)
-
-TRACEPOINT_EVENT(lttng_ust_pthread, pthread_mutex_trylock,
-       TP_ARGS(pthread_mutex_t *, mutex, int, status, void *, ip),
-       TP_FIELDS(
-               ctf_integer_hex(void *, mutex, mutex)
-               ctf_integer(int, status, status)
-               ctf_unused(ip)
-       )
-)
-
-TRACEPOINT_EVENT(lttng_ust_pthread, pthread_mutex_unlock,
-       TP_ARGS(pthread_mutex_t *, mutex, int, status, void *, ip),
-       TP_FIELDS(
-               ctf_integer_hex(void *, mutex, mutex)
-               ctf_integer(int, status, status)
-               ctf_unused(ip)
-       )
-)
-
-#endif /* _TRACEPOINT_UST_PTHREAD_H */
-
-#undef TRACEPOINT_INCLUDE
-#define TRACEPOINT_INCLUDE "./ust_pthread.h"
-
-/* This part must be outside ifdef protection */
-#include <lttng/tracepoint-event.h>
-
-#ifdef __cplusplus
-}
-#endif
diff --git a/src/lib/lttng-ust-pthread-wrapper/Makefile.am b/src/lib/lttng-ust-pthread-wrapper/Makefile.am
new file mode 100644 (file)
index 0000000..3edb72a
--- /dev/null
@@ -0,0 +1,15 @@
+# SPDX-License-Identifier: LGPL-2.1-only
+
+AM_CFLAGS += -I$(srcdir) -fno-strict-aliasing
+
+lib_LTLIBRARIES = liblttng-ust-pthread-wrapper.la
+
+liblttng_ust_pthread_wrapper_la_SOURCES = \
+       lttng-ust-pthread.c \
+       ust_pthread.h
+
+liblttng_ust_pthread_wrapper_la_LIBADD = \
+       $(top_builddir)/src/lib/lttng-ust/liblttng-ust.la \
+       $(DL_LIBS)
+
+liblttng_ust_pthread_wrapper_la_LDFLAGS = -version-info $(LTTNG_UST_LIBRARY_VERSION)
diff --git a/src/lib/lttng-ust-pthread-wrapper/lttng-ust-pthread.c b/src/lib/lttng-ust-pthread-wrapper/lttng-ust-pthread.c
new file mode 100644 (file)
index 0000000..c6633fe
--- /dev/null
@@ -0,0 +1,107 @@
+/*
+ * SPDX-License-Identifier: LGPL-2.1-or-later
+ *
+ * Copyright (C) 2013  Mentor Graphics
+ */
+
+/*
+ * Do _not_ define _LGPL_SOURCE because we don't want to create a
+ * circular dependency loop between this malloc wrapper, liburcu and
+ * libc.
+ */
+
+/* Has to be included first to override dlfcn.h */
+#include <common/compat/dlfcn.h>
+
+#include "common/macros.h"
+#include <pthread.h>
+
+#define TRACEPOINT_DEFINE
+#define TRACEPOINT_CREATE_PROBES
+#define TP_IP_PARAM ip
+#include "ust_pthread.h"
+
+static __thread int thread_in_trace;
+
+int pthread_mutex_lock(pthread_mutex_t *mutex)
+{
+       static int (*mutex_lock)(pthread_mutex_t *);
+       int retval;
+
+       if (!mutex_lock) {
+               mutex_lock = dlsym(RTLD_NEXT, "pthread_mutex_lock");
+               if (!mutex_lock) {
+                       if (thread_in_trace) {
+                               abort();
+                       }
+                       fprintf(stderr, "unable to initialize pthread wrapper library.\n");
+                       return EINVAL;
+               }
+       }
+       if (thread_in_trace) {
+               return mutex_lock(mutex);
+       }
+
+       thread_in_trace = 1;
+       tracepoint(lttng_ust_pthread, pthread_mutex_lock_req, mutex,
+               LTTNG_UST_CALLER_IP());
+       retval = mutex_lock(mutex);
+       tracepoint(lttng_ust_pthread, pthread_mutex_lock_acq, mutex,
+               retval, LTTNG_UST_CALLER_IP());
+       thread_in_trace = 0;
+       return retval;
+}
+
+int pthread_mutex_trylock(pthread_mutex_t *mutex)
+{
+       static int (*mutex_trylock)(pthread_mutex_t *);
+       int retval;
+
+       if (!mutex_trylock) {
+               mutex_trylock = dlsym(RTLD_NEXT, "pthread_mutex_trylock");
+               if (!mutex_trylock) {
+                       if (thread_in_trace) {
+                               abort();
+                       }
+                       fprintf(stderr, "unable to initialize pthread wrapper library.\n");
+                       return EINVAL;
+               }
+       }
+       if (thread_in_trace) {
+               return mutex_trylock(mutex);
+       }
+
+       thread_in_trace = 1;
+       retval = mutex_trylock(mutex);
+       tracepoint(lttng_ust_pthread, pthread_mutex_trylock, mutex,
+               retval, LTTNG_UST_CALLER_IP());
+       thread_in_trace = 0;
+       return retval;
+}
+
+int pthread_mutex_unlock(pthread_mutex_t *mutex)
+{
+       static int (*mutex_unlock)(pthread_mutex_t *);
+       int retval;
+
+       if (!mutex_unlock) {
+               mutex_unlock = dlsym(RTLD_NEXT, "pthread_mutex_unlock");
+               if (!mutex_unlock) {
+                       if (thread_in_trace) {
+                               abort();
+                       }
+                       fprintf(stderr, "unable to initialize pthread wrapper library.\n");
+                       return EINVAL;
+               }
+       }
+       if (thread_in_trace) {
+               return mutex_unlock(mutex);
+       }
+
+       thread_in_trace = 1;
+       retval = mutex_unlock(mutex);
+       tracepoint(lttng_ust_pthread, pthread_mutex_unlock, mutex,
+               retval, LTTNG_UST_CALLER_IP());
+       thread_in_trace = 0;
+       return retval;
+}
diff --git a/src/lib/lttng-ust-pthread-wrapper/ust_pthread.h b/src/lib/lttng-ust-pthread-wrapper/ust_pthread.h
new file mode 100644 (file)
index 0000000..4fdc11a
--- /dev/null
@@ -0,0 +1,64 @@
+/*
+ * SPDX-License-Identifier: MIT
+ *
+ * Copyright (C) 2013  Mentor Graphics
+ */
+
+#undef TRACEPOINT_PROVIDER
+#define TRACEPOINT_PROVIDER lttng_ust_pthread
+
+#if !defined(_TRACEPOINT_UST_PTHREAD_H) || defined(TRACEPOINT_HEADER_MULTI_READ)
+#define _TRACEPOINT_UST_PTHREAD_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <lttng/tracepoint.h>
+
+TRACEPOINT_EVENT(lttng_ust_pthread, pthread_mutex_lock_req,
+       TP_ARGS(pthread_mutex_t *, mutex, void *, ip),
+       TP_FIELDS(
+               ctf_integer_hex(void *, mutex, mutex)
+               ctf_unused(ip)
+       )
+)
+
+TRACEPOINT_EVENT(lttng_ust_pthread, pthread_mutex_lock_acq,
+       TP_ARGS(pthread_mutex_t *, mutex, int, status, void *, ip),
+       TP_FIELDS(
+               ctf_integer_hex(void *, mutex, mutex)
+               ctf_integer(int, status, status)
+               ctf_unused(ip)
+       )
+)
+
+TRACEPOINT_EVENT(lttng_ust_pthread, pthread_mutex_trylock,
+       TP_ARGS(pthread_mutex_t *, mutex, int, status, void *, ip),
+       TP_FIELDS(
+               ctf_integer_hex(void *, mutex, mutex)
+               ctf_integer(int, status, status)
+               ctf_unused(ip)
+       )
+)
+
+TRACEPOINT_EVENT(lttng_ust_pthread, pthread_mutex_unlock,
+       TP_ARGS(pthread_mutex_t *, mutex, int, status, void *, ip),
+       TP_FIELDS(
+               ctf_integer_hex(void *, mutex, mutex)
+               ctf_integer(int, status, status)
+               ctf_unused(ip)
+       )
+)
+
+#endif /* _TRACEPOINT_UST_PTHREAD_H */
+
+#undef TRACEPOINT_INCLUDE
+#define TRACEPOINT_INCLUDE "./ust_pthread.h"
+
+/* This part must be outside ifdef protection */
+#include <lttng/tracepoint-event.h>
+
+#ifdef __cplusplus
+}
+#endif
This page took 0.034365 seconds and 4 git commands to generate.