2 * Copyright (C) 2012 David Goulet <dgoulet@efficios.com>
4 * SPDX-License-Identifier: GPL-2.0-only
12 #include "lttng-sessiond.h"
13 #include "lttng/map/map.h"
14 #include "lttng/tracker.h"
16 #include <common/tracker.h>
19 struct notification_thread_handle
;
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 typedef enum lttng_error_code (*completion_handler_function
)(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
, int sock
,
43 struct lttng_session_descriptor
**return_descriptor
);
44 int cmd_destroy_session(struct ltt_session
*session
,
45 struct notification_thread_handle
*notification_thread_handle
,
48 /* Channel commands */
49 int cmd_disable_channel(struct ltt_session
*session
,
50 enum lttng_domain_type domain
, char *channel_name
);
51 int cmd_enable_channel(struct ltt_session
*session
,
52 const struct lttng_domain
*domain
, const struct lttng_channel
*attr
,
54 enum lttng_error_code
cmd_add_map(struct command_ctx
*cmd_ctx
, int sock
);
56 enum lttng_error_code
cmd_enable_map(struct ltt_session
*session
,
57 enum lttng_domain_type domain
, char *map_name
);
59 enum lttng_error_code
cmd_disable_map(struct ltt_session
*session
,
60 enum lttng_domain_type domain
, char *map_name
);
62 /* Process attribute tracker commands */
63 enum lttng_error_code
cmd_process_attr_tracker_get_tracking_policy(
64 struct ltt_session
*session
,
65 enum lttng_domain_type domain
,
66 enum lttng_process_attr process_attr
,
67 enum lttng_tracking_policy
*policy
);
68 enum lttng_error_code
cmd_process_attr_tracker_set_tracking_policy(
69 struct ltt_session
*session
,
70 enum lttng_domain_type domain
,
71 enum lttng_process_attr process_attr
,
72 enum lttng_tracking_policy policy
);
73 enum lttng_error_code
cmd_process_attr_tracker_inclusion_set_add_value(
74 struct ltt_session
*session
,
75 enum lttng_domain_type domain
,
76 enum lttng_process_attr process_attr
,
77 const struct process_attr_value
*value
);
78 enum lttng_error_code
cmd_process_attr_tracker_inclusion_set_remove_value(
79 struct ltt_session
*session
,
80 enum lttng_domain_type domain
,
81 enum lttng_process_attr process_attr
,
82 const struct process_attr_value
*value
);
83 enum lttng_error_code
cmd_process_attr_tracker_get_inclusion_set(
84 struct ltt_session
*session
,
85 enum lttng_domain_type domain
,
86 enum lttng_process_attr process_attr
,
87 struct lttng_process_attr_values
**values
);
90 int cmd_disable_event(struct ltt_session
*session
,
91 enum lttng_domain_type domain
,
92 const char *channel_name
,
93 const struct lttng_event
*event
);
94 int cmd_add_context(struct ltt_session
*session
, enum lttng_domain_type domain
,
95 char *channel_name
, const struct lttng_event_context
*ctx
, int kwpipe
);
96 int cmd_set_filter(struct ltt_session
*session
, enum lttng_domain_type domain
,
97 char *channel_name
, struct lttng_event
*event
,
98 struct lttng_bytecode
*bytecode
);
99 int cmd_enable_event(struct ltt_session
*session
, const struct lttng_domain
*domain
,
100 char *channel_name
, struct lttng_event
*event
,
101 char *filter_expression
,
102 struct lttng_bytecode
*filter
,
103 struct lttng_event_exclusion
*exclusion
,
106 /* Trace session action commands */
107 int cmd_start_trace(struct ltt_session
*session
);
108 int cmd_stop_trace(struct ltt_session
*session
);
110 /* Consumer commands */
111 int cmd_register_consumer(struct ltt_session
*session
,
112 enum lttng_domain_type domain
,
113 const char *sock_path
, struct consumer_data
*cdata
);
114 int cmd_set_consumer_uri(struct ltt_session
*session
, size_t nb_uri
,
115 struct lttng_uri
*uris
);
116 int cmd_setup_relayd(struct ltt_session
*session
);
118 /* Listing commands */
119 ssize_t
cmd_list_domains(struct ltt_session
*session
,
120 struct lttng_domain
**domains
);
121 ssize_t
cmd_list_events(enum lttng_domain_type domain
,
122 struct ltt_session
*session
, char *channel_name
,
123 struct lttng_payload
*payload
);
124 ssize_t
cmd_list_channels(enum lttng_domain_type domain
,
125 struct ltt_session
*session
, struct lttng_channel
**channels
);
126 enum lttng_error_code
cmd_list_maps(enum lttng_domain_type domain
,
127 struct ltt_session
*session
,
128 struct lttng_map_list
**return_map_list
);
129 ssize_t
cmd_list_domains(struct ltt_session
*session
,
130 struct lttng_domain
**domains
);
131 void cmd_list_lttng_sessions(struct lttng_session
*sessions
,
132 size_t session_count
, uid_t uid
, gid_t gid
);
133 ssize_t
cmd_list_tracepoint_fields(enum lttng_domain_type domain
,
134 struct lttng_event_field
**fields
);
135 ssize_t
cmd_list_tracepoints(enum lttng_domain_type domain
,
136 struct lttng_event
**events
);
137 ssize_t
cmd_snapshot_list_outputs(struct ltt_session
*session
,
138 struct lttng_snapshot_output
**outputs
);
139 ssize_t
cmd_list_syscalls(struct lttng_event
**events
);
141 int cmd_data_pending(struct ltt_session
*session
);
144 int cmd_snapshot_add_output(struct ltt_session
*session
,
145 const struct lttng_snapshot_output
*output
, uint32_t *id
);
146 int cmd_snapshot_del_output(struct ltt_session
*session
,
147 const struct lttng_snapshot_output
*output
);
148 int cmd_snapshot_record(struct ltt_session
*session
,
149 const struct lttng_snapshot_output
*output
, int wait
);
151 int cmd_set_session_shm_path(struct ltt_session
*session
,
152 const char *shm_path
);
153 int cmd_regenerate_metadata(struct ltt_session
*session
);
154 int cmd_regenerate_statedump(struct ltt_session
*session
);
156 enum lttng_error_code
cmd_register_trigger(
157 const struct lttng_credentials
*cmd_creds
,
158 struct lttng_trigger
*trigger
,
159 struct notification_thread_handle
*notification_thread_handle
,
160 struct lttng_trigger
**return_trigger
);
161 enum lttng_error_code
cmd_unregister_trigger(
162 const struct lttng_credentials
*cmd_creds
,
163 const struct lttng_trigger
*trigger
,
164 struct notification_thread_handle
*notification_thread_handle
);
166 int cmd_list_triggers(struct command_ctx
*cmd_ctx
,
167 struct notification_thread_handle
*notification_thread_handle
,
168 struct lttng_triggers
**return_triggers
);
170 int cmd_rotate_session(struct ltt_session
*session
,
171 struct lttng_rotate_session_return
*rotate_return
,
173 enum lttng_trace_chunk_command_type command
);
174 int cmd_rotate_get_info(struct ltt_session
*session
,
175 struct lttng_rotation_get_info_return
*info_return
,
177 int cmd_rotation_set_schedule(struct ltt_session
*session
,
178 bool activate
, enum lttng_rotation_schedule_type schedule_type
,
180 struct notification_thread_handle
*notification_thread_handle
);
182 int cmd_list_map_values(const char *session_name
, const struct lttng_map
*map
,
183 const struct lttng_map_query
*map_query
,
184 struct lttng_map_content
**return_map_content
);
186 const struct cmd_completion_handler
*cmd_pop_completion_handler(void);
187 int start_kernel_session(struct ltt_kernel_session
*ksess
);
188 int stop_kernel_session(struct ltt_kernel_session
*ksess
);