xref: /linux/tools/tracing/rtla/src/actions.h (revision 6ea082b171e00bb68b749426f03d9d7e833e9f51)
1*6ea082b1STomas Glozar /* SPDX-License-Identifier: GPL-2.0 */
2*6ea082b1STomas Glozar #include <tracefs.h>
3*6ea082b1STomas Glozar #include <stdbool.h>
4*6ea082b1STomas Glozar 
5*6ea082b1STomas Glozar enum action_type {
6*6ea082b1STomas Glozar 	ACTION_NONE = 0,
7*6ea082b1STomas Glozar 	ACTION_TRACE_OUTPUT,
8*6ea082b1STomas Glozar 	ACTION_SIGNAL,
9*6ea082b1STomas Glozar 	ACTION_SHELL,
10*6ea082b1STomas Glozar 	ACTION_FIELD_N
11*6ea082b1STomas Glozar };
12*6ea082b1STomas Glozar 
13*6ea082b1STomas Glozar struct action {
14*6ea082b1STomas Glozar 	enum action_type type;
15*6ea082b1STomas Glozar 	union {
16*6ea082b1STomas Glozar 		struct {
17*6ea082b1STomas Glozar 			/* For ACTION_TRACE_OUTPUT */
18*6ea082b1STomas Glozar 			char *trace_output;
19*6ea082b1STomas Glozar 		};
20*6ea082b1STomas Glozar 		struct {
21*6ea082b1STomas Glozar 			/* For ACTION_SIGNAL */
22*6ea082b1STomas Glozar 			int signal;
23*6ea082b1STomas Glozar 			int pid;
24*6ea082b1STomas Glozar 		};
25*6ea082b1STomas Glozar 		struct {
26*6ea082b1STomas Glozar 			/* For ACTION_SHELL */
27*6ea082b1STomas Glozar 			char *command;
28*6ea082b1STomas Glozar 		};
29*6ea082b1STomas Glozar 	};
30*6ea082b1STomas Glozar };
31*6ea082b1STomas Glozar 
32*6ea082b1STomas Glozar static const int action_default_size = 8;
33*6ea082b1STomas Glozar 
34*6ea082b1STomas Glozar struct actions {
35*6ea082b1STomas Glozar 	struct action *list;
36*6ea082b1STomas Glozar 	int len, size;
37*6ea082b1STomas Glozar 	bool present[ACTION_FIELD_N];
38*6ea082b1STomas Glozar 
39*6ea082b1STomas Glozar 	/* External dependencies */
40*6ea082b1STomas Glozar 	struct tracefs_instance *trace_output_inst;
41*6ea082b1STomas Glozar };
42*6ea082b1STomas Glozar 
43*6ea082b1STomas Glozar void actions_init(struct actions *self);
44*6ea082b1STomas Glozar void actions_destroy(struct actions *self);
45*6ea082b1STomas Glozar int actions_add_trace_output(struct actions *self, const char *trace_output);
46*6ea082b1STomas Glozar int actions_add_signal(struct actions *self, int signal, int pid);
47*6ea082b1STomas Glozar int actions_add_shell(struct actions *self, const char *command);
48*6ea082b1STomas Glozar int actions_parse(struct actions *self, const char *trigger);
49*6ea082b1STomas Glozar int actions_perform(const struct actions *self);
50