From df09bde567961bdf9cdda26f9737e3bbffd5cea9 Mon Sep 17 00:00:00 2001 From: Michael Jeanson Date: Mon, 12 Apr 2021 17:12:55 -0400 Subject: [PATCH] Move fd-tracker to liblttng-ust-common The fd-tracker provides ABI symbols to liblttng-ust-ctl which shouldn't link directy on liblttng-ust, move it to liblttng-ust-common to accomodate this. This is in line with the goal to move the shared state across our different libraries to ust-common. Change-Id: I69de6a9e6eaec9599f22e47cb0292ef793f6115d Signed-off-by: Michael Jeanson Signed-off-by: Mathieu Desnoyers --- src/common/ust-fd.h | 4 ++++ src/lib/lttng-ust-ctl/Makefile.am | 1 + src/liblttng-ust-comm/Makefile.am | 2 +- src/liblttng-ust/Makefile.am | 5 ++++ .../fd-tracker.c} | 3 +-- src/liblttng-ust/lttng-tracer-core.h | 3 --- src/liblttng-ust/ust-common.c | 24 +++++++++++++++++++ src/lttng-ust-ctl.pc.in | 2 +- tests/unit/libringbuffer/Makefile.am | 2 +- 9 files changed, 38 insertions(+), 8 deletions(-) rename src/{liblttng-ust-comm/lttng-ust-fd-tracker.c => liblttng-ust/fd-tracker.c} (99%) create mode 100644 src/liblttng-ust/ust-common.c diff --git a/src/common/ust-fd.h b/src/common/ust-fd.h index ddebaa91..9d14583c 100644 --- a/src/common/ust-fd.h +++ b/src/common/ust-fd.h @@ -11,6 +11,8 @@ * The fd tracker feature is part of the ABI and used by liblttng-ust-fd. * However, some test code and documentation needs to be written before it is * exposed to users with a public header. + * + * These symbols are provided by 'liblttng-ust-common'. */ #include @@ -25,4 +27,6 @@ int lttng_ust_safe_close_fd(int fd, int (*close_cb)(int)); int lttng_ust_safe_fclose_stream(FILE *stream, int (*fclose_cb)(FILE *stream)); int lttng_ust_safe_closefrom_fd(int lowfd, int (*close_cb)(int)); +void lttng_ust_fixup_fd_tracker_tls(void); + #endif /* _LTTNG_UST_FD_H */ diff --git a/src/lib/lttng-ust-ctl/Makefile.am b/src/lib/lttng-ust-ctl/Makefile.am index 43a88566..35999217 100644 --- a/src/lib/lttng-ust-ctl/Makefile.am +++ b/src/lib/lttng-ust-ctl/Makefile.am @@ -10,6 +10,7 @@ liblttng_ust_ctl_la_LDFLAGS = \ -version-info $(LTTNG_UST_CTL_LIBRARY_VERSION) liblttng_ust_ctl_la_LIBADD = \ + $(top_builddir)/src/liblttng-ust/liblttng-ust-common.la \ $(top_builddir)/src/liblttng-ust-comm/liblttng-ust-comm.la \ $(top_builddir)/src/liblttng-ust/liblttng-ust-support.la \ $(top_builddir)/src/common/libcommon.la \ diff --git a/src/liblttng-ust-comm/Makefile.am b/src/liblttng-ust-comm/Makefile.am index 5aa5938e..cad9c4ef 100644 --- a/src/liblttng-ust-comm/Makefile.am +++ b/src/liblttng-ust-comm/Makefile.am @@ -2,4 +2,4 @@ noinst_LTLIBRARIES = liblttng-ust-comm.la -liblttng_ust_comm_la_SOURCES = lttng-ust-comm.c lttng-ust-fd-tracker.c +liblttng_ust_comm_la_SOURCES = lttng-ust-comm.c diff --git a/src/liblttng-ust/Makefile.am b/src/liblttng-ust/Makefile.am index 78d82f0e..87380bc4 100644 --- a/src/liblttng-ust/Makefile.am +++ b/src/liblttng-ust/Makefile.am @@ -8,9 +8,14 @@ lib_LTLIBRARIES = liblttng-ust-common.la liblttng-ust-tracepoint.la liblttng-ust # ust-common liblttng_ust_common_la_SOURCES = \ + fd-tracker.c \ + ust-common.c \ lttng-ust-urcu.c \ lttng-ust-urcu-pointer.c +liblttng_ust_common_la_LIBADD = \ + $(top_builddir)/src/common/libcommon.la + liblttng_ust_common_la_LDFLAGS = -no-undefined -version-info $(LTTNG_UST_LIBRARY_VERSION) liblttng_ust_tracepoint_la_SOURCES = \ diff --git a/src/liblttng-ust-comm/lttng-ust-fd-tracker.c b/src/liblttng-ust/fd-tracker.c similarity index 99% rename from src/liblttng-ust-comm/lttng-ust-fd-tracker.c rename to src/liblttng-ust/fd-tracker.c index 3879a90d..df14f0e0 100644 --- a/src/liblttng-ust-comm/lttng-ust-fd-tracker.c +++ b/src/liblttng-ust/fd-tracker.c @@ -30,8 +30,7 @@ #include #include "common/logging.h" -#include "../liblttng-ust/compat.h" -#include "../liblttng-ust/lttng-tracer-core.h" +#include "liblttng-ust/compat.h" /* Operations on the fd set. */ #define IS_FD_VALID(fd) ((fd) >= 0 && (fd) < lttng_ust_max_fd) diff --git a/src/liblttng-ust/lttng-tracer-core.h b/src/liblttng-ust/lttng-tracer-core.h index e127a660..04ba642e 100644 --- a/src/liblttng-ust/lttng-tracer-core.h +++ b/src/liblttng-ust/lttng-tracer-core.h @@ -69,9 +69,6 @@ void lttng_fixup_time_ns_tls(void) void lttng_fixup_uts_ns_tls(void) __attribute__((visibility("hidden"))); -void lttng_ust_fixup_fd_tracker_tls(void) - __attribute__((visibility("hidden"))); - const char *lttng_ust_obj_get_name(int id) __attribute__((visibility("hidden"))); diff --git a/src/liblttng-ust/ust-common.c b/src/liblttng-ust/ust-common.c new file mode 100644 index 00000000..ad52770a --- /dev/null +++ b/src/liblttng-ust/ust-common.c @@ -0,0 +1,24 @@ +/* + * SPDX-License-Identifier: LGPL-2.1-only + * + * Copyright (C) 2021 Michael Jeanson + */ + +#include "common/logging.h" +#include "common/ust-fd.h" + +static +void lttng_ust_common_init(void) + __attribute__((constructor)); +static +void lttng_ust_common_init(void) +{ + /* Initialize logging for liblttng-ust-common */ + ust_err_init(); + + /* + * Initialize the fd-tracker, other libraries using it should also call + * this in their constructor in case it gets executed before this one. + */ + lttng_ust_init_fd_tracker(); +} diff --git a/src/lttng-ust-ctl.pc.in b/src/lttng-ust-ctl.pc.in index 3170b30a..a82a6689 100644 --- a/src/lttng-ust-ctl.pc.in +++ b/src/lttng-ust-ctl.pc.in @@ -7,6 +7,6 @@ Name: LTTng Userspace Tracer control Description: The LTTng Userspace Tracer (UST) is a library accompanied by a set of tools to trace userspace code. Version: @PACKAGE_VERSION@ Requires: -Libs: -L${libdir} -llttng-ust-ctl +Libs: -L${libdir} -llttng-ust-ctl -llttng-ust-common Cflags: -I${includedir} diff --git a/tests/unit/libringbuffer/Makefile.am b/tests/unit/libringbuffer/Makefile.am index 7b086442..253e9dae 100644 --- a/tests/unit/libringbuffer/Makefile.am +++ b/tests/unit/libringbuffer/Makefile.am @@ -6,6 +6,6 @@ noinst_PROGRAMS = test_shm test_shm_SOURCES = shm.c test_shm_LDADD = \ $(top_builddir)/src/common/libringbuffer.la \ - $(top_builddir)/src/liblttng-ust-comm/liblttng-ust-comm.la \ + $(top_builddir)/src/liblttng-ust/liblttng-ust-common.la \ $(top_builddir)/src/common/libcommon.la \ $(top_builddir)/tests/utils/libtap.a -- 2.34.1