2 * Copyright (C) 2012 David Goulet <dgoulet@efficios.com>
4 * SPDX-License-Identifier: GPL-2.0-only
11 #include "context.hpp"
12 #include "lttng-sessiond.hpp"
13 #include "lttng/tracker.h"
14 #include "session.hpp"
16 #include <common/tracker.hpp>
18 struct notification_thread_handle;
19 struct lttng_dynamic_buffer;
22 * A callback (and associated user data) that should be run after a command
23 * has been executed. No locks should be taken while executing this handler.
25 * The command's reply should not be sent until the handler has run and
26 * completed successfully. On failure, the handler's return code should
27 * be the only reply sent to the client.
29 using completion_handler_function = enum lttng_error_code (*)(void *);
30 struct cmd_completion_handler {
31 completion_handler_function run;
36 * Init the command subsystem. Must be called before using any of the functions
37 * above. This is called in the main() of the session daemon.
41 /* Session commands */
42 enum lttng_error_code cmd_create_session(struct command_ctx *cmd_ctx,
44 struct lttng_session_descriptor **return_descriptor);
45 int cmd_destroy_session(struct ltt_session *session, int *sock_fd);
47 /* Channel commands */
48 int cmd_disable_channel(struct ltt_session *session,
49 enum lttng_domain_type domain,
51 int cmd_enable_channel(struct command_ctx *cmd_ctx, int sock, int wpipe);
53 /* Process attribute tracker commands */
55 cmd_process_attr_tracker_get_tracking_policy(struct ltt_session *session,
56 enum lttng_domain_type domain,
57 enum lttng_process_attr process_attr,
58 enum lttng_tracking_policy *policy);
60 cmd_process_attr_tracker_set_tracking_policy(struct ltt_session *session,
61 enum lttng_domain_type domain,
62 enum lttng_process_attr process_attr,
63 enum lttng_tracking_policy policy);
65 cmd_process_attr_tracker_inclusion_set_add_value(struct ltt_session *session,
66 enum lttng_domain_type domain,
67 enum lttng_process_attr process_attr,
68 const struct process_attr_value *value);
70 cmd_process_attr_tracker_inclusion_set_remove_value(struct ltt_session *session,
71 enum lttng_domain_type domain,
72 enum lttng_process_attr process_attr,
73 const struct process_attr_value *value);
75 cmd_process_attr_tracker_get_inclusion_set(struct ltt_session *session,
76 enum lttng_domain_type domain,
77 enum lttng_process_attr process_attr,
78 struct lttng_process_attr_values **values);
81 int cmd_disable_event(struct command_ctx *cmd_ctx,
82 struct lttng_event *event,
83 char *filter_expression,
84 struct lttng_bytecode *filter,
85 struct lttng_event_exclusion *exclusion);
86 int cmd_add_context(struct command_ctx *cmd_ctx,
87 const struct lttng_event_context *event_context,
89 int cmd_set_filter(struct ltt_session *session,
90 enum lttng_domain_type domain,
92 struct lttng_event *event,
93 struct lttng_bytecode *bytecode);
94 int cmd_enable_event(struct command_ctx *cmd_ctx,
95 struct lttng_event *event,
96 char *filter_expression,
97 struct lttng_event_exclusion *exclusion,
98 struct lttng_bytecode *bytecode,
101 /* Trace session action commands */
102 int cmd_start_trace(struct ltt_session *session);
103 int cmd_stop_trace(struct ltt_session *session);
105 /* Consumer commands */
106 int cmd_register_consumer(struct ltt_session *session,
107 enum lttng_domain_type domain,
108 const char *sock_path,
109 struct consumer_data *cdata);
110 int cmd_set_consumer_uri(struct ltt_session *session, size_t nb_uri, struct lttng_uri *uris);
111 int cmd_setup_relayd(struct ltt_session *session);
113 /* Listing commands */
114 ssize_t cmd_list_domains(struct ltt_session *session, struct lttng_domain **domains);
115 enum lttng_error_code cmd_list_events(enum lttng_domain_type domain,
116 struct ltt_session *session,
118 struct lttng_payload *payload);
119 enum lttng_error_code cmd_list_channels(enum lttng_domain_type domain,
120 struct ltt_session *session,
121 struct lttng_payload *payload);
122 void cmd_list_lttng_sessions(struct lttng_session *sessions,
123 size_t session_count,
126 enum lttng_error_code cmd_list_tracepoint_fields(enum lttng_domain_type domain,
127 struct lttng_payload *reply);
128 enum lttng_error_code cmd_list_tracepoints(enum lttng_domain_type domain,
129 struct lttng_payload *reply_payload);
130 ssize_t cmd_snapshot_list_outputs(struct ltt_session *session,
131 struct lttng_snapshot_output **outputs);
132 enum lttng_error_code cmd_list_syscalls(struct lttng_payload *reply_payload);
134 int cmd_data_pending(struct ltt_session *session);
137 int cmd_snapshot_add_output(struct ltt_session *session,
138 const struct lttng_snapshot_output *output,
140 int cmd_snapshot_del_output(struct ltt_session *session,
141 const struct lttng_snapshot_output *output);
142 int cmd_snapshot_record(struct ltt_session *session,
143 const struct lttng_snapshot_output *output,
146 int cmd_set_session_shm_path(struct ltt_session *session, const char *shm_path);
147 int cmd_regenerate_metadata(struct ltt_session *session);
148 int cmd_regenerate_statedump(struct ltt_session *session);
150 enum lttng_error_code
151 cmd_register_trigger(const struct lttng_credentials *cmd_creds,
152 struct lttng_trigger *trigger,
153 bool is_anonymous_trigger,
154 struct notification_thread_handle *notification_thread_handle,
155 struct lttng_trigger **return_trigger);
156 enum lttng_error_code
157 cmd_unregister_trigger(const struct lttng_credentials *cmd_creds,
158 const struct lttng_trigger *trigger,
159 struct notification_thread_handle *notification_thread_handle);
161 enum lttng_error_code
162 cmd_list_triggers(struct command_ctx *cmd_ctx,
163 struct notification_thread_handle *notification_thread_handle,
164 struct lttng_triggers **return_triggers);
165 enum lttng_error_code
166 cmd_execute_error_query(const struct lttng_credentials *cmd_creds,
167 const struct lttng_error_query *query,
168 struct lttng_error_query_results **_results,
169 struct notification_thread_handle *notification_thread);
171 int cmd_rotate_session(struct ltt_session *session,
172 struct lttng_rotate_session_return *rotate_return,
174 enum lttng_trace_chunk_command_type command);
175 int cmd_rotate_get_info(struct ltt_session *session,
176 struct lttng_rotation_get_info_return *info_return,
178 int cmd_rotation_set_schedule(struct ltt_session *session,
180 enum lttng_rotation_schedule_type schedule_type,
183 const struct cmd_completion_handler *cmd_pop_completion_handler(void);
184 int start_kernel_session(struct ltt_kernel_session *ksess);
185 int stop_kernel_session(struct ltt_kernel_session *ksess);