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