Fix: baddr_statedump tracepoint registration
authorPaul Woegerer <paul_woegerer@mentor.com>
Tue, 10 Dec 2013 13:07:51 +0000 (14:07 +0100)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Tue, 10 Dec 2013 14:56:34 +0000 (09:56 -0500)
Ensure baddr_statedump tracepoint registration is completed prior to
using the tracepoint in lttng_ust_baddr_statedump().

Make liblttng-ust-dl robust for explicit baddr_statedump tracepoint
deregistration in lttng_ust_cleanup() (prevent dlopen/dlclose to get
traced if ust_baddr tracepoints are not available).

Signed-off-by: Paul Woegerer <paul_woegerer@mentor.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
liblttng-ust-dl/ustdl.c
liblttng-ust/lttng-ust-baddr.c
liblttng-ust/lttng-ust-baddr.h
liblttng-ust/lttng-ust-comm.c

index 3038d5c3636a87e85781147f3c65b7e0835f3861..ceb9b5bad8115140c03848bb21cf01373cbd02d0 100644 (file)
@@ -90,7 +90,7 @@ void lttng_ust_baddr_push(void *so_base, const char *so_name)
 void *dlopen(const char *filename, int flag)
 {
        void *handle = _lttng_ust_dl_libc_dlopen(filename, flag);
-       if (handle) {
+       if (__tracepoint_ptrs_registered && handle) {
                struct link_map *p = NULL;
                if (dlinfo(handle, RTLD_DI_LINKMAP, &p) != -1 && p != NULL
                                && p->l_addr != 0)
@@ -101,7 +101,7 @@ void *dlopen(const char *filename, int flag)
 
 int dlclose(void *handle)
 {
-       if (handle) {
+       if (__tracepoint_ptrs_registered && handle) {
                struct link_map *p = NULL;
                if (dlinfo(handle, RTLD_DI_LINKMAP, &p) != -1 && p != NULL
                                && p->l_addr != 0)
index df0ba457da85ce2baf0d9151f739de371588c7e5..b7843e24886c11bb99531470b97c11a5ae66158c 100644 (file)
@@ -194,3 +194,15 @@ int lttng_ust_baddr_statedump(void *owner)
        dump_exec_baddr(&data);
        return 0;
 }
+
+void lttng_ust_baddr_statedump_init(void)
+{
+       __tracepoints__init();
+       __tracepoints__ptrs_init();
+}
+
+void lttng_ust_baddr_statedump_destroy(void)
+{
+       __tracepoints__ptrs_destroy();
+       __tracepoints__destroy();
+}
index 08f7db7d0dd960cf76c6ea9d42d893357a725021..e7a0dfb69113ad128e46e82fdaa3da3d2f42d836 100644 (file)
@@ -21,6 +21,9 @@
 
 #include <lttng/ust-events.h>
 
+void lttng_ust_baddr_statedump_init(void);
+void lttng_ust_baddr_statedump_destroy(void);
+
 int lttng_ust_baddr_statedump(void *owner);
 
 #endif /* LTTNG_UST_BADDR_H */
index 6eb4a892f7bf7d343ec3d77b8e9d6ab0cea38b33..0c96f012f528fd4929581107e45ba9314430a92e 100644 (file)
@@ -1343,6 +1343,7 @@ void __attribute__((constructor)) lttng_ust_init(void)
         */
        init_usterr();
        init_tracepoint();
+       lttng_ust_baddr_statedump_init();
        lttng_ring_buffer_metadata_client_init();
        lttng_ring_buffer_client_overwrite_init();
        lttng_ring_buffer_client_overwrite_rt_init();
@@ -1457,6 +1458,7 @@ void lttng_ust_cleanup(int exiting)
        lttng_ring_buffer_client_overwrite_rt_exit();
        lttng_ring_buffer_client_overwrite_exit();
        lttng_ring_buffer_metadata_client_exit();
+       lttng_ust_baddr_statedump_destroy();
        exit_tracepoint();
        if (!exiting) {
                /* Reinitialize values for fork */
This page took 0.027164 seconds and 4 git commands to generate.