Group all syscall enums in one compile unit
authorFrancis Deslauriers <francis.deslauriers@efficios.com>
Wed, 5 May 2021 15:51:31 +0000 (11:51 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Thu, 6 May 2021 17:44:53 +0000 (13:44 -0400)
Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: Ic0189984d9bc70ae3f76af08bffd127500adad80

include/instrumentation/syscalls/headers/syscalls_pointers_override.h
include/lttng/events-reset.h
include/lttng/events.h
include/lttng/tracepoint-event-impl.h
src/Kbuild
src/lttng-syscalls-enum.c [new file with mode: 0644]

index cbd226aa454a7ff93d7155045488d3c15a6d11b6..000756db1e9dc64dd383d80bc399fe9cb899ebde 100644 (file)
@@ -457,6 +457,7 @@ SC_LTTNG_TRACEPOINT_EVENT_CODE(pselect6,
 )
 #endif /* defined(CONFIG_X86_32) || defined(CONFIG_X86_64) || defined(CONFIG_ARM64) || defined(CONFIG_ARM) */
 
+#ifdef LTTNG_CREATE_FIELD_METADATA
 #ifndef ONCE_LTTNG_TRACE_POLL_H
 #define ONCE_LTTNG_TRACE_POLL_H
 
@@ -464,6 +465,7 @@ SC_LTTNG_TRACEPOINT_EVENT_CODE(pselect6,
 #define POLL_FLAGS_PADDING_SIZE (sizeof(uint8_t) * BITS_PER_BYTE) - \
        ilog2(LTTNG_POLL_NRFLAGS - 1)
 
+#ifndef LTTNG_TRACEPOINT_TYPE_EXTERN
 /*
  * Only extract the values specified by iBCS2 for now.
  */
@@ -491,18 +493,30 @@ static const struct lttng_kernel_event_field *lttng_pollfd_flag_fields[] = {
                                false, false, false),
 };
 
+static_assert(((ARRAY_SIZE(lttng_pollfd_flag_fields) - 1) + POLL_FLAGS_PADDING_SIZE) == sizeof(uint8_t) * BITS_PER_BYTE);
+
+#endif /* LTTNG_TRACEPOINT_TYPE_EXTERN */
+
+LTTNG_TRACEPOINT_TYPE(PARAMS(const struct lttng_kernel_type_struct lttng_pollfd_flag_fields_struct),
+       PARAMS(lttng_kernel_static_type_struct_init( ARRAY_SIZE(lttng_pollfd_flag_fields), lttng_pollfd_flag_fields, 0)))
+
+#ifndef LTTNG_TRACEPOINT_TYPE_EXTERN
 static const struct lttng_kernel_event_field *lttng_pollfd_fields[] = {
        [0] = lttng_kernel_static_event_field("fd", lttng_kernel_static_type_integer_from_type(int, __BYTE_ORDER, 10),
                                false, false, false),
        [1] = lttng_kernel_static_event_field("raw_events", lttng_kernel_static_type_integer_from_type(uint16_t, __BYTE_ORDER, 16),
                                false, false, false),
        [2] = lttng_kernel_static_event_field("events",
-               lttng_kernel_static_type_struct(ARRAY_SIZE(lttng_pollfd_flag_fields),
-                       lttng_pollfd_flag_fields, 0),
+               (const struct lttng_kernel_type_common *) &lttng_pollfd_flag_fields_struct,
                false, false, false),
 };
+#endif /* LTTNG_TRACEPOINT_TYPE_EXTERN */
+
+LTTNG_TRACEPOINT_TYPE(PARAMS(const struct lttng_kernel_type_struct lttng_pollfd_fields_struct),
+       PARAMS(lttng_kernel_static_type_struct_init(ARRAY_SIZE(lttng_pollfd_fields), lttng_pollfd_fields, 0)))
 
 #endif /* ONCE_LTTNG_TRACE_POLL_H */
+#endif /* LTTNG_CREATE_FIELD_METADATA */
 
 #define LTTNG_SYSCALL_POLL_locvar                              \
        unsigned int fds_length, fds_max_len, alloc_fds;        \
@@ -510,9 +524,6 @@ static const struct lttng_kernel_event_field *lttng_pollfd_fields[] = {
        uint8_t overflow;
 
 #define LTTNG_SYSCALL_POLL_code_pre                            \
-       BUILD_BUG_ON(((ARRAY_SIZE(lttng_pollfd_flag_fields) - 1) +                      \
-                       POLL_FLAGS_PADDING_SIZE) !=                                     \
-                               sizeof(uint8_t) * BITS_PER_BYTE);                       \
        tp_locvar->fds = NULL;                                                          \
        tp_locvar->overflow = 0;                                                        \
                                                                                        \
@@ -570,7 +581,7 @@ end:                                                                                        \
                ctf_custom_field(                                                               \
                        ctf_custom_type(                                                        \
                                lttng_kernel_static_type_sequence("fds_length",                 \
-                                       lttng_kernel_static_type_struct(ARRAY_SIZE(lttng_pollfd_fields), lttng_pollfd_fields, 0), \
+                                       (const struct lttng_kernel_type_common *) &lttng_pollfd_fields_struct, \
                                        0,                                                      \
                                        none)                                                   \
                        ),                                                                      \
@@ -592,7 +603,7 @@ end:                                                                                        \
                ctf_custom_field(                                                               \
                        ctf_custom_type(                                                        \
                                lttng_kernel_static_type_sequence("fds_length",                 \
-                                       lttng_kernel_static_type_struct(ARRAY_SIZE(lttng_pollfd_fields), lttng_pollfd_fields, 0), \
+                                       (const struct lttng_kernel_type_common *) &lttng_pollfd_fields_struct, \
                                        0,                                                      \
                                        none)                                                   \
                        ),                                                                      \
@@ -699,6 +710,8 @@ SC_LTTNG_TRACEPOINT_ENUM(lttng_epoll_op,
        )
 )
 
+#ifdef LTTNG_CREATE_FIELD_METADATA
+
 #ifndef ONCE_LTTNG_TRACE_EPOLL_CTL_H
 #define ONCE_LTTNG_TRACE_EPOLL_CTL_H
 
@@ -706,6 +719,7 @@ SC_LTTNG_TRACEPOINT_ENUM(lttng_epoll_op,
 #define EPOLL_FLAGS_PADDING_SIZE (sizeof(uint8_t) * BITS_PER_BYTE) - \
        ilog2(LTTNG_EPOLL_NRFLAGS - 1)
 
+#ifndef LTTNG_TRACEPOINT_TYPE_EXTERN
 /*
  * Only extract the values specified by iBCS2 for now.
  */
@@ -734,7 +748,12 @@ static const struct lttng_kernel_event_field *lttng_epoll_ctl_events_fields[] =
                        lttng_kernel_static_type_integer(EPOLL_FLAGS_PADDING_SIZE, 1, 0, __LITTLE_ENDIAN, 10),
                        false, false, false),
 };
+#endif /* LTTNG_TRACEPOINT_TYPE_EXTERN */
+
+LTTNG_TRACEPOINT_TYPE(PARAMS(const struct lttng_kernel_type_struct lttng_epoll_ctl_events_fields_struct),
+       PARAMS(lttng_kernel_static_type_struct_init(ARRAY_SIZE(lttng_epoll_ctl_events_fields), lttng_epoll_ctl_events_fields, 0)))
 
+#ifndef LTTNG_TRACEPOINT_TYPE_EXTERN
 static const struct lttng_kernel_event_field *lttng_epoll_data_fields[] = {
        [0] = lttng_kernel_static_event_field("u64",
                        lttng_kernel_static_type_integer_from_type(uint64_t, __BYTE_ORDER, 16),
@@ -743,23 +762,30 @@ static const struct lttng_kernel_event_field *lttng_epoll_data_fields[] = {
                        lttng_kernel_static_type_integer_from_type(int, __BYTE_ORDER, 10),
                        false, false, false),
 };
+#endif /* LTTNG_TRACEPOINT_TYPE_EXTERN */
 
+LTTNG_TRACEPOINT_TYPE(PARAMS(const struct lttng_kernel_type_struct lttng_epoll_data_fields_struct),
+       PARAMS(lttng_kernel_static_type_struct_init(ARRAY_SIZE(lttng_epoll_data_fields), lttng_epoll_data_fields, 0)))
+
+#ifndef LTTNG_TRACEPOINT_TYPE_EXTERN
 static const struct lttng_kernel_event_field *epoll_ctl_fields[] = {
        [0] = lttng_kernel_static_event_field("data_union",
-               lttng_kernel_static_type_struct(ARRAY_SIZE(lttng_epoll_data_fields),
-                               lttng_epoll_data_fields,
-                               0),
+               (const struct lttng_kernel_type_common *) &lttng_epoll_data_fields_struct,
                false, false, false),
        [1] = lttng_kernel_static_event_field("raw_events",
                lttng_kernel_static_type_integer_from_type(uint32_t, __BYTE_ORDER, 16),
                false, false, false),
        [2] = lttng_kernel_static_event_field("events",
-               lttng_kernel_static_type_struct(ARRAY_SIZE(lttng_epoll_ctl_events_fields),
-                               lttng_epoll_ctl_events_fields,
-                               0),
+               (const struct lttng_kernel_type_common *) &lttng_epoll_ctl_events_fields_struct,
                false, false, false),
 };
+#endif /* LTTNG_TRACEPOINT_TYPE_EXTERN */
+
+LTTNG_TRACEPOINT_TYPE(PARAMS(const struct lttng_kernel_type_struct epoll_ctl_fields_struct),
+       PARAMS(lttng_kernel_static_type_struct_init(ARRAY_SIZE(epoll_ctl_fields), epoll_ctl_fields, 0)))
+
 #endif /* ONCE_LTTNG_TRACE_EPOLL_CTL_H */
+#endif /* LTTNG_CREATE_FIELD_METADATA */
 
 #if defined(CONFIG_X86_32) || defined(CONFIG_X86_64) || defined(CONFIG_ARM64) || defined(CONFIG_ARM)
 #define OVERRIDE_32_epoll_ctl
@@ -810,21 +836,31 @@ SC_LTTNG_TRACEPOINT_EVENT_CODE(epoll_ctl,
 )
 #endif /* defined(CONFIG_X86_32) || defined(CONFIG_X86_64) || defined(CONFIG_ARM64) || defined(CONFIG_ARM) */
 
+#ifdef LTTNG_CREATE_FIELD_METADATA
 #ifndef ONCE_LTTNG_TRACE_EPOLL_H
 #define ONCE_LTTNG_TRACE_EPOLL_H
 
+#ifndef LTTNG_TRACEPOINT_TYPE_EXTERN
 static const struct lttng_kernel_event_field *lttng_epoll_wait_fields[] = lttng_kernel_static_event_field_array(
        [0] = lttng_kernel_static_event_field("data_union",
-                       lttng_kernel_static_type_struct(ARRAY_SIZE(lttng_epoll_data_fields), lttng_epoll_data_fields, 0),
+                       (const struct lttng_kernel_type_common *) &lttng_epoll_data_fields_struct,
                        false, false, false),
        [1] = lttng_kernel_static_event_field("raw_events", lttng_kernel_static_type_integer_from_type(uint32_t, __BYTE_ORDER, 16),
                        false, false, false),
        [2] = lttng_kernel_static_event_field("events",
-                       lttng_kernel_static_type_struct(ARRAY_SIZE(lttng_epoll_ctl_events_fields), lttng_epoll_ctl_events_fields, 0),
+                       (const struct lttng_kernel_type_common *) &lttng_epoll_ctl_events_fields_struct,
                        false, false, false),
 );
 
+static_assert(((ARRAY_SIZE(lttng_epoll_ctl_events_fields) - 1) + EPOLL_FLAGS_PADDING_SIZE) == sizeof(uint8_t) * BITS_PER_BYTE);
+
+#endif /* LTTNG_TRACEPOINT_TYPE_EXTERN */
+
+LTTNG_TRACEPOINT_TYPE(PARAMS(const struct lttng_kernel_type_struct lttng_epoll_wait_fields_struct),
+       PARAMS(lttng_kernel_static_type_struct_init(ARRAY_SIZE(lttng_epoll_wait_fields), lttng_epoll_wait_fields, 0)))
+
 #endif /* ONCE_LTTNG_TRACE_EPOLL_H */
+#endif /* LTTNG_CREATE_FIELD_METADATA */
 
 #define LTTNG_SYSCALL_EPOLL_WAIT_locvar                \
        sc_out(                                 \
@@ -834,9 +870,6 @@ static const struct lttng_kernel_event_field *lttng_epoll_wait_fields[] = lttng_
        )
 
 #define LTTNG_SYSCALL_EPOLL_WAIT_code_pre                                      \
-       BUILD_BUG_ON(((ARRAY_SIZE(lttng_epoll_ctl_events_fields) - 1) +         \
-                       EPOLL_FLAGS_PADDING_SIZE) !=                            \
-                               sizeof(uint8_t) * BITS_PER_BYTE);               \
        sc_out({                                                                \
                int err;                                                        \
                unsigned long maxalloc;                                         \
index 31c828dcedb25ef3c9f60952de475f4864f39514..c4a43787e4186c4805e0c66fd98a4de269690f65 100644 (file)
@@ -22,6 +22,9 @@
 #undef LTTNG_TRACEPOINT_ENUM
 #define LTTNG_TRACEPOINT_ENUM(_name, _values)
 
+#undef LTTNG_TRACEPOINT_TYPE
+#define LTTNG_TRACEPOINT_TYPE(_prototype, _init)
+
 #undef TP_PROTO
 #define TP_PROTO(args...)
 
index b7267cd587a730d4b7e72b717a6eb97544414414..a04d0f2a9de586e522854d263fea35ca38998547 100644 (file)
@@ -142,6 +142,10 @@ struct lttng_kernel_event_field {
                        nofilter:1;     /* do not consider for filter */
 };
 
+#ifndef PARAMS
+#define PARAMS(args...)        args
+#endif
+
 #define lttng_kernel_static_type_integer(_size, _alignment, _signedness, _byte_order, _base)           \
        ((const struct lttng_kernel_type_common *) __LTTNG_COMPOUND_LITERAL(const struct lttng_kernel_type_integer, { \
                .parent = {                                                                             \
@@ -207,15 +211,20 @@ struct lttng_kernel_event_field {
                .encoding = lttng_kernel_string_encoding_##_encoding,                                   \
        }))
 
-#define lttng_kernel_static_type_struct(_nr_fields, _fields, _alignment)                               \
-       ((const struct lttng_kernel_type_common *) __LTTNG_COMPOUND_LITERAL(const struct lttng_kernel_type_struct, { \
+#define lttng_kernel_static_type_struct_init(_nr_fields, _fields, _alignment)                          \
+       {                                                                                               \
                .parent = {                                                                             \
                        .type = lttng_kernel_type_struct,                                               \
                },                                                                                      \
                .nr_fields = (_nr_fields),                                                              \
                .fields = _fields,                                                                      \
                .alignment = (_alignment),                                                              \
-       }))
+       }
+
+#define lttng_kernel_static_type_struct(_nr_fields, _fields, _alignment)                               \
+       ((const struct lttng_kernel_type_common *) __LTTNG_COMPOUND_LITERAL(const struct lttng_kernel_type_struct, \
+               lttng_kernel_static_type_struct_init(_nr_fields, PARAMS(_fields), _alignment)                   \
+       ))
 
 #define lttng_kernel_static_type_variant(_nr_choices, _choices, _tag_name, _alignment)                 \
        ((const struct lttng_kernel_type_common *) __LTTNG_COMPOUND_LITERAL(const struct lttng_kernel_type_variant, { \
index 4df71ff2b0b47a11e72fd380844ba5b4569b2a6d..32ecf29d81765c24bd65ead03a6e03871e9d3bce 100644 (file)
@@ -198,11 +198,13 @@ void __event_template_proto___##_name(void);
 #define TP_ENUM_VALUES(...)                                            \
        __VA_ARGS__
 
-#undef LTTNG_TRACEPOINT_ENUM
-#define LTTNG_TRACEPOINT_ENUM(_name, _values)                          \
+#ifndef LTTNG_TRACEPOINT_TYPE_EXTERN
+# undef LTTNG_TRACEPOINT_ENUM
+# define LTTNG_TRACEPOINT_ENUM(_name, _values)                         \
        static const struct lttng_kernel_enum_entry *__enum_values__##_name[] = { \
                _values                                                 \
        };
+#endif
 
 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
 
@@ -307,18 +309,37 @@ void __event_template_proto___##_name(void);
 #define LTTNG_TRACEPOINT_EVENT_CLASS_CODE(_name, _proto, _args, _locvar, _code_pre, _fields, _code_post) \
        LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS(_name, _locvar, _code_pre, PARAMS(_fields), _code_post)
 
-#undef LTTNG_TRACEPOINT_ENUM
-#define LTTNG_TRACEPOINT_ENUM(_name, _values)                                          \
-       static const struct lttng_kernel_enum_desc __enum_##_name = {                   \
-               .name = #_name,                                                         \
-               .entries = __enum_values__##_name,                                      \
-               .nr_entries = ARRAY_SIZE(__enum_values__##_name),                       \
-       };
+#ifdef LTTNG_TRACEPOINT_TYPE_EXTERN
+# undef LTTNG_TRACEPOINT_TYPE
+# define LTTNG_TRACEPOINT_TYPE(_prototype, _init)      \
+       extern _prototype;
+#elif defined (LTTNG_TRACEPOINT_TYPE_DEFINE_EXPORT)
+# define LTTNG_TRACEPOINT_TYPE_VISIBILITY __attribute__((visibility("hidden")))
+#else
+# define LTTNG_TRACEPOINT_TYPE_VISIBILITY static
+#endif
+
+#ifdef LTTNG_TRACEPOINT_TYPE_VISIBILITY
+# undef LTTNG_TRACEPOINT_TYPE
+# define LTTNG_TRACEPOINT_TYPE(_prototype, _init)      \
+       LTTNG_TRACEPOINT_TYPE_VISIBILITY _prototype = _init;
+#endif
+
+# undef LTTNG_TRACEPOINT_ENUM
+# define LTTNG_TRACEPOINT_ENUM(_name, _values)                                         \
+       LTTNG_TRACEPOINT_TYPE(PARAMS(const struct lttng_kernel_enum_desc __enum_##_name), \
+       PARAMS({                                                                        \
+                .name = #_name,                                                         \
+                .entries = __enum_values__##_name,                                      \
+                .nr_entries = ARRAY_SIZE(__enum_values__##_name),                       \
+        }))
 
 #define LTTNG_CREATE_FIELD_METADATA
 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
 #undef LTTNG_CREATE_FIELD_METADATA
 
+#undef LTTNG_TRACEPOINT_TYPE_VISIBILITY
+
 /*
  * Stage 3 of the trace events.
  *
index a5a840a7d900bb315cfdf34e7772469e4c026dfa..b03b4b93e59a05df1db7770c225d55e5bd820711 100644 (file)
@@ -90,6 +90,7 @@ lttng-wrapper-objs := wrapper/page_alloc.o \
 
 ifneq ($(CONFIG_HAVE_SYSCALL_TRACEPOINTS),)
   lttng-tracer-objs += lttng-syscalls.o
+  lttng-tracer-objs += lttng-syscalls-enum.o
 endif # CONFIG_HAVE_SYSCALL_TRACEPOINTS
 
 ifneq ($(CONFIG_PERF_EVENTS),)
diff --git a/src/lttng-syscalls-enum.c b/src/lttng-syscalls-enum.c
new file mode 100644 (file)
index 0000000..1bb60b1
--- /dev/null
@@ -0,0 +1,51 @@
+/* SPDX-License-Identifier: (GPL-2.0-only or LGPL-2.1-only)
+ *
+ * lttng-syscalls-enum.c
+ *
+ * LTTng syscall enum types
+ *
+ * Copyright (C) 2021 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ * Copyright (C) 2021 Francis Deslauriers <francis.deslauriers@efficios.com>
+ */
+
+#include <lttng/events.h>
+
+#define LTTNG_PACKAGE_BUILD
+#define CREATE_TRACE_POINTS
+#define TP_MODULE_NOINIT
+#define TRACE_INCLUDE_PATH instrumentation/syscalls/headers
+
+#define PARAMS(args...)        args
+
+#undef sc_exit
+#define sc_exit(...)
+#undef sc_in
+#define sc_in(...)     __VA_ARGS__
+#undef sc_out
+#define sc_out(...)
+#undef sc_inout
+#define sc_inout(...)  __VA_ARGS__
+
+#define TP_PROBE_CB(_template)
+#define SC_LTTNG_TRACEPOINT_EVENT(_name, _proto, _args, _fields)
+#define SC_LTTNG_TRACEPOINT_EVENT_CODE(_name, _proto, _args, _locvar, _code_pre, _fields, _code_post)
+#define SC_LTTNG_TRACEPOINT_EVENT_CLASS_NOARGS(_name, _fields)
+#define SC_LTTNG_TRACEPOINT_EVENT_INSTANCE_NOARGS(_template, _name)
+
+#define LTTNG_TRACEPOINT_TYPE_DEFINE_EXPORT
+
+#define SC_LTTNG_TRACEPOINT_ENUM(_name, _values) \
+       LTTNG_TRACEPOINT_ENUM(_name, PARAMS(_values))
+
+#undef TRACE_SYSTEM
+#define TRACE_SYSTEM syscall_entry_integers
+#define TRACE_INCLUDE_FILE syscalls_integers
+#include <instrumentation/syscalls/headers/syscalls_integers.h>
+#undef TRACE_INCLUDE_FILE
+#undef TRACE_SYSTEM
+#define TRACE_SYSTEM syscall_entry_pointers
+#define TRACE_INCLUDE_FILE syscalls_pointers
+#include <instrumentation/syscalls/headers/syscalls_pointers.h>
+#undef TRACE_INCLUDE_FILE
+#undef TRACE_SYSTEM
+#undef SC_LTTNG_TRACEPOINT_ENUM
This page took 0.032128 seconds and 4 git commands to generate.