Commit | Line | Data |
---|---|---|
e42c4f49 FD |
1 | /* SPDX-License-Identifier: (GPL-2.0-only or LGPL-2.1-only) |
2 | * | |
3 | * lttng-syscalls-exit-table.c | |
4 | * | |
5 | * LTTng syscall exit probes. | |
6 | * | |
7 | * Copyright (C) 2010-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com> | |
8 | * Copyright (C) 2021 Francis Deslauriers <francis.deslauriers@efficios.com> | |
9 | */ | |
10 | ||
11 | #include <wrapper/tracepoint.h> | |
12 | ||
13 | #include "lttng-syscalls.h" | |
14 | ||
15 | ||
16 | #ifdef IA32_NR_syscalls | |
17 | #define NR_compat_syscalls IA32_NR_syscalls | |
18 | #else | |
19 | #define NR_compat_syscalls NR_syscalls | |
20 | #endif | |
21 | ||
22 | /* | |
23 | * Create LTTng tracepoint probes. | |
24 | */ | |
25 | #define LTTNG_PACKAGE_BUILD | |
26 | #define CREATE_TRACE_POINTS | |
27 | #define TP_MODULE_NOINIT | |
b03cf820 | 28 | #define TRACE_INCLUDE_PATH instrumentation/syscalls |
e42c4f49 FD |
29 | |
30 | #define PARAMS(args...) args | |
31 | ||
32 | #define SC_EXIT | |
33 | ||
34 | #undef sc_in | |
4667f7f6 | 35 | #define sc_in(...) |
e42c4f49 | 36 | #undef sc_out |
4667f7f6 | 37 | #define sc_out(...) __VA_ARGS__ |
e42c4f49 | 38 | #undef sc_inout |
4667f7f6 | 39 | #define sc_inout(...) __VA_ARGS__ |
e42c4f49 FD |
40 | #undef sc_exit |
41 | #define sc_exit(...) __VA_ARGS__ | |
42 | ||
43 | #define LTTNG_TRACEPOINT_TYPE_EXTERN | |
44 | ||
45 | #include <lttng/events-reset.h> | |
46 | ||
47 | /* Hijack probe callback for system call enter */ | |
48 | #undef TP_PROBE_CB | |
49 | #define TP_PROBE_CB(_template) &syscall_exit_event_probe | |
50 | #define SC_LTTNG_TRACEPOINT_EVENT(_name, _proto, _args, _fields) \ | |
51 | LTTNG_TRACEPOINT_EVENT(syscall_exit_##_name, PARAMS(_proto), PARAMS(_args), \ | |
52 | PARAMS(_fields)) | |
53 | #define SC_LTTNG_TRACEPOINT_EVENT_CODE(_name, _proto, _args, _locvar, _code_pre, _fields, _code_post) \ | |
54 | LTTNG_TRACEPOINT_EVENT_CODE(syscall_exit_##_name, PARAMS(_proto), PARAMS(_args), \ | |
55 | PARAMS(_locvar), PARAMS(_code_pre), \ | |
56 | PARAMS(_fields), PARAMS(_code_post)) | |
57 | #define SC_LTTNG_TRACEPOINT_EVENT_CLASS_NOARGS(_name, _fields) \ | |
58 | LTTNG_TRACEPOINT_EVENT_CLASS_NOARGS(syscall_exit_##_name, PARAMS(_fields)) | |
59 | #define SC_LTTNG_TRACEPOINT_EVENT_INSTANCE_NOARGS(_template, _name) \ | |
60 | LTTNG_TRACEPOINT_EVENT_INSTANCE_NOARGS(syscall_exit_##_template, syscall_exit_##_name) | |
61 | ||
62 | #define SC_LTTNG_TRACEPOINT_ENUM(_name, _values) \ | |
63 | LTTNG_TRACEPOINT_ENUM(_name, PARAMS(_values)) | |
64 | #undef TRACE_SYSTEM | |
65 | #define TRACE_SYSTEM syscall_exit_integers | |
66 | #define TRACE_INCLUDE_FILE syscalls_integers | |
b03cf820 | 67 | #include <instrumentation/syscalls/syscalls_integers.h> |
e42c4f49 FD |
68 | #undef TRACE_INCLUDE_FILE |
69 | #undef TRACE_SYSTEM | |
70 | #define TRACE_SYSTEM syscall_exit_pointers | |
71 | #define TRACE_INCLUDE_FILE syscalls_pointers | |
b03cf820 | 72 | #include <instrumentation/syscalls/syscalls_pointers.h> |
e42c4f49 FD |
73 | #undef TRACE_INCLUDE_FILE |
74 | #undef TRACE_SYSTEM | |
75 | #undef SC_LTTNG_TRACEPOINT_ENUM | |
76 | #undef SC_LTTNG_TRACEPOINT_EVENT_CODE | |
77 | #undef SC_LTTNG_TRACEPOINT_EVENT | |
78 | #undef SC_LTTNG_TRACEPOINT_EVENT_CLASS_NOARGS | |
79 | #undef SC_LTTNG_TRACEPOINT_EVENT_INSTANCE_NOARGS | |
80 | #undef TP_PROBE_CB | |
81 | #undef _TRACE_SYSCALLS_INTEGERS_H | |
82 | #undef _TRACE_SYSCALLS_POINTERS_H | |
83 | ||
84 | #define CREATE_SYSCALL_TABLE | |
85 | ||
86 | #undef sc_exit | |
87 | #define sc_exit(...) | |
88 | ||
89 | #undef TRACE_SYSCALL_TABLE | |
90 | #define TRACE_SYSCALL_TABLE(_template, _name, _nr, _nrargs) \ | |
91 | [ _nr ] = { \ | |
92 | .event_func = __event_probe__syscall_exit_##_template, \ | |
93 | .nrargs = (_nrargs), \ | |
94 | .fields = __event_fields___syscall_exit_##_template, \ | |
95 | .desc = &__event_desc___syscall_exit_##_name, \ | |
96 | }, | |
97 | ||
98 | /* Event syscall enter tracing table */ | |
99 | static const struct trace_syscall_entry _sc_exit_table[] = { | |
b03cf820 MJ |
100 | #include <instrumentation/syscalls/syscalls_integers.h> |
101 | #include <instrumentation/syscalls/syscalls_pointers.h> | |
e42c4f49 FD |
102 | }; |
103 | ||
104 | const struct trace_syscall_table sc_exit_table = { | |
105 | .table = _sc_exit_table, | |
106 | .len = ARRAY_SIZE(_sc_exit_table), | |
107 | }; | |
108 | #undef SC_EXIT | |
109 | ||
110 | #undef CREATE_SYSCALL_TABLE |