Make lttng-ust robust against -finstrument-functions.
authorPaul Woegerer <paul_woegerer@mentor.com>
Wed, 18 Jul 2012 19:28:44 +0000 (15:28 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Wed, 18 Jul 2012 19:28:44 +0000 (15:28 -0400)
[ Edit by Mathieu Desnoyers:

We need to declare the no_instrument_function attribute on function
declarations (rather than definition) for g++. Moved the attribute prior
to the function declaration (rather than after) to follow the coding
style within LTTng-UST. ]

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
include/Makefile.am
include/lttng/ringbuffer-config.h
include/lttng/tracepoint.h
include/lttng/ust-compiler.h [new file with mode: 0644]
include/lttng/ust-tracepoint-event.h

index 633260baf8fe16d1392749ed025ed4fadbc9c7a9..208e74e92e68f943c0933e8000c4b9c2ee3eb655 100644 (file)
@@ -14,6 +14,7 @@ nobase_include_HEADERS = \
        lttng/ringbuffer-abi.h \
        lttng/ust-tracer.h \
        lttng/ust-config.h \
+       lttng/ust-compiler.h \
        lttng/ust.h \
        lttng/ust-endian.h \
        lttng/ringbuffer-config.h \
index 24e7dbeb6bf9e07fc8d1521a11ace7e8a830a016..650b56b250db4dbb6d2889bff659c74fe1c20970 100644 (file)
@@ -27,6 +27,7 @@
 #include <urcu/arch.h>
 #include <string.h>
 #include "lttng/align.h"
+#include <lttng/ust-compiler.h>
 
 struct lttng_ust_lib_ring_buffer;
 struct channel;
@@ -228,6 +229,11 @@ struct lttng_ust_lib_ring_buffer_ctx {
  * @largest_align: largest alignment within data payload types
  * @cpu: processor id
  */
+static inline lttng_ust_notrace
+void lib_ring_buffer_ctx_init(struct lttng_ust_lib_ring_buffer_ctx *ctx,
+                             struct channel *chan, void *priv,
+                             size_t data_size, int largest_align,
+                             int cpu, struct lttng_ust_shm_handle *handle);
 static inline
 void lib_ring_buffer_ctx_init(struct lttng_ust_lib_ring_buffer_ctx *ctx,
                              struct channel *chan, void *priv,
@@ -275,6 +281,8 @@ void lib_ring_buffer_ctx_init(struct lttng_ust_lib_ring_buffer_ctx *ctx,
  * Calculate the offset needed to align the type.
  * size_of_type must be non-zero.
  */
+static inline lttng_ust_notrace
+unsigned int lib_ring_buffer_align(size_t align_drift, size_t size_of_type);
 static inline
 unsigned int lib_ring_buffer_align(size_t align_drift, size_t size_of_type)
 {
@@ -289,6 +297,8 @@ unsigned int lib_ring_buffer_align(size_t align_drift, size_t size_of_type)
  * Calculate the offset needed to align the type.
  * size_of_type must be non-zero.
  */
+static inline lttng_ust_notrace
+unsigned int lib_ring_buffer_align(size_t align_drift, size_t size_of_type);
 static inline
 unsigned int lib_ring_buffer_align(size_t align_drift, size_t size_of_type)
 {
@@ -301,6 +311,9 @@ unsigned int lib_ring_buffer_align(size_t align_drift, size_t size_of_type)
  * lib_ring_buffer_align_ctx - Align context offset on "alignment"
  * @ctx: ring buffer context.
  */
+static inline lttng_ust_notrace
+void lib_ring_buffer_align_ctx(struct lttng_ust_lib_ring_buffer_ctx *ctx,
+                          size_t alignment);
 static inline
 void lib_ring_buffer_align_ctx(struct lttng_ust_lib_ring_buffer_ctx *ctx,
                           size_t alignment)
@@ -313,6 +326,10 @@ void lib_ring_buffer_align_ctx(struct lttng_ust_lib_ring_buffer_ctx *ctx,
  * lib_ring_buffer_check_config() returns 0 on success.
  * Used internally to check for valid configurations at channel creation.
  */
+static inline lttng_ust_notrace
+int lib_ring_buffer_check_config(const struct lttng_ust_lib_ring_buffer_config *config,
+                            unsigned int switch_timer_interval,
+                            unsigned int read_timer_interval);
 static inline
 int lib_ring_buffer_check_config(const struct lttng_ust_lib_ring_buffer_config *config,
                             unsigned int switch_timer_interval,
index 5bab476b86485a112c98a5ab433fa13ec88cca7d..e1de626cc6b54ff5db9f7935099b99c24017f4c2 100644 (file)
@@ -22,6 +22,7 @@
 #include <string.h>    /* for memset */
 #include <assert.h>
 #include <lttng/ust-config.h>  /* for sdt */
+#include <lttng/ust-compiler.h>
 
 #ifdef LTTNG_UST_HAVE_SDT_INTEGRATION
 #define SDT_USE_VARIADIC
@@ -137,7 +138,10 @@ extern "C" {
 
 #define _DECLARE_TRACEPOINT(_provider, _name, ...)                                     \
 extern struct tracepoint __tracepoint_##_provider##___##_name;                         \
-static inline void __tracepoint_cb_##_provider##___##_name(_TP_ARGS_PROTO(__VA_ARGS__))        \
+static inline lttng_ust_notrace                                                                \
+void __tracepoint_cb_##_provider##___##_name(_TP_ARGS_PROTO(__VA_ARGS__));             \
+static inline                                                                          \
+void __tracepoint_cb_##_provider##___##_name(_TP_ARGS_PROTO(__VA_ARGS__))              \
 {                                                                                      \
        struct tracepoint_probe *__tp_probe;                                            \
                                                                                        \
@@ -157,14 +161,22 @@ static inline void __tracepoint_cb_##_provider##___##_name(_TP_ARGS_PROTO(__VA_A
 end:                                                                                   \
        tp_rcu_read_unlock_bp();                                                        \
 }                                                                                      \
-static inline void __tracepoint_register_##_provider##___##_name(char *name,           \
-               void (*func)(void), void *data)                                                 \
+static inline lttng_ust_notrace                                                                \
+void __tracepoint_register_##_provider##___##_name(char *name,                         \
+               void (*func)(void), void *data);                                        \
+static inline                                                                          \
+void __tracepoint_register_##_provider##___##_name(char *name,                         \
+               void (*func)(void), void *data)                                         \
 {                                                                                      \
        __tracepoint_probe_register(name, func, data,                                   \
                __tracepoint_##_provider##___##_name.signature);                        \
 }                                                                                      \
-static inline void __tracepoint_unregister_##_provider##___##_name(char *name,         \
-               void (*func)(void), void *data)                                                 \
+static inline lttng_ust_notrace                                                                \
+void __tracepoint_unregister_##_provider##___##_name(char *name,                       \
+               void (*func)(void), void *data);                                        \
+static inline                                                                          \
+void __tracepoint_unregister_##_provider##___##_name(char *name,                       \
+               void (*func)(void), void *data)                                         \
 {                                                                                      \
        __tracepoint_probe_unregister(name, func, data);                                \
 }
@@ -249,7 +261,10 @@ int __tracepoint_registered
 struct tracepoint_dlopen tracepoint_dlopen
        __attribute__((weak, visibility("hidden")));
 
-static void __attribute__((constructor)) __tracepoints__init(void)
+static void lttng_ust_notrace __attribute__((constructor))
+__tracepoints__init(void);
+static void
+__tracepoints__init(void)
 {
        if (__tracepoint_registered++)
                return;
@@ -285,7 +300,10 @@ static void __attribute__((constructor)) __tracepoints__init(void)
                                __start___tracepoints_ptrs);
 }
 
-static void __attribute__((destructor)) __tracepoints__destroy(void)
+static void lttng_ust_notrace __attribute__((destructor))
+__tracepoints__destroy(void);
+static void
+__tracepoints__destroy(void)
 {
        int ret;
 
diff --git a/include/lttng/ust-compiler.h b/include/lttng/ust-compiler.h
new file mode 100644 (file)
index 0000000..c35a23e
--- /dev/null
@@ -0,0 +1,21 @@
+#ifndef _LTTNG_UST_COMPILER_H
+#define _LTTNG_UST_COMPILER_H
+
+/*
+ * Copyright 2011-2012 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *                       Paul Woegerer <paul_woegerer@mentor.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ */
+
+#define lttng_ust_notrace __attribute__((no_instrument_function))
+
+#endif /* _LTTNG_UST_COMPILER_H */
index 8db1e688fb8ff3d9dba3d8dcd1242be62ebc0cdf..aac32b96833413fe66add9a52097a4e5221fb344 100644 (file)
@@ -16,6 +16,7 @@
 #include <urcu/compiler.h>
 #include <lttng/ust-events.h>
 #include <lttng/ringbuffer-config.h>
+#include <lttng/ust-compiler.h>
 #include <string.h>
 
 /*
@@ -243,8 +244,11 @@ static void __event_probe__##_provider##___##_name(_TP_ARGS_DATA_PROTO(_args));
 #define TP_FIELDS(...) __VA_ARGS__
 
 #undef TRACEPOINT_EVENT_CLASS
-#define TRACEPOINT_EVENT_CLASS(_provider, _name, _args, _fields)      \
-static inline size_t __event_get_size__##_provider##___##_name(size_t *__dynamic_len, _TP_ARGS_DATA_PROTO(_args)) \
+#define TRACEPOINT_EVENT_CLASS(_provider, _name, _args, _fields)             \
+static inline lttng_ust_notrace                                                      \
+size_t __event_get_size__##_provider##___##_name(size_t *__dynamic_len, _TP_ARGS_DATA_PROTO(_args)); \
+static inline                                                                \
+size_t __event_get_size__##_provider##___##_name(size_t *__dynamic_len, _TP_ARGS_DATA_PROTO(_args)) \
 {                                                                            \
        size_t __event_len = 0;                                               \
        unsigned int __dynamic_len_idx = 0;                                   \
@@ -360,6 +364,8 @@ void __event_prepare_filter_stack__##_provider##___##_name(char *__stack_data,\
 
 #undef TRACEPOINT_EVENT_CLASS
 #define TRACEPOINT_EVENT_CLASS(_provider, _name, _args, _fields)             \
+static inline lttng_ust_notrace                                                      \
+size_t __event_get_align__##_provider##___##_name(_TP_ARGS_PROTO(_args));     \
 static inline                                                                \
 size_t __event_get_align__##_provider##___##_name(_TP_ARGS_PROTO(_args))      \
 {                                                                            \
@@ -438,7 +444,10 @@ size_t __event_get_align__##_provider##___##_name(_TP_ARGS_PROTO(_args))      \
  */
 #undef TRACEPOINT_EVENT_CLASS
 #define TRACEPOINT_EVENT_CLASS(_provider, _name, _args, _fields)             \
-static void __event_probe__##_provider##___##_name(_TP_ARGS_DATA_PROTO(_args))\
+static lttng_ust_notrace                                                     \
+void __event_probe__##_provider##___##_name(_TP_ARGS_DATA_PROTO(_args));      \
+static                                                                       \
+void __event_probe__##_provider##___##_name(_TP_ARGS_DATA_PROTO(_args))              \
 {                                                                            \
        struct ltt_event *__event = __tp_data;                                \
        struct ltt_channel *__chan = __event->chan;                           \
@@ -593,7 +602,9 @@ static struct lttng_probe_desc _TP_COMBINE_TOKENS(__probe_desc___, TRACEPOINT_PR
 
 /* Reset all macros within TRACEPOINT_EVENT */
 #include <lttng/ust-tracepoint-event-reset.h>
-static void __attribute__((constructor))
+static void lttng_ust_notrace __attribute__((constructor))
+_TP_COMBINE_TOKENS(__lttng_events_init__, TRACEPOINT_PROVIDER)(void);
+static void
 _TP_COMBINE_TOKENS(__lttng_events_init__, TRACEPOINT_PROVIDER)(void)
 {
        int ret;
@@ -602,7 +613,9 @@ _TP_COMBINE_TOKENS(__lttng_events_init__, TRACEPOINT_PROVIDER)(void)
        assert(!ret);
 }
 
-static void __attribute__((destructor))
+static void lttng_ust_notrace __attribute__((destructor))
+_TP_COMBINE_TOKENS(__lttng_events_exit__, TRACEPOINT_PROVIDER)(void);
+static void
 _TP_COMBINE_TOKENS(__lttng_events_exit__, TRACEPOINT_PROVIDER)(void)
 {
        ltt_probe_unregister(&_TP_COMBINE_TOKENS(__probe_desc___, TRACEPOINT_PROVIDER));
This page took 0.029538 seconds and 4 git commands to generate.