Commit | Line | Data |
---|---|---|
2f77fc4b | 1 | /* |
ab5be9fa | 2 | * Copyright (C) 2012 David Goulet <dgoulet@efficios.com> |
2f77fc4b | 3 | * |
ab5be9fa | 4 | * SPDX-License-Identifier: GPL-2.0-only |
2f77fc4b | 5 | * |
2f77fc4b DG |
6 | */ |
7 | ||
8 | #ifndef CMD_H | |
9 | #define CMD_H | |
10 | ||
c9e313bc SM |
11 | #include "context.hpp" |
12 | #include "lttng-sessiond.hpp" | |
159b042f | 13 | #include "lttng/tracker.h" |
c9e313bc | 14 | #include "session.hpp" |
28f23191 | 15 | |
c9e313bc | 16 | #include <common/tracker.hpp> |
49cddecd | 17 | #include <lttng/kernel.h> |
2f77fc4b | 18 | |
b0880ae5 | 19 | struct notification_thread_handle; |
999af9c1 | 20 | struct lttng_dynamic_buffer; |
b0880ae5 | 21 | |
a503e1ef JG |
22 | /* |
23 | * A callback (and associated user data) that should be run after a command | |
24 | * has been executed. No locks should be taken while executing this handler. | |
25 | * | |
26 | * The command's reply should not be sent until the handler has run and | |
27 | * completed successfully. On failure, the handler's return code should | |
28 | * be the only reply sent to the client. | |
29 | */ | |
e665dfbc | 30 | using completion_handler_function = enum lttng_error_code (*)(void *); |
a503e1ef JG |
31 | struct cmd_completion_handler { |
32 | completion_handler_function run; | |
33 | void *data; | |
34 | }; | |
35 | ||
2f77fc4b DG |
36 | /* |
37 | * Init the command subsystem. Must be called before using any of the functions | |
38 | * above. This is called in the main() of the session daemon. | |
39 | */ | |
40 | void cmd_init(void); | |
41 | ||
42 | /* Session commands */ | |
28f23191 JG |
43 | enum lttng_error_code cmd_create_session(struct command_ctx *cmd_ctx, |
44 | int sock, | |
45 | struct lttng_session_descriptor **return_descriptor); | |
0038180d | 46 | int cmd_destroy_session(struct ltt_session *session, int *sock_fd); |
2f77fc4b DG |
47 | |
48 | /* Channel commands */ | |
56a37563 | 49 | int cmd_disable_channel(struct ltt_session *session, |
28f23191 JG |
50 | enum lttng_domain_type domain, |
51 | char *channel_name); | |
999af9c1 | 52 | int cmd_enable_channel(struct command_ctx *cmd_ctx, int sock, int wpipe); |
159b042f JG |
53 | |
54 | /* Process attribute tracker commands */ | |
28f23191 JG |
55 | enum lttng_error_code |
56 | cmd_process_attr_tracker_get_tracking_policy(struct ltt_session *session, | |
57 | enum lttng_domain_type domain, | |
58 | enum lttng_process_attr process_attr, | |
59 | enum lttng_tracking_policy *policy); | |
60 | enum lttng_error_code | |
61 | cmd_process_attr_tracker_set_tracking_policy(struct ltt_session *session, | |
62 | enum lttng_domain_type domain, | |
63 | enum lttng_process_attr process_attr, | |
64 | enum lttng_tracking_policy policy); | |
65 | enum lttng_error_code | |
66 | cmd_process_attr_tracker_inclusion_set_add_value(struct ltt_session *session, | |
67 | enum lttng_domain_type domain, | |
68 | enum lttng_process_attr process_attr, | |
69 | const struct process_attr_value *value); | |
70 | enum lttng_error_code | |
71 | cmd_process_attr_tracker_inclusion_set_remove_value(struct ltt_session *session, | |
72 | enum lttng_domain_type domain, | |
73 | enum lttng_process_attr process_attr, | |
74 | const struct process_attr_value *value); | |
75 | enum lttng_error_code | |
76 | cmd_process_attr_tracker_get_inclusion_set(struct ltt_session *session, | |
77 | enum lttng_domain_type domain, | |
78 | enum lttng_process_attr process_attr, | |
79 | struct lttng_process_attr_values **values); | |
2f77fc4b DG |
80 | |
81 | /* Event commands */ | |
8ddd72ef | 82 | int cmd_disable_event(struct command_ctx *cmd_ctx, |
28f23191 JG |
83 | struct lttng_event *event, |
84 | char *filter_expression, | |
85 | struct lttng_bytecode *filter, | |
86 | struct lttng_event_exclusion *exclusion); | |
26e1c61f | 87 | int cmd_add_context(struct command_ctx *cmd_ctx, |
28f23191 JG |
88 | const struct lttng_event_context *event_context, |
89 | int kwpipe); | |
90 | int cmd_set_filter(struct ltt_session *session, | |
91 | enum lttng_domain_type domain, | |
92 | char *channel_name, | |
93 | struct lttng_event *event, | |
94 | struct lttng_bytecode *bytecode); | |
8ddd72ef | 95 | int cmd_enable_event(struct command_ctx *cmd_ctx, |
28f23191 JG |
96 | struct lttng_event *event, |
97 | char *filter_expression, | |
98 | struct lttng_event_exclusion *exclusion, | |
99 | struct lttng_bytecode *bytecode, | |
100 | int wpipe); | |
2f77fc4b DG |
101 | |
102 | /* Trace session action commands */ | |
103 | int cmd_start_trace(struct ltt_session *session); | |
104 | int cmd_stop_trace(struct ltt_session *session); | |
105 | ||
106 | /* Consumer commands */ | |
56a37563 | 107 | int cmd_register_consumer(struct ltt_session *session, |
28f23191 JG |
108 | enum lttng_domain_type domain, |
109 | const char *sock_path, | |
110 | struct consumer_data *cdata); | |
111 | int cmd_set_consumer_uri(struct ltt_session *session, size_t nb_uri, struct lttng_uri *uris); | |
ffe60014 | 112 | int cmd_setup_relayd(struct ltt_session *session); |
2f77fc4b DG |
113 | |
114 | /* Listing commands */ | |
28f23191 | 115 | ssize_t cmd_list_domains(struct ltt_session *session, struct lttng_domain **domains); |
8ddd72ef | 116 | enum lttng_error_code cmd_list_events(enum lttng_domain_type domain, |
28f23191 JG |
117 | struct ltt_session *session, |
118 | char *channel_name, | |
119 | struct lttng_payload *payload); | |
999af9c1 | 120 | enum lttng_error_code cmd_list_channels(enum lttng_domain_type domain, |
28f23191 JG |
121 | struct ltt_session *session, |
122 | struct lttng_payload *payload); | |
b178f53e | 123 | void cmd_list_lttng_sessions(struct lttng_session *sessions, |
28f23191 JG |
124 | size_t session_count, |
125 | uid_t uid, | |
126 | gid_t gid); | |
b2d68839 | 127 | enum lttng_error_code cmd_list_tracepoint_fields(enum lttng_domain_type domain, |
28f23191 | 128 | struct lttng_payload *reply); |
8ddd72ef | 129 | enum lttng_error_code cmd_list_tracepoints(enum lttng_domain_type domain, |
28f23191 | 130 | struct lttng_payload *reply_payload); |
6dc3064a | 131 | ssize_t cmd_snapshot_list_outputs(struct ltt_session *session, |
28f23191 JG |
132 | struct lttng_snapshot_output **outputs); |
133 | enum lttng_error_code cmd_list_syscalls(struct lttng_payload *reply_payload); | |
2f77fc4b | 134 | |
6d805429 | 135 | int cmd_data_pending(struct ltt_session *session); |
49cddecd | 136 | enum lttng_error_code cmd_kernel_tracer_status(enum lttng_kernel_tracer_status *status); |
2f77fc4b | 137 | |
6dc3064a DG |
138 | /* Snapshot */ |
139 | int cmd_snapshot_add_output(struct ltt_session *session, | |
28f23191 JG |
140 | const struct lttng_snapshot_output *output, |
141 | uint32_t *id); | |
6dc3064a | 142 | int cmd_snapshot_del_output(struct ltt_session *session, |
28f23191 | 143 | const struct lttng_snapshot_output *output); |
6dc3064a | 144 | int cmd_snapshot_record(struct ltt_session *session, |
28f23191 JG |
145 | const struct lttng_snapshot_output *output, |
146 | int wait); | |
6dc3064a | 147 | |
28f23191 | 148 | int cmd_set_session_shm_path(struct ltt_session *session, const char *shm_path); |
eded6438 | 149 | int cmd_regenerate_metadata(struct ltt_session *session); |
c2561365 | 150 | int cmd_regenerate_statedump(struct ltt_session *session); |
d7ba1388 | 151 | |
28f23191 JG |
152 | enum lttng_error_code |
153 | cmd_register_trigger(const struct lttng_credentials *cmd_creds, | |
154 | struct lttng_trigger *trigger, | |
155 | bool is_anonymous_trigger, | |
156 | struct notification_thread_handle *notification_thread_handle, | |
157 | struct lttng_trigger **return_trigger); | |
158 | enum lttng_error_code | |
159 | cmd_unregister_trigger(const struct lttng_credentials *cmd_creds, | |
160 | const struct lttng_trigger *trigger, | |
161 | struct notification_thread_handle *notification_thread_handle); | |
162 | ||
163 | enum lttng_error_code | |
164 | cmd_list_triggers(struct command_ctx *cmd_ctx, | |
165 | struct notification_thread_handle *notification_thread_handle, | |
166 | struct lttng_triggers **return_triggers); | |
167 | enum lttng_error_code | |
168 | cmd_execute_error_query(const struct lttng_credentials *cmd_creds, | |
169 | const struct lttng_error_query *query, | |
170 | struct lttng_error_query_results **_results, | |
171 | struct notification_thread_handle *notification_thread); | |
fbc9f37d | 172 | |
5c408ad8 | 173 | int cmd_rotate_session(struct ltt_session *session, |
28f23191 JG |
174 | struct lttng_rotate_session_return *rotate_return, |
175 | bool quiet_rotation, | |
176 | enum lttng_trace_chunk_command_type command); | |
d68c9a04 | 177 | int cmd_rotate_get_info(struct ltt_session *session, |
28f23191 JG |
178 | struct lttng_rotation_get_info_return *info_return, |
179 | uint64_t rotate_id); | |
66ea93b1 | 180 | int cmd_rotation_set_schedule(struct ltt_session *session, |
28f23191 JG |
181 | bool activate, |
182 | enum lttng_rotation_schedule_type schedule_type, | |
183 | uint64_t value); | |
5c408ad8 | 184 | |
a503e1ef | 185 | const struct cmd_completion_handler *cmd_pop_completion_handler(void); |
4dbe1875 MD |
186 | int start_kernel_session(struct ltt_kernel_session *ksess); |
187 | int stop_kernel_session(struct ltt_kernel_session *ksess); | |
a503e1ef | 188 | |
2f77fc4b | 189 | #endif /* CMD_H */ |