2 * Copyright (C) 2012 David Goulet <dgoulet@efficios.com>
4 * SPDX-License-Identifier: GPL-2.0-only
11 #include "context.hpp"
12 #include "ctl-utils.hpp"
13 #include "lttng-sessiond.hpp"
14 #include "lttng/tracker.h"
15 #include "session.hpp"
17 #include <common/tracker.hpp>
19 #include <lttng/kernel.h>
21 struct notification_thread_handle;
22 struct lttng_dynamic_buffer;
25 * A callback (and associated user data) that should be run after a command
26 * has been executed. No locks should be taken while executing this handler.
28 * The command's reply should not be sent until the handler has run and
29 * completed successfully. On failure, the handler's return code should
30 * be the only reply sent to the client.
32 using completion_handler_function = enum lttng_error_code (*)(void *);
33 struct cmd_completion_handler {
34 completion_handler_function run;
39 * Init the command subsystem. Must be called before using any of the functions
40 * above. This is called in the main() of the session daemon.
44 /* Session commands */
45 enum lttng_error_code cmd_create_session(struct command_ctx *cmd_ctx,
47 struct lttng_session_descriptor **return_descriptor);
48 int cmd_destroy_session(struct ltt_session *session, int *sock_fd);
50 /* Channel commands */
51 int cmd_disable_channel(struct ltt_session *session,
52 enum lttng_domain_type domain,
54 int cmd_enable_channel(struct command_ctx *cmd_ctx,
55 ltt_session::locked_ref& session,
59 /* Process attribute tracker commands */
61 cmd_process_attr_tracker_get_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);
66 cmd_process_attr_tracker_set_tracking_policy(struct ltt_session *session,
67 enum lttng_domain_type domain,
68 enum lttng_process_attr process_attr,
69 enum lttng_tracking_policy policy);
71 cmd_process_attr_tracker_inclusion_set_add_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);
76 cmd_process_attr_tracker_inclusion_set_remove_value(struct ltt_session *session,
77 enum lttng_domain_type domain,
78 enum lttng_process_attr process_attr,
79 const struct process_attr_value *value);
81 cmd_process_attr_tracker_get_inclusion_set(struct ltt_session *session,
82 enum lttng_domain_type domain,
83 enum lttng_process_attr process_attr,
84 struct lttng_process_attr_values **values);
87 int cmd_disable_event(struct command_ctx *cmd_ctx,
88 ltt_session::locked_ref& locked_session,
89 struct lttng_event *event,
90 char *filter_expression,
91 struct lttng_bytecode *filter,
92 struct lttng_event_exclusion *exclusion);
93 int cmd_add_context(struct command_ctx *cmd_ctx,
94 ltt_session::locked_ref& locked_session,
95 const struct lttng_event_context *event_context,
97 int cmd_set_filter(struct ltt_session *session,
98 enum lttng_domain_type domain,
100 struct lttng_event *event,
101 struct lttng_bytecode *bytecode);
102 int cmd_enable_event(struct command_ctx *cmd_ctx,
103 ltt_session::locked_ref& session,
104 struct lttng_event *event,
105 char *filter_expression,
106 struct lttng_event_exclusion *exclusion,
107 struct lttng_bytecode *bytecode,
110 /* Trace session action commands */
111 int cmd_start_trace(struct ltt_session *session);
112 int cmd_stop_trace(struct ltt_session *session);
114 /* Consumer commands */
115 int cmd_register_consumer(struct ltt_session *session,
116 enum lttng_domain_type domain,
117 const char *sock_path,
118 struct consumer_data *cdata);
119 int cmd_set_consumer_uri(struct ltt_session *session, size_t nb_uri, struct lttng_uri *uris);
120 int cmd_setup_relayd(struct ltt_session *session);
122 /* Listing commands */
123 ssize_t cmd_list_domains(struct ltt_session *session, struct lttng_domain **domains);
124 enum lttng_error_code cmd_list_events(enum lttng_domain_type domain,
125 struct ltt_session *session,
127 struct lttng_payload *payload);
128 enum lttng_error_code cmd_list_channels(enum lttng_domain_type domain,
129 struct ltt_session *session,
130 struct lttng_payload *payload);
131 void cmd_list_lttng_sessions(struct lttng_session *sessions,
132 size_t session_count,
135 enum lttng_error_code cmd_list_tracepoint_fields(enum lttng_domain_type domain,
136 struct lttng_payload *reply);
137 enum lttng_error_code cmd_list_tracepoints(enum lttng_domain_type domain,
138 struct lttng_payload *reply_payload);
139 ssize_t cmd_snapshot_list_outputs(struct ltt_session *session,
140 struct lttng_snapshot_output **outputs);
141 enum lttng_error_code cmd_list_syscalls(struct lttng_payload *reply_payload);
143 int cmd_data_pending(struct ltt_session *session);
144 enum lttng_error_code cmd_kernel_tracer_status(enum lttng_kernel_tracer_status *status);
147 int cmd_snapshot_add_output(struct ltt_session *session,
148 const struct lttng_snapshot_output *output,
150 int cmd_snapshot_del_output(struct ltt_session *session,
151 const struct lttng_snapshot_output *output);
152 int cmd_snapshot_record(struct ltt_session *session,
153 const struct lttng_snapshot_output *output,
156 int cmd_set_session_shm_path(struct ltt_session *session, const char *shm_path);
157 int cmd_regenerate_metadata(struct ltt_session *session);
158 int cmd_regenerate_statedump(struct ltt_session *session);
161 cmd_register_trigger(const struct lttng_credentials *cmd_creds,
162 struct lttng_trigger *trigger,
163 bool is_anonymous_trigger,
164 struct notification_thread_handle *notification_thread_handle);
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);
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);
180 int cmd_rotate_session(struct ltt_session *session,
181 struct lttng_rotate_session_return *rotate_return,
183 enum lttng_trace_chunk_command_type command);
184 int cmd_rotate_get_info(struct ltt_session *session,
185 struct lttng_rotation_get_info_return *info_return,
187 int cmd_rotation_set_schedule(struct ltt_session *session,
189 enum lttng_rotation_schedule_type schedule_type,
192 const struct cmd_completion_handler *cmd_pop_completion_handler();
193 int start_kernel_session(struct ltt_kernel_session *ksess);
194 int stop_kernel_session(struct ltt_kernel_session *ksess);