From: Mathieu Desnoyers Date: Fri, 18 Nov 2011 19:04:08 +0000 (-0500) Subject: Do not install usterr-signal-safe X-Git-Tag: v1.9.1~68 X-Git-Url: http://git.lttng.org/?a=commitdiff_plain;h=44c72f10aa3cace72ffe40a0f9bb7aadb9c82dc8;p=lttng-ust.git Do not install usterr-signal-safe Signed-off-by: Mathieu Desnoyers --- diff --git a/include/Makefile.am b/include/Makefile.am index 28462e60..4ebff36a 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -10,7 +10,6 @@ nobase_include_HEADERS = \ lttng/ust-abi.h \ lttng/ringbuffer-abi.h \ lttng/ust-tracer.h \ - lttng/usterr-signal-safe.h \ lttng/config.h \ lttng/share.h \ lttng/ust.h \ @@ -22,6 +21,7 @@ nobase_include_HEADERS = \ noinst_HEADERS = \ usterr.h \ + usterr-signal-safe.h \ ust_snprintf.h \ ust-comm.h \ lttng/bitfield.h \ diff --git a/include/lttng/ringbuffer-config.h b/include/lttng/ringbuffer-config.h index 1ff5858c..728738cd 100644 --- a/include/lttng/ringbuffer-config.h +++ b/include/lttng/ringbuffer-config.h @@ -21,7 +21,6 @@ #include #include "lttng/ust-tracer.h" -#include "lttng/usterr-signal-safe.h" #include #include #include diff --git a/include/lttng/ust-tracepoint-event.h b/include/lttng/ust-tracepoint-event.h index 23c2e384..6983ef16 100644 --- a/include/lttng/ust-tracepoint-event.h +++ b/include/lttng/ust-tracepoint-event.h @@ -14,8 +14,8 @@ #include #include #include -#include #include +#include /* * Macro declarations used for all stages. diff --git a/include/lttng/usterr-signal-safe.h b/include/lttng/usterr-signal-safe.h deleted file mode 100644 index ab4c8a36..00000000 --- a/include/lttng/usterr-signal-safe.h +++ /dev/null @@ -1,147 +0,0 @@ -#ifndef _USTERR_SIGNAL_SAFE_H -#define _USTERR_SIGNAL_SAFE_H - -/* - * Copyright (C) 2009 Pierre-Marc Fournier - * Copyright (C) 2011 Mathieu Desnoyers - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; version 2.1 of - * the License. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include -#include -#include -#include -#include -#include - -#include - -enum ust_loglevel { - UST_LOGLEVEL_UNKNOWN = 0, - UST_LOGLEVEL_NORMAL, - UST_LOGLEVEL_DEBUG, -}; - -extern volatile enum ust_loglevel ust_loglevel; -void init_usterr(void); - -static inline int ust_debug(void) -{ - return ust_loglevel == UST_LOGLEVEL_DEBUG; -} - -#ifndef UST_COMPONENT -//#error UST_COMPONENT is undefined -#define UST_COMPONENT libust -#endif - -/* To stringify the expansion of a define */ -#define UST_XSTR(d) UST_STR(d) -#define UST_STR(s) #s - -#define USTERR_MAX_LEN 512 - -/* 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. - */ - -extern int ust_safe_snprintf(char *str, size_t n, const char *fmt, ...) - __attribute__ ((format (printf, 3, 4))); - -static inline void __attribute__ ((format (printf, 1, 2))) - __check_ust_safe_fmt(const char *fmt, ...) -{ -} - -/* Can't use dynamic allocation. Limit ourselves to USTERR_MAX_LEN chars. */ -/* Add end of string in case of buffer overflow. */ -#define sigsafe_print_err(fmt, args...) \ -do { \ - char ____buf[USTERR_MAX_LEN]; \ - int ____saved_errno; \ - ____saved_errno = errno; /* signal-safety */ \ - ust_safe_snprintf(____buf, sizeof(____buf), fmt, ## args); \ - ____buf[sizeof(____buf) - 1] = 0; \ - patient_write(STDERR_FILENO, ____buf, strlen(____buf)); \ - errno = ____saved_errno; /* signal-safety */ \ -} while (0) - -#define UST_STR_COMPONENT UST_XSTR(UST_COMPONENT) - -#define ERRMSG(fmt, args...) \ - do { \ - sigsafe_print_err(UST_STR_COMPONENT "[%ld/%ld]: " fmt " (in %s() at " __FILE__ ":" UST_XSTR(__LINE__) ")\n", \ - (long) getpid(), \ - (long) syscall(SYS_gettid), \ - ## args, __func__); \ - fflush(stderr); \ - } while(0) - -#ifdef LTTNG_UST_DEBUG -# define DBG(fmt, args...) ERRMSG(fmt, ## args) -# define DBG_raw(fmt, args...) \ - do { \ - sigsafe_print_err(fmt, ## args); \ - fflush(stderr); \ - } while(0) -#else -# define DBG(fmt, args...) \ - do { \ - if (ust_debug()) \ - ERRMSG(fmt, ## args); \ - } while (0) -# define DBG_raw(fmt, args...) \ - do { \ - if (ust_debug()) { \ - sigsafe_print_err(fmt, ## args); \ - fflush(stderr); \ - } \ - } while(0) -#endif -#define WARN(fmt, args...) ERRMSG("Warning: " fmt, ## args) -#define ERR(fmt, args...) ERRMSG("Error: " fmt, ## args) -#define BUG(fmt, args...) ERRMSG("BUG: " fmt, ## args) - -#if (_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600) && !defined(_GNU_SOURCE) -#define PERROR(call, args...)\ - do { \ - char buf[200] = "Error in strerror_r()"; \ - strerror_r(errno, buf, sizeof(buf)); \ - ERRMSG("Error: " call ": %s", ## args, buf); \ - } while(0); -#else -#define PERROR(call, args...)\ - do { \ - char *buf; \ - char tmp[200]; \ - buf = strerror_r(errno, tmp, sizeof(tmp)); \ - ERRMSG("Error: " call ": %s", ## args, buf); \ - } while(0); -#endif - -#define BUG_ON(condition) \ - do { \ - if (caa_unlikely(condition)) \ - ERR("condition not respected (BUG) on line %s:%d", __FILE__, __LINE__); \ - } while(0) -#define WARN_ON(condition) \ - do { \ - if (caa_unlikely(condition)) \ - WARN("condition not respected on line %s:%d", __FILE__, __LINE__); \ - } while(0) -#define WARN_ON_ONCE(condition) WARN_ON(condition) - -#endif /* _USTERR_SIGNAL_SAFE_H */ diff --git a/include/usterr-signal-safe.h b/include/usterr-signal-safe.h new file mode 100644 index 00000000..ab4c8a36 --- /dev/null +++ b/include/usterr-signal-safe.h @@ -0,0 +1,147 @@ +#ifndef _USTERR_SIGNAL_SAFE_H +#define _USTERR_SIGNAL_SAFE_H + +/* + * Copyright (C) 2009 Pierre-Marc Fournier + * Copyright (C) 2011 Mathieu Desnoyers + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; version 2.1 of + * the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include +#include +#include +#include +#include +#include + +#include + +enum ust_loglevel { + UST_LOGLEVEL_UNKNOWN = 0, + UST_LOGLEVEL_NORMAL, + UST_LOGLEVEL_DEBUG, +}; + +extern volatile enum ust_loglevel ust_loglevel; +void init_usterr(void); + +static inline int ust_debug(void) +{ + return ust_loglevel == UST_LOGLEVEL_DEBUG; +} + +#ifndef UST_COMPONENT +//#error UST_COMPONENT is undefined +#define UST_COMPONENT libust +#endif + +/* To stringify the expansion of a define */ +#define UST_XSTR(d) UST_STR(d) +#define UST_STR(s) #s + +#define USTERR_MAX_LEN 512 + +/* 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. + */ + +extern int ust_safe_snprintf(char *str, size_t n, const char *fmt, ...) + __attribute__ ((format (printf, 3, 4))); + +static inline void __attribute__ ((format (printf, 1, 2))) + __check_ust_safe_fmt(const char *fmt, ...) +{ +} + +/* Can't use dynamic allocation. Limit ourselves to USTERR_MAX_LEN chars. */ +/* Add end of string in case of buffer overflow. */ +#define sigsafe_print_err(fmt, args...) \ +do { \ + char ____buf[USTERR_MAX_LEN]; \ + int ____saved_errno; \ + ____saved_errno = errno; /* signal-safety */ \ + ust_safe_snprintf(____buf, sizeof(____buf), fmt, ## args); \ + ____buf[sizeof(____buf) - 1] = 0; \ + patient_write(STDERR_FILENO, ____buf, strlen(____buf)); \ + errno = ____saved_errno; /* signal-safety */ \ +} while (0) + +#define UST_STR_COMPONENT UST_XSTR(UST_COMPONENT) + +#define ERRMSG(fmt, args...) \ + do { \ + sigsafe_print_err(UST_STR_COMPONENT "[%ld/%ld]: " fmt " (in %s() at " __FILE__ ":" UST_XSTR(__LINE__) ")\n", \ + (long) getpid(), \ + (long) syscall(SYS_gettid), \ + ## args, __func__); \ + fflush(stderr); \ + } while(0) + +#ifdef LTTNG_UST_DEBUG +# define DBG(fmt, args...) ERRMSG(fmt, ## args) +# define DBG_raw(fmt, args...) \ + do { \ + sigsafe_print_err(fmt, ## args); \ + fflush(stderr); \ + } while(0) +#else +# define DBG(fmt, args...) \ + do { \ + if (ust_debug()) \ + ERRMSG(fmt, ## args); \ + } while (0) +# define DBG_raw(fmt, args...) \ + do { \ + if (ust_debug()) { \ + sigsafe_print_err(fmt, ## args); \ + fflush(stderr); \ + } \ + } while(0) +#endif +#define WARN(fmt, args...) ERRMSG("Warning: " fmt, ## args) +#define ERR(fmt, args...) ERRMSG("Error: " fmt, ## args) +#define BUG(fmt, args...) ERRMSG("BUG: " fmt, ## args) + +#if (_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600) && !defined(_GNU_SOURCE) +#define PERROR(call, args...)\ + do { \ + char buf[200] = "Error in strerror_r()"; \ + strerror_r(errno, buf, sizeof(buf)); \ + ERRMSG("Error: " call ": %s", ## args, buf); \ + } while(0); +#else +#define PERROR(call, args...)\ + do { \ + char *buf; \ + char tmp[200]; \ + buf = strerror_r(errno, tmp, sizeof(tmp)); \ + ERRMSG("Error: " call ": %s", ## args, buf); \ + } while(0); +#endif + +#define BUG_ON(condition) \ + do { \ + if (caa_unlikely(condition)) \ + ERR("condition not respected (BUG) on line %s:%d", __FILE__, __LINE__); \ + } while(0) +#define WARN_ON(condition) \ + do { \ + if (caa_unlikely(condition)) \ + WARN("condition not respected on line %s:%d", __FILE__, __LINE__); \ + } while(0) +#define WARN_ON_ONCE(condition) WARN_ON(condition) + +#endif /* _USTERR_SIGNAL_SAFE_H */ diff --git a/liblttng-ust-ctl/ustctl.c b/liblttng-ust-ctl/ustctl.c index 83c60034..e285a2d2 100644 --- a/liblttng-ust-ctl/ustctl.c +++ b/liblttng-ust-ctl/ustctl.c @@ -20,9 +20,10 @@ #include #include #include -#include #include #include + +#include #include #include "../libringbuffer/backend.h" diff --git a/liblttng-ust/ltt-events.c b/liblttng-ust/ltt-events.c index b67998c3..2595ea89 100644 --- a/liblttng-ust/ltt-events.c +++ b/liblttng-ust/ltt-events.c @@ -14,25 +14,29 @@ #include #include #include -#include -#include -#include #include -#include #include #include #include +#include +#include + +#include +#include +#include +#include + +#include #include -#include + +#include +#include + #include "ltt-tracer.h" #include "ltt-tracer-core.h" #include "wait.h" #include "../libringbuffer/shm.h" -#include -#include -#include #include "jhash.h" -#include /* * The sessions mutex is the centralized mutex across UST tracing diff --git a/liblttng-ust/ltt-tracer-core.h b/liblttng-ust/ltt-tracer-core.h index c54d620e..fdb73119 100644 --- a/liblttng-ust/ltt-tracer-core.h +++ b/liblttng-ust/ltt-tracer-core.h @@ -24,12 +24,11 @@ #include #include #include -#include #include -#include -#include "lttng/bug.h" - +#include +#include #include +#include struct ltt_session; struct ltt_channel; diff --git a/liblttng-ust/lttng-ust-abi.c b/liblttng-ust/lttng-ust-abi.c index dbf53306..76af511f 100644 --- a/liblttng-ust/lttng-ust-abi.c +++ b/liblttng-ust/lttng-ust-abi.c @@ -28,11 +28,11 @@ #include #include #include -#include #include +#include +#include #include "ltt-tracer.h" #include "tracepoint-internal.h" -#include struct ltt_tracepoint_list { struct tracepoint_iter iter; diff --git a/liblttng-ust/lttng-ust-comm.c b/liblttng-ust/lttng-ust-comm.c index 17c7350d..2f972942 100644 --- a/liblttng-ust/lttng-ust-comm.c +++ b/liblttng-ust/lttng-ust-comm.c @@ -38,12 +38,12 @@ #include #include -#include #include -#include #include -#include "tracepoint-internal.h" #include +#include +#include +#include "tracepoint-internal.h" #include "ltt-tracer-core.h" /* diff --git a/liblttng-ust/tracepoint.c b/liblttng-ust/tracepoint.c index e62b11c7..abe39e57 100644 --- a/liblttng-ust/tracepoint.c +++ b/liblttng-ust/tracepoint.c @@ -21,17 +21,20 @@ #define _LGPL_SOURCE #include -#include #include #include + #include #include #include #include #include + +#include + +#include #include -#include #include "tracepoint-internal.h" #include "ltt-tracer-core.h" #include "jhash.h" diff --git a/liblttng-ust/ust-core.c b/liblttng-ust/ust-core.c index 80bd42b0..7c17a766 100644 --- a/liblttng-ust/ust-core.c +++ b/liblttng-ust/ust-core.c @@ -18,9 +18,9 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#include -#include #include +#include +#include static CDS_LIST_HEAD(ltt_transport_list); diff --git a/libringbuffer/frontend_types.h b/libringbuffer/frontend_types.h index cb3b21cd..32462f6b 100644 --- a/libringbuffer/frontend_types.h +++ b/libringbuffer/frontend_types.h @@ -21,8 +21,8 @@ #include #include -#include #include +#include #include "backend_types.h" #include "shm_internal.h" #include "vatomic.h" diff --git a/libringbuffer/shm.h b/libringbuffer/shm.h index d102b8bf..41111447 100644 --- a/libringbuffer/shm.h +++ b/libringbuffer/shm.h @@ -10,7 +10,7 @@ */ #include -#include +#include #include #include "shm_types.h" diff --git a/snprintf/core.c b/snprintf/core.c index cbacdb54..2fa9839c 100644 --- a/snprintf/core.c +++ b/snprintf/core.c @@ -18,6 +18,6 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#include +#include volatile enum ust_loglevel ust_loglevel;