xref: /linux/kernel/trace/rv/rv_trace.h (revision f74f8bb246cf22f27752977da62079cb615f55b2)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #undef TRACE_SYSTEM
3 #define TRACE_SYSTEM rv
4 
5 #if !defined(_TRACE_RV_H) || defined(TRACE_HEADER_MULTI_READ)
6 #define _TRACE_RV_H
7 
8 #include <linux/rv.h>
9 #include <linux/tracepoint.h>
10 
11 #ifdef CONFIG_DA_MON_EVENTS_IMPLICIT
12 DECLARE_EVENT_CLASS(event_da_monitor,
13 
14 	TP_PROTO(char *state, char *event, char *next_state, bool final_state),
15 
16 	TP_ARGS(state, event, next_state, final_state),
17 
18 	TP_STRUCT__entry(
19 		__array(	char,	state,		MAX_DA_NAME_LEN	)
20 		__array(	char,	event,		MAX_DA_NAME_LEN	)
21 		__array(	char,	next_state,	MAX_DA_NAME_LEN	)
22 		__field(	bool,	final_state			)
23 	),
24 
25 	TP_fast_assign(
26 		memcpy(__entry->state,		state,		MAX_DA_NAME_LEN);
27 		memcpy(__entry->event,		event,		MAX_DA_NAME_LEN);
28 		memcpy(__entry->next_state,	next_state,	MAX_DA_NAME_LEN);
29 		__entry->final_state		= final_state;
30 	),
31 
32 	TP_printk("%s x %s -> %s %s",
33 		__entry->state,
34 		__entry->event,
35 		__entry->next_state,
36 		__entry->final_state ? "(final)" : "")
37 );
38 
39 DECLARE_EVENT_CLASS(error_da_monitor,
40 
41 	TP_PROTO(char *state, char *event),
42 
43 	TP_ARGS(state, event),
44 
45 	TP_STRUCT__entry(
46 		__array(	char,	state,		MAX_DA_NAME_LEN	)
47 		__array(	char,	event,		MAX_DA_NAME_LEN	)
48 	),
49 
50 	TP_fast_assign(
51 		memcpy(__entry->state,		state,		MAX_DA_NAME_LEN);
52 		memcpy(__entry->event,		event,		MAX_DA_NAME_LEN);
53 	),
54 
55 	TP_printk("event %s not expected in the state %s",
56 		__entry->event,
57 		__entry->state)
58 );
59 
60 #include <monitors/wip/wip_trace.h>
61 #include <monitors/tss/tss_trace.h>
62 #include <monitors/sco/sco_trace.h>
63 #include <monitors/scpd/scpd_trace.h>
64 #include <monitors/snep/snep_trace.h>
65 #include <monitors/sncid/sncid_trace.h>
66 // Add new monitors based on CONFIG_DA_MON_EVENTS_IMPLICIT here
67 
68 #endif /* CONFIG_DA_MON_EVENTS_IMPLICIT */
69 
70 #ifdef CONFIG_DA_MON_EVENTS_ID
71 DECLARE_EVENT_CLASS(event_da_monitor_id,
72 
73 	TP_PROTO(int id, char *state, char *event, char *next_state, bool final_state),
74 
75 	TP_ARGS(id, state, event, next_state, final_state),
76 
77 	TP_STRUCT__entry(
78 		__field(	int,	id				)
79 		__array(	char,	state,		MAX_DA_NAME_LEN	)
80 		__array(	char,	event,		MAX_DA_NAME_LEN	)
81 		__array(	char,	next_state,	MAX_DA_NAME_LEN	)
82 		__field(	bool,	final_state			)
83 	),
84 
85 	TP_fast_assign(
86 		memcpy(__entry->state,		state,		MAX_DA_NAME_LEN);
87 		memcpy(__entry->event,		event,		MAX_DA_NAME_LEN);
88 		memcpy(__entry->next_state,	next_state,	MAX_DA_NAME_LEN);
89 		__entry->id			= id;
90 		__entry->final_state		= final_state;
91 	),
92 
93 	TP_printk("%d: %s x %s -> %s %s",
94 		__entry->id,
95 		__entry->state,
96 		__entry->event,
97 		__entry->next_state,
98 		__entry->final_state ? "(final)" : "")
99 );
100 
101 DECLARE_EVENT_CLASS(error_da_monitor_id,
102 
103 	TP_PROTO(int id, char *state, char *event),
104 
105 	TP_ARGS(id, state, event),
106 
107 	TP_STRUCT__entry(
108 		__field(	int,	id				)
109 		__array(	char,	state,		MAX_DA_NAME_LEN	)
110 		__array(	char,	event,		MAX_DA_NAME_LEN	)
111 	),
112 
113 	TP_fast_assign(
114 		memcpy(__entry->state,		state,		MAX_DA_NAME_LEN);
115 		memcpy(__entry->event,		event,		MAX_DA_NAME_LEN);
116 		__entry->id			= id;
117 	),
118 
119 	TP_printk("%d: event %s not expected in the state %s",
120 		__entry->id,
121 		__entry->event,
122 		__entry->state)
123 );
124 
125 #include <monitors/wwnr/wwnr_trace.h>
126 #include <monitors/snroc/snroc_trace.h>
127 // Add new monitors based on CONFIG_DA_MON_EVENTS_ID here
128 
129 #endif /* CONFIG_DA_MON_EVENTS_ID */
130 #ifdef CONFIG_LTL_MON_EVENTS_ID
131 DECLARE_EVENT_CLASS(event_ltl_monitor_id,
132 
133 	TP_PROTO(struct task_struct *task, char *states, char *atoms, char *next),
134 
135 	TP_ARGS(task, states, atoms, next),
136 
137 	TP_STRUCT__entry(
138 		__string(comm, task->comm)
139 		__field(pid_t, pid)
140 		__string(states, states)
141 		__string(atoms, atoms)
142 		__string(next, next)
143 	),
144 
145 	TP_fast_assign(
146 		__assign_str(comm);
147 		__entry->pid = task->pid;
148 		__assign_str(states);
149 		__assign_str(atoms);
150 		__assign_str(next);
151 	),
152 
153 	TP_printk("%s[%d]: (%s) x (%s) -> (%s)", __get_str(comm), __entry->pid,
154 		  __get_str(states), __get_str(atoms), __get_str(next))
155 );
156 
157 DECLARE_EVENT_CLASS(error_ltl_monitor_id,
158 
159 	TP_PROTO(struct task_struct *task),
160 
161 	TP_ARGS(task),
162 
163 	TP_STRUCT__entry(
164 		__string(comm, task->comm)
165 		__field(pid_t, pid)
166 	),
167 
168 	TP_fast_assign(
169 		__assign_str(comm);
170 		__entry->pid = task->pid;
171 	),
172 
173 	TP_printk("%s[%d]: violation detected", __get_str(comm), __entry->pid)
174 );
175 #include <monitors/pagefault/pagefault_trace.h>
176 #include <monitors/sleep/sleep_trace.h>
177 // Add new monitors based on CONFIG_LTL_MON_EVENTS_ID here
178 #endif /* CONFIG_LTL_MON_EVENTS_ID */
179 #endif /* _TRACE_RV_H */
180 
181 /* This part must be outside protection */
182 #undef TRACE_INCLUDE_PATH
183 #define TRACE_INCLUDE_PATH .
184 #undef TRACE_INCLUDE_FILE
185 #define TRACE_INCLUDE_FILE rv_trace
186 #include <trace/define_trace.h>
187