The major SONAME bump to '1' gives us the opportunity to hide private
symbols that should never have been visible.
Changing 'ust_loglevel' from a public weak symbol to a private one,
means that each library that uses ust_err will now have it's own private
copy of the loglevel and will have to call 'ust_err_init' in it's
constructor.
While we're at it, namespace the symbols that were previously part of
the ABI.
Change-Id: I031d4ebfaa43fa4fb3c9f60dc6b557b1d30eca18
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
### Global private headers ###
### ###
### Global private headers ###
### ###
-# note: usterr-signal-safe.h need namespace cleanup.
-
noinst_HEADERS = \
usterr-signal-safe.h \
ust-snprintf.h \
noinst_HEADERS = \
usterr-signal-safe.h \
ust-snprintf.h \
#include <sys/types.h>
#include <errno.h>
#include <stdarg.h>
#include <sys/types.h>
#include <errno.h>
#include <stdarg.h>
#include <stdio.h>
#include <ust-share.h>
#include <stdio.h>
#include <ust-share.h>
#include "ust-tid.h"
#include "ust-snprintf.h"
#include "ust-tid.h"
#include "ust-snprintf.h"
-enum ust_loglevel {
- UST_LOGLEVEL_UNKNOWN = 0,
- UST_LOGLEVEL_NORMAL,
- UST_LOGLEVEL_DEBUG,
+enum ust_err_loglevel {
+ UST_ERR_LOGLEVEL_UNKNOWN = 0,
+ UST_ERR_LOGLEVEL_NORMAL,
+ UST_ERR_LOGLEVEL_DEBUG,
-extern volatile enum ust_loglevel ust_loglevel;
-void init_usterr(void);
+LTTNG_HIDDEN
+extern volatile enum ust_err_loglevel ust_err_loglevel;
+LTTNG_HIDDEN
+void ust_err_init(void);
-static inline int ust_debug(void)
+static inline bool ust_err_debug_enabled(void)
}
#else /* #ifdef LTTNG_UST_DEBUG */
}
#else /* #ifdef LTTNG_UST_DEBUG */
-static inline int ust_debug(void)
+static inline bool ust_err_debug_enabled(void)
- return ust_loglevel == UST_LOGLEVEL_DEBUG;
+ return ust_err_loglevel == UST_ERR_LOGLEVEL_DEBUG;
}
#endif /* #else #ifdef LTTNG_UST_DEBUG */
}
#endif /* #else #ifdef LTTNG_UST_DEBUG */
+/*
+ * The default component for error messages.
+ */
-//#error UST_COMPONENT is undefined
#define UST_COMPONENT libust
#endif
#define UST_COMPONENT libust
#endif
#define UST_XSTR(d) UST_STR(d)
#define UST_STR(s) #s
#define UST_XSTR(d) UST_STR(d)
#define UST_STR(s) #s
-#define USTERR_MAX_LEN 512
+#define UST_ERR_MAX_LEN 512
-/* We sometimes print in the tracing path, and tracing can occur in
+/*
+ * We sometimes print in the tracing path, and tracing can occur in
* signal handlers, so we must use a print method which is signal safe.
*/
* signal handlers, so we must use a print method which is signal safe.
*/
-/* Can't use dynamic allocation. Limit ourselves to USTERR_MAX_LEN chars. */
+/* Can't use dynamic allocation. Limit ourselves to UST_ERR_MAX_LEN chars. */
/* Add end of string in case of buffer overflow. */
#define sigsafe_print_err(fmt, args...) \
do { \
/* Add end of string in case of buffer overflow. */
#define sigsafe_print_err(fmt, args...) \
do { \
- if (ust_debug()) { \
- char ____buf[USTERR_MAX_LEN]; \
+ if (ust_err_debug_enabled()) { \
+ char ____buf[UST_ERR_MAX_LEN]; \
int ____saved_errno; \
\
____saved_errno = errno; /* signal-safety */ \
int ____saved_errno; \
\
____saved_errno = errno; /* signal-safety */ \
*/
#define PERROR(call, args...) \
do { \
*/
#define PERROR(call, args...) \
do { \
+ if (ust_err_debug_enabled()) { \
char buf[200] = "Error in strerror_r()"; \
strerror_r(errno, buf, sizeof(buf)); \
ERRMSG("Error: " call ": %s", ## args, buf); \
char buf[200] = "Error in strerror_r()"; \
strerror_r(errno, buf, sizeof(buf)); \
ERRMSG("Error: " call ": %s", ## args, buf); \
*/
#define PERROR(call, args...) \
do { \
*/
#define PERROR(call, args...) \
do { \
+ if (ust_err_debug_enabled()) { \
char *buf; \
char tmp[200]; \
buf = strerror_r(errno, tmp, sizeof(tmp)); \
char *buf; \
char tmp[200]; \
buf = strerror_r(errno, tmp, sizeof(tmp)); \
static __attribute__((constructor))
void ustctl_init(void)
{
static __attribute__((constructor))
void ustctl_init(void)
{
- init_usterr();
- lttng_ust_getenv_init(); /* Needs init_usterr() to be completed. */
+ ust_err_init();
+ lttng_ust_getenv_init(); /* Needs ust_err_init() to be completed. */
lttng_ust_clock_init();
lttng_ring_buffer_metadata_client_init();
lttng_ring_buffer_client_overwrite_init();
lttng_ust_clock_init();
lttng_ring_buffer_metadata_client_init();
lttng_ring_buffer_client_overwrite_init();
#endif
static int (*__lttng_ust_plibc_dlclose)(void *handle);
#endif
static int (*__lttng_ust_plibc_dlclose)(void *handle);
+static __attribute__((constructor))
+void _lttng_ust_dl_init(void)
+{
+ ust_err_init();
+}
+
static
void *_lttng_ust_dl_libc_dlopen(const char *filename, int flags)
{
static
void *_lttng_ust_dl_libc_dlopen(const char *filename, int flags)
{
liblttng_ust_fd_la_LIBADD = \
$(top_builddir)/liblttng-ust/liblttng-ust.la \
liblttng_ust_fd_la_LIBADD = \
$(top_builddir)/liblttng-ust/liblttng-ust.la \
+ $(top_builddir)/snprintf/libustsnprintf.la \
$(DL_LIBS)
liblttng_ust_fd_la_CFLAGS = -DUST_COMPONENT=liblttng-ust-fd $(AM_CFLAGS)
$(DL_LIBS)
liblttng_ust_fd_la_CFLAGS = -DUST_COMPONENT=liblttng-ust-fd $(AM_CFLAGS)
static int (*__lttng_ust_fd_plibc_close)(int fd);
static int (*__lttng_ust_fd_plibc_fclose)(FILE *stream);
static int (*__lttng_ust_fd_plibc_close)(int fd);
static int (*__lttng_ust_fd_plibc_fclose)(FILE *stream);
+static __attribute__((constructor))
+void _lttng_ust_fd_init(void)
+{
+ ust_err_init();
+}
+
static
int _lttng_ust_fd_libc_close(int fd)
{
static
int _lttng_ust_fd_libc_close(int fd)
{
"Please upgrade your kernel "
"(fix is commit 9ea71503a8ed9184d2d0b8ccc4d269d05f7940ae in Linux kernel "
"mainline). LTTng-UST will use polling mode fallback.");
"Please upgrade your kernel "
"(fix is commit 9ea71503a8ed9184d2d0b8ccc4d269d05f7940ae in Linux kernel "
"mainline). LTTng-UST will use polling mode fallback.");
+ if (ust_err_debug_enabled())
PERROR("futex");
goto end_wait;
}
PERROR("futex");
goto end_wait;
}
* sessiond (otherwise leading to errors when trying to create
* sessiond before the init functions are completed).
*/
* sessiond (otherwise leading to errors when trying to create
* sessiond before the init functions are completed).
*/
- init_usterr();
- lttng_ust_getenv_init(); /* Needs init_usterr() to be completed. */
+ ust_err_init();
+ lttng_ust_getenv_init(); /* Needs ust_err_init() to be completed. */
init_tracepoint();
lttng_ust_init_fd_tracker();
lttng_ust_clock_init();
init_tracepoint();
lttng_ust_init_fd_tracker();
lttng_ust_clock_init();
DBG("just registered a tracepoints section from %p and having %d tracepoints",
tracepoints_start, tracepoints_count);
DBG("just registered a tracepoints section from %p and having %d tracepoints",
tracepoints_start, tracepoints_count);
+ if (ust_err_debug_enabled()) {
int i;
for (i = 0; i < tracepoints_count; i++) {
int i;
for (i = 0; i < tracepoints_count; i++) {
{
if (uatomic_xchg(&initialized, 1) == 1)
return;
{
if (uatomic_xchg(&initialized, 1) == 1)
return;
#include <usterr-signal-safe.h>
#include <usterr-signal-safe.h>
-volatile enum ust_loglevel ust_loglevel;
+volatile enum ust_err_loglevel ust_err_loglevel;
- if (ust_loglevel == UST_LOGLEVEL_UNKNOWN) {
+ if (ust_err_loglevel == UST_ERR_LOGLEVEL_UNKNOWN) {
/*
* This getenv is not part of lttng_getenv() because it
* is required to print ERR() performed during getenv
/*
* This getenv is not part of lttng_getenv() because it
* is required to print ERR() performed during getenv
*/
ust_debug = getenv("LTTNG_UST_DEBUG");
if (ust_debug)
*/
ust_debug = getenv("LTTNG_UST_DEBUG");
if (ust_debug)
- ust_loglevel = UST_LOGLEVEL_DEBUG;
+ ust_err_loglevel = UST_ERR_LOGLEVEL_DEBUG;
- ust_loglevel = UST_LOGLEVEL_NORMAL;
+ ust_err_loglevel = UST_ERR_LOGLEVEL_NORMAL;