Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
torvalds
GitHub Repository: torvalds/linux
Path: blob/master/include/trace/define_remote_events.h
170838 views
1
/* SPDX-License-Identifier: GPL-2.0 */
2
3
#include <linux/trace_events.h>
4
#include <linux/trace_remote_event.h>
5
#include <linux/trace_seq.h>
6
#include <linux/stringify.h>
7
8
#define REMOTE_EVENT_INCLUDE(__file) __stringify(../../__file)
9
10
#ifdef REMOTE_EVENT_SECTION
11
# define __REMOTE_EVENT_SECTION(__name) __used __section(REMOTE_EVENT_SECTION"."#__name)
12
#else
13
# define __REMOTE_EVENT_SECTION(__name)
14
#endif
15
16
#define REMOTE_PRINTK_COUNT_ARGS(__args...) \
17
__COUNT_ARGS(, ##__args, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 0)
18
19
#define __remote_printk0() \
20
trace_seq_putc(seq, '\n')
21
22
#define __remote_printk1(__fmt) \
23
trace_seq_puts(seq, " " __fmt "\n") \
24
25
#define __remote_printk2(__fmt, __args...) \
26
do { \
27
trace_seq_putc(seq, ' '); \
28
trace_seq_printf(seq, __fmt, __args); \
29
trace_seq_putc(seq, '\n'); \
30
} while (0)
31
32
/* Apply the appropriate trace_seq sequence according to the number of arguments */
33
#define remote_printk(__args...) \
34
CONCATENATE(__remote_printk, REMOTE_PRINTK_COUNT_ARGS(__args))(__args)
35
36
#define RE_PRINTK(__args...) __args
37
38
#define REMOTE_EVENT(__name, __id, __struct, __printk) \
39
REMOTE_EVENT_FORMAT(__name, __struct); \
40
static void remote_event_print_##__name(void *evt, struct trace_seq *seq) \
41
{ \
42
struct remote_event_format_##__name __maybe_unused *__entry = evt; \
43
trace_seq_puts(seq, #__name); \
44
remote_printk(__printk); \
45
}
46
#include REMOTE_EVENT_INCLUDE(REMOTE_EVENT_INCLUDE_FILE)
47
48
#undef REMOTE_EVENT
49
#undef RE_PRINTK
50
#undef re_field
51
#define re_field(__type, __field) \
52
{ \
53
.type = #__type, .name = #__field, \
54
.size = sizeof(__type), .align = __alignof__(__type), \
55
.is_signed = is_signed_type(__type), \
56
},
57
#define __entry REC
58
#define RE_PRINTK(__fmt, __args...) "\"" __fmt "\", " __stringify(__args)
59
#define REMOTE_EVENT(__name, __id, __struct, __printk) \
60
static struct trace_event_fields remote_event_fields_##__name[] = { \
61
__struct \
62
{} \
63
}; \
64
static char remote_event_print_fmt_##__name[] = __printk; \
65
static struct remote_event __REMOTE_EVENT_SECTION(__name) \
66
remote_event_##__name = { \
67
.name = #__name, \
68
.id = __id, \
69
.fields = remote_event_fields_##__name, \
70
.print_fmt = remote_event_print_fmt_##__name, \
71
.print = remote_event_print_##__name, \
72
}
73
#include REMOTE_EVENT_INCLUDE(REMOTE_EVENT_INCLUDE_FILE)
74
75