From: Paul Woegerer Date: Tue, 10 Dec 2013 13:07:51 +0000 (+0100) Subject: Fix: baddr_statedump tracepoint registration X-Git-Tag: v2.4.0-rc2~1 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=bd703713989223b66362ed670e2b3b0097118f46;p=lttng-ust.git Fix: baddr_statedump tracepoint registration 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 Signed-off-by: Mathieu Desnoyers --- diff --git a/liblttng-ust-dl/ustdl.c b/liblttng-ust-dl/ustdl.c index 3038d5c3..ceb9b5ba 100644 --- a/liblttng-ust-dl/ustdl.c +++ b/liblttng-ust-dl/ustdl.c @@ -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) diff --git a/liblttng-ust/lttng-ust-baddr.c b/liblttng-ust/lttng-ust-baddr.c index df0ba457..b7843e24 100644 --- a/liblttng-ust/lttng-ust-baddr.c +++ b/liblttng-ust/lttng-ust-baddr.c @@ -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(); +} diff --git a/liblttng-ust/lttng-ust-baddr.h b/liblttng-ust/lttng-ust-baddr.h index 08f7db7d..e7a0dfb6 100644 --- a/liblttng-ust/lttng-ust-baddr.h +++ b/liblttng-ust/lttng-ust-baddr.h @@ -21,6 +21,9 @@ #include +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 */ diff --git a/liblttng-ust/lttng-ust-comm.c b/liblttng-ust/lttng-ust-comm.c index 6eb4a892..0c96f012 100644 --- a/liblttng-ust/lttng-ust-comm.c +++ b/liblttng-ust/lttng-ust-comm.c @@ -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 */