Split syscall tracepoint generation in their own files
authorFrancis Deslauriers <francis.deslauriers@efficios.com>
Fri, 30 Apr 2021 21:30:48 +0000 (17:30 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Thu, 6 May 2021 17:51:31 +0000 (13:51 -0400)
This commit tracepoint generation of the 4 different types of syscalls
(entry, exit, entry_compat, and exit_compat) each in their own .c file.

The compilation time of the lttng-modules projects is currently
dominated by the compilation of the src/lttng-syscalls.o object.
This is caused by the extensive use of macros to generate tracepoint for
all syscalls. This also uses a lot of memory making the compilation of
the project tedious on system with low memory.

This allows for parallelization of the compilation which offers 2
improvements: Reduction of compilation time and reduction of the memory
usage.

In term of compilation time, on my 4 cpus laptop, I measured a 15sec
(20%) speedup over 10 runs when using all 4 cpus (make -j4).

On a larger machine (16 cpus), I measured 30sec (60%) speedup when using
all 16 cpus.

In term of memory usage, I was able to compile the project on a virtual
machine with 500MB of memory without hitting memory exhaustion errors.

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I025a4c36ef16b935be2a86f5b6649526752a7393

include/instrumentation/syscalls/headers/syscalls_pointers_override.h
include/lttng/tracepoint-event.h
src/Kbuild
src/lttng-syscalls-entry-compat-table.c [new file with mode: 0644]
src/lttng-syscalls-entry-table.c [new file with mode: 0644]
src/lttng-syscalls-exit-compat-table.c [new file with mode: 0644]
src/lttng-syscalls-exit-table.c [new file with mode: 0644]
src/lttng-syscalls.c
src/lttng-syscalls.h

index 000756db1e9dc64dd383d80bc399fe9cb899ebde..c84efdc900b39aa902674084dee57985f988e13a 100644 (file)
@@ -810,7 +810,7 @@ SC_LTTNG_TRACEPOINT_EVENT_CODE(epoll_ctl,
                sc_in(
                        ctf_custom_field(
                                ctf_custom_type(
-                                       lttng_kernel_static_type_struct(ARRAY_SIZE(epoll_ctl_fields), epoll_ctl_fields, 0)
+                                       (const struct lttng_kernel_type_common *) &epoll_ctl_fields_struct
                                ),
                                event,
                                ctf_custom_code(
@@ -914,7 +914,7 @@ LTTNG_TRACEPOINT_TYPE(PARAMS(const struct lttng_kernel_type_struct lttng_epoll_w
        ctf_custom_field(                                                               \
                ctf_custom_type(                                                        \
                        lttng_kernel_static_type_sequence("fds_length",                 \
-                               lttng_kernel_static_type_struct(ARRAY_SIZE(lttng_epoll_wait_fields), lttng_epoll_wait_fields, 0), \
+                               (const struct lttng_kernel_type_common *) &lttng_epoll_wait_fields_struct, \
                                0,                                                      \
                                none)                                                   \
                ),                                                                      \
index d3ad1b320372d4025be22bc7cf22246103ee754a..37da43475a9674fcef192d79a9dee2259644f7af 100644 (file)
 #define _LTTNG_INSTRUMENTATION(...)
 #endif
 
+#undef LTTNG_TRACEPOINT_EVENT
 #define LTTNG_TRACEPOINT_EVENT(name, proto, args, fields) \
        _LTTNG_INSTRUMENTATION(DECLARE_TRACE(name, PARAMS(proto), PARAMS(args)))
+#undef LTTNG_TRACEPOINT_EVENT_CODE
 #define LTTNG_TRACEPOINT_EVENT_CODE(name, proto, args, _locvar, _code_pre, fields, _code_post) \
        _LTTNG_INSTRUMENTATION(DECLARE_TRACE(name, PARAMS(proto), PARAMS(args)))
+#undef LTTNG_TRACEPOINT_EVENT_CODE_MAP
 #define LTTNG_TRACEPOINT_EVENT_CODE_MAP(name, map, proto, args, _locvar, _code_pre, fields, _code_post) \
        _LTTNG_INSTRUMENTATION(DECLARE_TRACE(name, PARAMS(proto), PARAMS(args)))
+#undef LTTNG_TRACEPOINT_EVENT_MAP
 #define LTTNG_TRACEPOINT_EVENT_MAP(name, map, proto, args, fields) \
        _LTTNG_INSTRUMENTATION(DECLARE_TRACE(name, PARAMS(proto), PARAMS(args)))
+#undef LTTNG_TRACEPOINT_EVENT_MAP_NOARGS
 #define LTTNG_TRACEPOINT_EVENT_MAP_NOARGS(name, map, fields) \
        _LTTNG_INSTRUMENTATION(DECLARE_TRACE_NOARGS(name))
 
+#undef LTTNG_TRACEPOINT_EVENT_CLASS
 #define LTTNG_TRACEPOINT_EVENT_CLASS(name, proto, args, fields)
+#undef LTTNG_TRACEPOINT_EVENT_CLASS_NOARGS
+#define LTTNG_TRACEPOINT_EVENT_CLASS_NOARGS(name, fields)
+#undef LTTNG_TRACEPOINT_EVENT_CLASS_CODE
 #define LTTNG_TRACEPOINT_EVENT_CLASS_CODE(_name, _proto, _args, _locvar, _code_pre, _fields, _code_post)
+#undef LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS
 #define LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS(_name, _locvar, _code_pre, _fields, _code_post)
 
+#undef LTTNG_TRACEPOINT_EVENT_INSTANCE
 #define LTTNG_TRACEPOINT_EVENT_INSTANCE(template, name, proto, args) \
        _LTTNG_INSTRUMENTATION(DECLARE_TRACE(name, PARAMS(proto), PARAMS(args)))
+#undef LTTNG_TRACEPOINT_EVENT_INSTANCE_NOARGS
 #define LTTNG_TRACEPOINT_EVENT_INSTANCE_NOARGS(template, name) \
        _LTTNG_INSTRUMENTATION(DECLARE_TRACE_NOARGS(name))
+#undef LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP
 #define LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP(_template, _name, _map, _proto, _args) \
        _LTTNG_INSTRUMENTATION(DECLARE_TRACE(name, PARAMS(proto), PARAMS(args)))
+#undef LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP_NOARGS
 #define LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP_NOARGS(_template, _name, _map) \
        _LTTNG_INSTRUMENTATION(DECLARE_TRACE_NOARGS(name))
 
+#undef LTTNG_TRACEPOINT_ENUM
 #define LTTNG_TRACEPOINT_ENUM(_name, _values)
 
+#undef LTTNG_TRACEPOINT_TYPE
+#define LTTNG_TRACEPOINT_TYPE(_prototype, _init)
+
 #endif /* LTTNG_TRACEPOINT_EVENT_H */
index b03b4b93e59a05df1db7770c225d55e5bd820711..0eba20d81b3db8f0fecf33a2ff024e5155048627 100644 (file)
@@ -90,6 +90,10 @@ lttng-wrapper-objs := wrapper/page_alloc.o \
 
 ifneq ($(CONFIG_HAVE_SYSCALL_TRACEPOINTS),)
   lttng-tracer-objs += lttng-syscalls.o
+  lttng-tracer-objs += lttng-syscalls-entry-table.o
+  lttng-tracer-objs += lttng-syscalls-entry-compat-table.o
+  lttng-tracer-objs += lttng-syscalls-exit-table.o
+  lttng-tracer-objs += lttng-syscalls-exit-compat-table.o
   lttng-tracer-objs += lttng-syscalls-enum.o
 endif # CONFIG_HAVE_SYSCALL_TRACEPOINTS
 
diff --git a/src/lttng-syscalls-entry-compat-table.c b/src/lttng-syscalls-entry-compat-table.c
new file mode 100644 (file)
index 0000000..2c2902b
--- /dev/null
@@ -0,0 +1,114 @@
+/* SPDX-License-Identifier: (GPL-2.0-only or LGPL-2.1-only)
+ *
+ * lttng-syscalls-entry-compat-table.c
+ *
+ * LTTng syscall entry compat probes.
+ *
+ * Copyright (C) 2010-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ * Copyright (C) 2021 Francis Deslauriers <francis.deslauriers@efficios.com>
+ */
+
+#include <wrapper/tracepoint.h>
+
+#include "lttng-syscalls.h"
+
+
+#ifdef IA32_NR_syscalls
+#define NR_compat_syscalls IA32_NR_syscalls
+#else
+#define NR_compat_syscalls NR_syscalls
+#endif
+
+/*
+ * Create LTTng tracepoint probes.
+ */
+#define LTTNG_PACKAGE_BUILD
+#define CREATE_TRACE_POINTS
+#define TP_MODULE_NOINIT
+#define TRACE_INCLUDE_PATH instrumentation/syscalls/headers
+
+#define PARAMS(args...)        args
+
+#define SC_ENTER
+
+#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 LTTNG_TRACEPOINT_TYPE_EXTERN
+
+#include <lttng/events-reset.h>
+
+/* Hijack probe callback for system call enter */
+#undef TP_PROBE_CB
+#define TP_PROBE_CB(_template)         &syscall_entry_event_probe
+#define LTTNG_SC_COMPAT
+#define SC_LTTNG_TRACEPOINT_EVENT(_name, _proto, _args, _fields) \
+       LTTNG_TRACEPOINT_EVENT(compat_syscall_entry_##_name, PARAMS(_proto), PARAMS(_args), \
+               PARAMS(_fields))
+#define SC_LTTNG_TRACEPOINT_EVENT_CODE(_name, _proto, _args, _locvar, _code_pre, _fields, _code_post) \
+       LTTNG_TRACEPOINT_EVENT_CODE(compat_syscall_entry_##_name, PARAMS(_proto), PARAMS(_args), \
+               PARAMS(_locvar), PARAMS(_code_pre),                             \
+               PARAMS(_fields), PARAMS(_code_post))
+#define SC_LTTNG_TRACEPOINT_EVENT_CLASS_NOARGS(_name, _fields) \
+       LTTNG_TRACEPOINT_EVENT_CLASS_NOARGS(compat_syscall_entry_##_name, PARAMS(_fields))
+#define SC_LTTNG_TRACEPOINT_EVENT_INSTANCE_NOARGS(_template, _name)            \
+       LTTNG_TRACEPOINT_EVENT_INSTANCE_NOARGS(compat_syscall_entry_##_template, compat_syscall_entry_##_name)
+
+#define SC_LTTNG_TRACEPOINT_ENUM(_name, _values) \
+       LTTNG_TRACEPOINT_ENUM(_name, PARAMS(_values))
+#undef TRACE_SYSTEM
+#define TRACE_SYSTEM compat_syscall_entry_integers
+#define TRACE_INCLUDE_FILE compat_syscalls_integers
+#include <instrumentation/syscalls/headers/syscalls_integers.h>
+#undef TRACE_INCLUDE_FILE
+#undef TRACE_SYSTEM
+#define TRACE_SYSTEM compat_syscall_entry_pointers
+#define TRACE_INCLUDE_FILE compat_syscalls_pointers
+#include <instrumentation/syscalls/headers/syscalls_pointers.h>
+#undef TRACE_INCLUDE_FILE
+#undef TRACE_SYSTEM
+#undef SC_LTTNG_TRACEPOINT_ENUM
+#undef SC_LTTNG_TRACEPOINT_EVENT_CODE
+#undef SC_LTTNG_TRACEPOINT_EVENT
+#undef SC_LTTNG_TRACEPOINT_EVENT_CLASS_NOARGS
+#undef SC_LTTNG_TRACEPOINT_EVENT_INSTANCE_NOARGS
+#undef TP_PROBE_CB
+
+#undef _TRACE_SYSCALLS_INTEGERS_H
+#undef _TRACE_SYSCALLS_POINTERS_H
+#undef LTTNG_SC_COMPAT
+
+#define CREATE_SYSCALL_TABLE
+
+#undef sc_exit
+#define sc_exit(...)
+
+#undef TRACE_SYSCALL_TABLE
+#define TRACE_SYSCALL_TABLE(_template, _name, _nr, _nrargs)    \
+       [ _nr ] = {                                             \
+               .event_func = __event_probe__compat_syscall_entry_##_template, \
+               .nrargs = (_nrargs),                            \
+               .fields = __event_fields___compat_syscall_entry_##_template, \
+               .desc = &__event_desc___compat_syscall_entry_##_name, \
+       },
+
+/* Event compat syscall enter table */
+const struct trace_syscall_entry _compat_sc_table[] = {
+#include <instrumentation/syscalls/headers/compat_syscalls_integers.h>
+#include <instrumentation/syscalls/headers/compat_syscalls_pointers.h>
+};
+
+const struct trace_syscall_table compat_sc_table = {
+       .table = _compat_sc_table,
+       .len = ARRAY_SIZE(_compat_sc_table),
+};
+
+#undef SC_ENTER
+
+#undef CREATE_SYSCALL_TABLE
diff --git a/src/lttng-syscalls-entry-table.c b/src/lttng-syscalls-entry-table.c
new file mode 100644 (file)
index 0000000..7324f48
--- /dev/null
@@ -0,0 +1,111 @@
+/* SPDX-License-Identifier: (GPL-2.0-only or LGPL-2.1-only)
+ *
+ * lttng-syscalls-entry-table.c
+ *
+ * LTTng syscall entry probes.
+ *
+ * Copyright (C) 2010-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ * Copyright (C) 2021 Francis Deslauriers <francis.deslauriers@efficios.com>
+ */
+
+#include <wrapper/tracepoint.h>
+
+#include "lttng-syscalls.h"
+
+
+#ifdef IA32_NR_syscalls
+#define NR_compat_syscalls IA32_NR_syscalls
+#else
+#define NR_compat_syscalls NR_syscalls
+#endif
+
+/*
+ * Create LTTng tracepoint probes.
+ */
+#define LTTNG_PACKAGE_BUILD
+#define CREATE_TRACE_POINTS
+#define TP_MODULE_NOINIT
+#define TRACE_INCLUDE_PATH instrumentation/syscalls/headers
+
+#define PARAMS(args...)        args
+
+#define SC_ENTER
+
+#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 LTTNG_TRACEPOINT_TYPE_EXTERN
+
+#include <lttng/events-reset.h>
+
+/* Hijack probe callback for system call enter */
+#undef TP_PROBE_CB
+#define TP_PROBE_CB(_template)         &syscall_entry_event_probe
+#define SC_LTTNG_TRACEPOINT_EVENT(_name, _proto, _args, _fields) \
+       LTTNG_TRACEPOINT_EVENT(syscall_entry_##_name, PARAMS(_proto), PARAMS(_args), \
+               PARAMS(_fields))
+#define SC_LTTNG_TRACEPOINT_EVENT_CODE(_name, _proto, _args, _locvar, _code_pre, _fields, _code_post) \
+       LTTNG_TRACEPOINT_EVENT_CODE(syscall_entry_##_name, PARAMS(_proto), PARAMS(_args), \
+               PARAMS(_locvar), PARAMS(_code_pre),                             \
+               PARAMS(_fields), PARAMS(_code_post))
+#define SC_LTTNG_TRACEPOINT_EVENT_CLASS_NOARGS(_name, _fields) \
+       LTTNG_TRACEPOINT_EVENT_CLASS_NOARGS(syscall_entry_##_name, PARAMS(_fields))
+#define SC_LTTNG_TRACEPOINT_EVENT_INSTANCE_NOARGS(_template, _name)            \
+       LTTNG_TRACEPOINT_EVENT_INSTANCE_NOARGS(syscall_entry_##_template, syscall_entry_##_name)
+
+#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
+#undef SC_LTTNG_TRACEPOINT_EVENT_CODE
+#undef SC_LTTNG_TRACEPOINT_EVENT
+#undef SC_LTTNG_TRACEPOINT_EVENT_CLASS_NOARGS
+#undef SC_LTTNG_TRACEPOINT_EVENT_INSTANCE_NOARGS
+#undef TP_PROBE_CB
+#undef _TRACE_SYSCALLS_INTEGERS_H
+#undef _TRACE_SYSCALLS_POINTERS_H
+
+#define CREATE_SYSCALL_TABLE
+
+#undef sc_exit
+#define sc_exit(...)
+
+#undef TRACE_SYSCALL_TABLE
+#define TRACE_SYSCALL_TABLE(_template, _name, _nr, _nrargs)    \
+       [ _nr ] = {                                             \
+               .event_func = __event_probe__syscall_entry_##_template, \
+               .nrargs = (_nrargs),                            \
+               .fields = __event_fields___syscall_entry_##_template, \
+               .desc = &__event_desc___syscall_entry_##_name,  \
+       },
+
+/* Event syscall enter tracing table */
+static const struct trace_syscall_entry _sc_table[] = {
+#include <instrumentation/syscalls/headers/syscalls_integers.h>
+#include <instrumentation/syscalls/headers/syscalls_pointers.h>
+};
+
+const struct trace_syscall_table sc_table = {
+       .table = _sc_table,
+       .len = ARRAY_SIZE(_sc_table),
+};
+
+#undef SC_ENTER
+
+#undef CREATE_SYSCALL_TABLE
diff --git a/src/lttng-syscalls-exit-compat-table.c b/src/lttng-syscalls-exit-compat-table.c
new file mode 100644 (file)
index 0000000..58fc327
--- /dev/null
@@ -0,0 +1,113 @@
+/* SPDX-License-Identifier: (GPL-2.0-only or LGPL-2.1-only)
+ *
+ * lttng-syscalls-exit-compat-table.c
+ *
+ * LTTng syscall exit compat probes.
+ *
+ * Copyright (C) 2010-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ * Copyright (C) 2021 Francis Deslauriers <francis.deslauriers@efficios.com>
+ */
+
+#include <wrapper/tracepoint.h>
+
+#include "lttng-syscalls.h"
+
+
+#ifdef IA32_NR_syscalls
+#define NR_compat_syscalls IA32_NR_syscalls
+#else
+#define NR_compat_syscalls NR_syscalls
+#endif
+
+/*
+ * Create LTTng tracepoint probes.
+ */
+#define LTTNG_PACKAGE_BUILD
+#define CREATE_TRACE_POINTS
+#define TP_MODULE_NOINIT
+#define TRACE_INCLUDE_PATH instrumentation/syscalls/headers
+
+#define PARAMS(args...)        args
+
+#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__
+#undef sc_exit
+#define sc_exit(...)           __VA_ARGS__
+
+#define LTTNG_TRACEPOINT_TYPE_EXTERN
+
+#include <lttng/events-reset.h>
+
+/* Hijack probe callback for system call compat exit */
+#undef TP_PROBE_CB
+#define LTTNG_SC_COMPAT
+#define TP_PROBE_CB(_template)         &syscall_exit_event_probe
+#define SC_LTTNG_TRACEPOINT_EVENT(_name, _proto, _args, _fields) \
+       LTTNG_TRACEPOINT_EVENT(compat_syscall_exit_##_name, PARAMS(_proto), PARAMS(_args), \
+               PARAMS(_fields))
+#define SC_LTTNG_TRACEPOINT_EVENT_CODE(_name, _proto, _args, _locvar, _code_pre, _fields, _code_post) \
+       LTTNG_TRACEPOINT_EVENT_CODE(compat_syscall_exit_##_name, PARAMS(_proto), PARAMS(_args), \
+               PARAMS(_locvar), PARAMS(_code_pre),                             \
+               PARAMS(_fields), PARAMS(_code_post))
+#define SC_LTTNG_TRACEPOINT_EVENT_CLASS_NOARGS(_name, _fields) \
+       LTTNG_TRACEPOINT_EVENT_CLASS_NOARGS(compat_syscall_exit_##_name, PARAMS(_fields))
+#define SC_LTTNG_TRACEPOINT_EVENT_INSTANCE_NOARGS(_template, _name)            \
+       LTTNG_TRACEPOINT_EVENT_INSTANCE_NOARGS(compat_syscall_exit_##_template, compat_syscall_exit_##_name)
+
+#define SC_LTTNG_TRACEPOINT_ENUM(_name, _values) \
+       LTTNG_TRACEPOINT_ENUM(_name, PARAMS(_values))
+#undef TRACE_SYSTEM
+#define TRACE_SYSTEM compat_syscall_exit_integers
+#define TRACE_INCLUDE_FILE compat_syscalls_integers
+#include <instrumentation/syscalls/headers/syscalls_integers.h>
+#undef TRACE_INCLUDE_FILE
+#undef TRACE_SYSTEM
+#define TRACE_SYSTEM compat_syscall_exit_pointers
+#define TRACE_INCLUDE_FILE compat_syscalls_pointers
+#include <instrumentation/syscalls/headers/syscalls_pointers.h>
+#undef TRACE_INCLUDE_FILE
+#undef TRACE_SYSTEM
+#undef SC_LTTNG_TRACEPOINT_ENUM
+#undef SC_LTTNG_TRACEPOINT_EVENT_CODE
+#undef SC_LTTNG_TRACEPOINT_EVENT
+#undef SC_LTTNG_TRACEPOINT_EVENT_CLASS_NOARGS
+#undef SC_LTTNG_TRACEPOINT_EVENT_INSTANCE_NOARGS
+#undef TP_PROBE_CB
+#undef _TRACE_SYSCALLS_INTEGERS_H
+#undef _TRACE_SYSCALLS_POINTERS_H
+#undef LTTNG_SC_COMPAT
+
+#define CREATE_SYSCALL_TABLE
+
+#undef sc_exit
+#define sc_exit(...)
+
+#undef TRACE_SYSCALL_TABLE
+#define TRACE_SYSCALL_TABLE(_template, _name, _nr, _nrargs)    \
+       [ _nr ] = {                                             \
+               .event_func = __event_probe__compat_syscall_exit_##_template, \
+               .nrargs = (_nrargs),                            \
+               .fields = __event_fields___compat_syscall_exit_##_template, \
+               .desc = &__event_desc___compat_syscall_exit_##_name, \
+       },
+
+/* Event compat syscall exit table */
+const struct trace_syscall_entry _compat_sc_exit_table[] = {
+#include <instrumentation/syscalls/headers/compat_syscalls_integers.h>
+#include <instrumentation/syscalls/headers/compat_syscalls_pointers.h>
+};
+
+const struct trace_syscall_table compat_sc_exit_table = {
+       .table = _compat_sc_exit_table,
+       .len = ARRAY_SIZE(_compat_sc_exit_table),
+};
+
+#undef SC_EXIT
+
+#undef CREATE_SYSCALL_TABLE
diff --git a/src/lttng-syscalls-exit-table.c b/src/lttng-syscalls-exit-table.c
new file mode 100644 (file)
index 0000000..aaaa331
--- /dev/null
@@ -0,0 +1,110 @@
+/* SPDX-License-Identifier: (GPL-2.0-only or LGPL-2.1-only)
+ *
+ * lttng-syscalls-exit-table.c
+ *
+ * LTTng syscall exit probes.
+ *
+ * Copyright (C) 2010-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ * Copyright (C) 2021 Francis Deslauriers <francis.deslauriers@efficios.com>
+ */
+
+#include <wrapper/tracepoint.h>
+
+#include "lttng-syscalls.h"
+
+
+#ifdef IA32_NR_syscalls
+#define NR_compat_syscalls IA32_NR_syscalls
+#else
+#define NR_compat_syscalls NR_syscalls
+#endif
+
+/*
+ * Create LTTng tracepoint probes.
+ */
+#define LTTNG_PACKAGE_BUILD
+#define CREATE_TRACE_POINTS
+#define TP_MODULE_NOINIT
+#define TRACE_INCLUDE_PATH instrumentation/syscalls/headers
+
+#define PARAMS(args...)        args
+
+#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__
+#undef sc_exit
+#define sc_exit(...)           __VA_ARGS__
+
+#define LTTNG_TRACEPOINT_TYPE_EXTERN
+
+#include <lttng/events-reset.h>
+
+/* Hijack probe callback for system call enter */
+#undef TP_PROBE_CB
+#define TP_PROBE_CB(_template)         &syscall_exit_event_probe
+#define SC_LTTNG_TRACEPOINT_EVENT(_name, _proto, _args, _fields) \
+       LTTNG_TRACEPOINT_EVENT(syscall_exit_##_name, PARAMS(_proto), PARAMS(_args), \
+               PARAMS(_fields))
+#define SC_LTTNG_TRACEPOINT_EVENT_CODE(_name, _proto, _args, _locvar, _code_pre, _fields, _code_post) \
+       LTTNG_TRACEPOINT_EVENT_CODE(syscall_exit_##_name, PARAMS(_proto), PARAMS(_args), \
+               PARAMS(_locvar), PARAMS(_code_pre),                             \
+               PARAMS(_fields), PARAMS(_code_post))
+#define SC_LTTNG_TRACEPOINT_EVENT_CLASS_NOARGS(_name, _fields) \
+       LTTNG_TRACEPOINT_EVENT_CLASS_NOARGS(syscall_exit_##_name, PARAMS(_fields))
+#define SC_LTTNG_TRACEPOINT_EVENT_INSTANCE_NOARGS(_template, _name)            \
+       LTTNG_TRACEPOINT_EVENT_INSTANCE_NOARGS(syscall_exit_##_template, syscall_exit_##_name)
+
+#define SC_LTTNG_TRACEPOINT_ENUM(_name, _values) \
+       LTTNG_TRACEPOINT_ENUM(_name, PARAMS(_values))
+#undef TRACE_SYSTEM
+#define TRACE_SYSTEM syscall_exit_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_exit_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
+#undef SC_LTTNG_TRACEPOINT_EVENT_CODE
+#undef SC_LTTNG_TRACEPOINT_EVENT
+#undef SC_LTTNG_TRACEPOINT_EVENT_CLASS_NOARGS
+#undef SC_LTTNG_TRACEPOINT_EVENT_INSTANCE_NOARGS
+#undef TP_PROBE_CB
+#undef _TRACE_SYSCALLS_INTEGERS_H
+#undef _TRACE_SYSCALLS_POINTERS_H
+
+#define CREATE_SYSCALL_TABLE
+
+#undef sc_exit
+#define sc_exit(...)
+
+#undef TRACE_SYSCALL_TABLE
+#define TRACE_SYSCALL_TABLE(_template, _name, _nr, _nrargs)    \
+       [ _nr ] = {                                             \
+               .event_func = __event_probe__syscall_exit_##_template, \
+               .nrargs = (_nrargs),                            \
+               .fields = __event_fields___syscall_exit_##_template, \
+               .desc = &__event_desc___syscall_exit_##_name,   \
+       },
+
+/* Event syscall enter tracing table */
+static const struct trace_syscall_entry _sc_exit_table[] = {
+#include <instrumentation/syscalls/headers/syscalls_integers.h>
+#include <instrumentation/syscalls/headers/syscalls_pointers.h>
+};
+
+const struct trace_syscall_table sc_exit_table = {
+       .table = _sc_exit_table,
+       .len = ARRAY_SIZE(_sc_exit_table),
+};
+#undef SC_EXIT
+
+#undef CREATE_SYSCALL_TABLE
index 2b469cb5b1c3fbb59a967b53e8a0d5fd6938a6f2..6b52b69bbf7dd2c3d0f50e2dfaa6b2f2d96a160f 100644 (file)
@@ -62,15 +62,11 @@ enum sc_type {
 #define SYSCALL_EXIT_STR               __stringify(SYSCALL_EXIT_TOK)
 #define COMPAT_SYSCALL_EXIT_STR                __stringify(COMPAT_SYSCALL_EXIT_TOK)
 
-static
 void syscall_entry_event_probe(void *__data, struct pt_regs *regs, long id);
-static
 void syscall_exit_event_probe(void *__data, struct pt_regs *regs, long ret);
 
-static
 void syscall_entry_event_notifier_probe(void *__data, struct pt_regs *regs,
                long id);
-static
 void syscall_exit_event_notifier_probe(void *__data, struct pt_regs *regs,
                long ret);
 
@@ -120,275 +116,15 @@ typedef __kernel_old_time_t time_t;
 #include <instrumentation/syscalls/headers/syscalls_unknown.h>
 #undef TRACE_SYSTEM
 
-#define SC_ENTER
-
-#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__
-
-/* Hijack probe callback for system call enter */
-#undef TP_PROBE_CB
-#define TP_PROBE_CB(_template)         &syscall_entry_event_probe
-#define SC_LTTNG_TRACEPOINT_EVENT(_name, _proto, _args, _fields) \
-       LTTNG_TRACEPOINT_EVENT(syscall_entry_##_name, PARAMS(_proto), PARAMS(_args), \
-               PARAMS(_fields))
-#define SC_LTTNG_TRACEPOINT_EVENT_CODE(_name, _proto, _args, _locvar, _code_pre, _fields, _code_post) \
-       LTTNG_TRACEPOINT_EVENT_CODE(syscall_entry_##_name, PARAMS(_proto), PARAMS(_args), \
-               PARAMS(_locvar), PARAMS(_code_pre),                             \
-               PARAMS(_fields), PARAMS(_code_post))
-#define SC_LTTNG_TRACEPOINT_EVENT_CLASS_NOARGS(_name, _fields) \
-       LTTNG_TRACEPOINT_EVENT_CLASS_NOARGS(syscall_entry_##_name, PARAMS(_fields))
-#define SC_LTTNG_TRACEPOINT_EVENT_INSTANCE_NOARGS(_template, _name)            \
-       LTTNG_TRACEPOINT_EVENT_INSTANCE_NOARGS(syscall_entry_##_template, syscall_entry_##_name)
-/* Enumerations only defined at first inclusion. */
-#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
-#undef SC_LTTNG_TRACEPOINT_EVENT_CODE
-#undef SC_LTTNG_TRACEPOINT_EVENT
-#undef SC_LTTNG_TRACEPOINT_EVENT_CLASS_NOARGS
-#undef SC_LTTNG_TRACEPOINT_EVENT_INSTANCE_NOARGS
-#undef TP_PROBE_CB
-#undef _TRACE_SYSCALLS_INTEGERS_H
-#undef _TRACE_SYSCALLS_POINTERS_H
-
-/* Hijack probe callback for compat system call enter */
-#define TP_PROBE_CB(_template)         &syscall_entry_event_probe
-#define LTTNG_SC_COMPAT
-#define SC_LTTNG_TRACEPOINT_EVENT(_name, _proto, _args, _fields) \
-       LTTNG_TRACEPOINT_EVENT(compat_syscall_entry_##_name, PARAMS(_proto), PARAMS(_args), \
-               PARAMS(_fields))
-#define SC_LTTNG_TRACEPOINT_EVENT_CODE(_name, _proto, _args, _locvar, _code_pre, _fields, _code_post) \
-       LTTNG_TRACEPOINT_EVENT_CODE(compat_syscall_entry_##_name, PARAMS(_proto), PARAMS(_args), \
-               PARAMS(_locvar), PARAMS(_code_pre), PARAMS(_fields), PARAMS(_code_post))
-#define SC_LTTNG_TRACEPOINT_EVENT_CLASS_NOARGS(_name, _fields) \
-       LTTNG_TRACEPOINT_EVENT_CLASS_NOARGS(compat_syscall_entry_##_name, PARAMS(_fields))
-#define SC_LTTNG_TRACEPOINT_EVENT_INSTANCE_NOARGS(_template, _name)            \
-       LTTNG_TRACEPOINT_EVENT_INSTANCE_NOARGS(compat_syscall_entry_##_template, \
-               compat_syscall_entry_##_name)
-/* Enumerations only defined at inital inclusion (not here). */
-#define SC_LTTNG_TRACEPOINT_ENUM(_name, _values)
-#define TRACE_SYSTEM compat_syscall_entry_integers
-#define TRACE_INCLUDE_FILE compat_syscalls_integers
-#include <instrumentation/syscalls/headers/compat_syscalls_integers.h>
-#undef TRACE_INCLUDE_FILE
-#undef TRACE_SYSTEM
-#define TRACE_SYSTEM compat_syscall_entry_pointers
-#define TRACE_INCLUDE_FILE compat_syscalls_pointers
-#include <instrumentation/syscalls/headers/compat_syscalls_pointers.h>
-#undef TRACE_INCLUDE_FILE
-#undef TRACE_SYSTEM
-#undef SC_LTTNG_TRACEPOINT_ENUM
-#undef SC_LTTNG_TRACEPOINT_EVENT_CODE
-#undef SC_LTTNG_TRACEPOINT_EVENT
-#undef SC_LTTNG_TRACEPOINT_EVENT_CLASS_NOARGS
-#undef SC_LTTNG_TRACEPOINT_EVENT_INSTANCE_NOARGS
-#undef TP_PROBE_CB
-#undef _TRACE_SYSCALLS_INTEGERS_H
-#undef _TRACE_SYSCALLS_POINTERS_H
-#undef LTTNG_SC_COMPAT
-
-#undef SC_ENTER
-
-#define SC_EXIT
-
-#undef sc_exit
-#define sc_exit(...)           __VA_ARGS__
-#undef sc_in
-#define sc_in(...)
-#undef sc_out
-#define sc_out(...)            __VA_ARGS__
-#undef sc_inout
-#define sc_inout(...)          __VA_ARGS__
-
-/* Hijack probe callback for system call exit */
-#define TP_PROBE_CB(_template)         &syscall_exit_event_probe
-#define SC_LTTNG_TRACEPOINT_EVENT(_name, _proto, _args, _fields) \
-       LTTNG_TRACEPOINT_EVENT(syscall_exit_##_name, PARAMS(_proto), PARAMS(_args), \
-               PARAMS(_fields))
-#define SC_LTTNG_TRACEPOINT_EVENT_CODE(_name, _proto, _args, _locvar, _code_pre, _fields, _code_post) \
-       LTTNG_TRACEPOINT_EVENT_CODE(syscall_exit_##_name, PARAMS(_proto), PARAMS(_args), \
-               PARAMS(_locvar), PARAMS(_code_pre), PARAMS(_fields), PARAMS(_code_post))
-#define SC_LTTNG_TRACEPOINT_EVENT_CLASS_NOARGS(_name, _fields) \
-       LTTNG_TRACEPOINT_EVENT_CLASS_NOARGS(syscall_exit_##_name, PARAMS(_fields))
-#define SC_LTTNG_TRACEPOINT_EVENT_INSTANCE_NOARGS(_template, _name)            \
-       LTTNG_TRACEPOINT_EVENT_INSTANCE_NOARGS(syscall_exit_##_template,        \
-               syscall_exit_##_name)
-/* Enumerations only defined at inital inclusion (not here). */
-#define SC_LTTNG_TRACEPOINT_ENUM(_name, _values)
-#define TRACE_SYSTEM syscall_exit_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_exit_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
-#undef SC_LTTNG_TRACEPOINT_EVENT_CODE
-#undef SC_LTTNG_TRACEPOINT_EVENT
-#undef SC_LTTNG_TRACEPOINT_EVENT_CLASS_NOARGS
-#undef SC_LTTNG_TRACEPOINT_EVENT_INSTANCE_NOARGS
-#undef TP_PROBE_CB
-#undef _TRACE_SYSCALLS_INTEGERS_H
-#undef _TRACE_SYSCALLS_POINTERS_H
-
-
-/* Hijack probe callback for compat system call exit */
-#define TP_PROBE_CB(_template)         &syscall_exit_event_probe
-#define LTTNG_SC_COMPAT
-#define SC_LTTNG_TRACEPOINT_EVENT(_name, _proto, _args, _fields) \
-       LTTNG_TRACEPOINT_EVENT(compat_syscall_exit_##_name, PARAMS(_proto), PARAMS(_args), \
-               PARAMS(_fields))
-#define SC_LTTNG_TRACEPOINT_EVENT_CODE(_name, _proto, _args, _locvar, _code_pre, _fields, _code_post) \
-       LTTNG_TRACEPOINT_EVENT_CODE(compat_syscall_exit_##_name, PARAMS(_proto), PARAMS(_args), \
-               PARAMS(_locvar), PARAMS(_code_pre), PARAMS(_fields), PARAMS(_code_post))
-#define SC_LTTNG_TRACEPOINT_EVENT_CLASS_NOARGS(_name, _fields) \
-       LTTNG_TRACEPOINT_EVENT_CLASS_NOARGS(compat_syscall_exit_##_name, PARAMS(_fields))
-#define SC_LTTNG_TRACEPOINT_EVENT_INSTANCE_NOARGS(_template, _name)            \
-       LTTNG_TRACEPOINT_EVENT_INSTANCE_NOARGS(compat_syscall_exit_##_template, \
-               compat_syscall_exit_##_name)
-/* Enumerations only defined at inital inclusion (not here). */
-#define SC_LTTNG_TRACEPOINT_ENUM(_name, _values)
-#define TRACE_SYSTEM compat_syscall_exit_integers
-#define TRACE_INCLUDE_FILE compat_syscalls_integers
-#include <instrumentation/syscalls/headers/compat_syscalls_integers.h>
-#undef TRACE_INCLUDE_FILE
-#undef TRACE_SYSTEM
-#define TRACE_SYSTEM compat_syscall_exit_pointers
-#define TRACE_INCLUDE_FILE compat_syscalls_pointers
-#include <instrumentation/syscalls/headers/compat_syscalls_pointers.h>
-#undef TRACE_INCLUDE_FILE
-#undef TRACE_SYSTEM
-#undef SC_LTTNG_TRACEPOINT_ENUM
-#undef SC_LTTNG_TRACEPOINT_EVENT_CODE
-#undef SC_LTTNG_TRACEPOINT_EVENT
-#undef SC_LTTNG_TRACEPOINT_EVENT_CLASS_NOARGS
-#undef SC_LTTNG_TRACEPOINT_EVENT_INSTANCE_NOARGS
 #undef TP_PROBE_CB
-#undef _TRACE_SYSCALLS_INTEGERS_H
-#undef _TRACE_SYSCALLS_POINTERS_H
-#undef LTTNG_SC_COMPAT
-
-#undef SC_EXIT
-
-#undef TP_MODULE_NOINIT
-#undef LTTNG_PACKAGE_BUILD
-#undef CREATE_TRACE_POINTS
-
-#define CREATE_SYSCALL_TABLE
-
-#define SC_ENTER
 
-#undef sc_exit
-#define sc_exit(...)
-
-#undef TRACE_SYSCALL_TABLE
-#define TRACE_SYSCALL_TABLE(_template, _name, _nr, _nrargs)    \
-       [ _nr ] = {                                             \
-               .event_func = __event_probe__syscall_entry_##_template, \
-               .nrargs = (_nrargs),                            \
-               .fields = __event_fields___syscall_entry_##_template, \
-               .desc = &__event_desc___syscall_entry_##_name,  \
-       },
-
-/* Event syscall enter tracing table */
-static const struct trace_syscall_entry _sc_table[] = {
-#include <instrumentation/syscalls/headers/syscalls_integers.h>
-#include <instrumentation/syscalls/headers/syscalls_pointers.h>
-};
-
-
-const struct trace_syscall_table sc_table = {
-       .table = _sc_table,
-       .len = ARRAY_SIZE(_sc_table),
-};
-
-#undef TRACE_SYSCALL_TABLE
-#define TRACE_SYSCALL_TABLE(_template, _name, _nr, _nrargs)    \
-       [ _nr ] = {                                             \
-               .event_func = __event_probe__compat_syscall_entry_##_template, \
-               .nrargs = (_nrargs),                            \
-               .fields = __event_fields___compat_syscall_entry_##_template, \
-               .desc = &__event_desc___compat_syscall_entry_##_name, \
-       },
-
-/* Event compat syscall enter table */
-const struct trace_syscall_entry _compat_sc_table[] = {
-#include <instrumentation/syscalls/headers/compat_syscalls_integers.h>
-#include <instrumentation/syscalls/headers/compat_syscalls_pointers.h>
-};
-
-const struct trace_syscall_table compat_sc_table = {
-       .table = _compat_sc_table,
-       .len = ARRAY_SIZE(_compat_sc_table),
-};
-
-#undef SC_ENTER
-
-#define SC_EXIT
-
-#undef sc_exit
-#define sc_exit(...)           __VA_ARGS__
-
-#undef TRACE_SYSCALL_TABLE
-#define TRACE_SYSCALL_TABLE(_template, _name, _nr, _nrargs)    \
-       [ _nr ] = {                                             \
-               .event_func = __event_probe__syscall_exit_##_template, \
-               .nrargs = (_nrargs),                            \
-               .fields = __event_fields___syscall_exit_##_template, \
-               .desc = &__event_desc___syscall_exit_##_name, \
-       },
+extern const struct trace_syscall_table sc_table;
+extern const struct trace_syscall_table compat_sc_table;
 
 /* Event syscall exit table */
-static const struct trace_syscall_entry _sc_exit_table[] = {
-#include <instrumentation/syscalls/headers/syscalls_integers.h>
-#include <instrumentation/syscalls/headers/syscalls_pointers.h>
-};
-
-const struct trace_syscall_table sc_exit_table = {
-       .table = _sc_exit_table,
-       .len = ARRAY_SIZE(_sc_exit_table),
-};
-
+extern const struct trace_syscall_table sc_exit_table;
+extern const struct trace_syscall_table compat_sc_exit_table;
 
-#undef TRACE_SYSCALL_TABLE
-#define TRACE_SYSCALL_TABLE(_template, _name, _nr, _nrargs)    \
-       [ _nr ] = {                                             \
-               .event_func = __event_probe__compat_syscall_exit_##_template, \
-               .nrargs = (_nrargs),                            \
-               .fields = __event_fields___compat_syscall_exit_##_template, \
-               .desc = &__event_desc___compat_syscall_exit_##_name, \
-       },
-
-/* Event compat syscall exit table */
-const struct trace_syscall_entry _compat_sc_exit_table[] = {
-#include <instrumentation/syscalls/headers/compat_syscalls_integers.h>
-#include <instrumentation/syscalls/headers/compat_syscalls_pointers.h>
-};
-
-const struct trace_syscall_table compat_sc_exit_table = {
-       .table = _compat_sc_exit_table,
-       .len = ARRAY_SIZE(_compat_sc_exit_table),
-};
 
 #undef SC_EXIT
 
@@ -810,7 +546,6 @@ void syscall_exit_event_probe(void *__data, struct pt_regs *regs, long ret)
                               regs, ret);
 }
 
-static
 void syscall_exit_event_notifier_probe(void *__data, struct pt_regs *regs,
                long ret)
 {
index 9a9d9173312fd9143872b6a882a62b82b5efff86..d221dfb7c7d2a4424d3086c548a4a928dc297bb8 100644 (file)
@@ -1,9 +1,47 @@
+/* SPDX-License-Identifier: (GPL-2.0-only or LGPL-2.1-only)
+ *
+ * lttng-syscalls.h
+ *
+ * LTTng syscall header.
+ *
+ * Copyright (C) 2021 Francis Deslauriers <francis.deslauriers@efficios.com>
+ */
+
 #ifndef LTTNG_SYSCALLS_H
 #define LTTNG_SYSCALLS_H
 
 #include <stddef.h>
 
+#include <asm/ptrace.h>
+
 #include <lttng/events.h>
+#include <lttng/kernel-version.h>
+
+
+/*
+ * Forward declarations for old kernels.
+ */
+struct mmsghdr;
+struct rlimit64;
+struct oldold_utsname;
+struct old_utsname;
+struct sel_arg_struct;
+struct mmap_arg_struct;
+struct file_handle;
+struct user_msghdr;
+
+/*
+ * Forward declaration for kernels >= 5.6
+ */
+struct timex;
+struct timeval;
+struct itimerval;
+struct itimerspec;
+
+#if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(5,6,0))
+typedef __kernel_old_time_t time_t;
+#endif
+
 struct trace_syscall_entry {
        void *event_func;
        const struct lttng_kernel_event_desc *desc;
@@ -15,4 +53,18 @@ struct trace_syscall_table {
        const struct trace_syscall_entry *table;
        const size_t len;
 };
+
+extern
+void syscall_entry_event_probe(void *__data, struct pt_regs *regs, long id);
+
+extern
+void syscall_exit_event_probe(void *__data, struct pt_regs *regs, long ret);
+
+extern
+void syscall_entry_event_notifier_probe(void *__data, struct pt_regs *regs,
+               long id);
+extern
+void syscall_exit_event_notifier_probe(void *__data, struct pt_regs *regs,
+               long ret);
+
 #endif /* LTTNG_SYSCALLS_H */
This page took 0.036819 seconds and 4 git commands to generate.