2 * Copyright (C) 2012 David Goulet <dgoulet@efficios.com>
4 * SPDX-License-Identifier: GPL-2.0-only
13 #include "lttng-sessiond.h"
15 struct notification_thread_handle
;
18 * A callback (and associated user data) that should be run after a command
19 * has been executed. No locks should be taken while executing this handler.
21 * The command's reply should not be sent until the handler has run and
22 * completed successfully. On failure, the handler's return code should
23 * be the only reply sent to the client.
25 typedef enum lttng_error_code (*completion_handler_function
)(void *);
26 struct cmd_completion_handler
{
27 completion_handler_function run
;
32 * Init the command subsystem. Must be called before using any of the functions
33 * above. This is called in the main() of the session daemon.
37 /* Session commands */
38 enum lttng_error_code
cmd_create_session(struct command_ctx
*cmd_ctx
, int sock
,
39 struct lttng_session_descriptor
**return_descriptor
);
40 int cmd_destroy_session(struct ltt_session
*session
,
41 struct notification_thread_handle
*notification_thread_handle
,
44 /* Channel commands */
45 int cmd_disable_channel(struct ltt_session
*session
,
46 enum lttng_domain_type domain
, char *channel_name
);
47 int cmd_enable_channel(struct ltt_session
*session
,
48 const struct lttng_domain
*domain
, const struct lttng_channel
*attr
,
50 int cmd_track_id(struct ltt_session
*session
,
51 enum lttng_tracker_type tracker_type
,
52 enum lttng_domain_type domain
,
53 const struct lttng_tracker_id
*id
);
54 int cmd_untrack_id(struct ltt_session
*session
,
55 enum lttng_tracker_type tracker_type
,
56 enum lttng_domain_type domain
,
57 const struct lttng_tracker_id
*id
);
60 int cmd_disable_event(struct ltt_session
*session
,
61 enum lttng_domain_type domain
,
62 const char *channel_name
,
63 const struct lttng_event
*event
);
64 int cmd_add_context(struct ltt_session
*session
, enum lttng_domain_type domain
,
65 char *channel_name
, const struct lttng_event_context
*ctx
, int kwpipe
);
66 int cmd_set_filter(struct ltt_session
*session
, enum lttng_domain_type domain
,
67 char *channel_name
, struct lttng_event
*event
,
68 struct lttng_filter_bytecode
*bytecode
);
69 int cmd_enable_event(struct ltt_session
*session
, const struct lttng_domain
*domain
,
70 char *channel_name
, struct lttng_event
*event
,
71 char *filter_expression
,
72 struct lttng_filter_bytecode
*filter
,
73 struct lttng_event_exclusion
*exclusion
,
76 /* Trace session action commands */
77 int cmd_start_trace(struct ltt_session
*session
);
78 int cmd_stop_trace(struct ltt_session
*session
);
80 /* Consumer commands */
81 int cmd_register_consumer(struct ltt_session
*session
,
82 enum lttng_domain_type domain
,
83 const char *sock_path
, struct consumer_data
*cdata
);
84 int cmd_set_consumer_uri(struct ltt_session
*session
, size_t nb_uri
,
85 struct lttng_uri
*uris
);
86 int cmd_setup_relayd(struct ltt_session
*session
);
88 /* Listing commands */
89 ssize_t
cmd_list_domains(struct ltt_session
*session
,
90 struct lttng_domain
**domains
);
91 ssize_t
cmd_list_events(enum lttng_domain_type domain
,
92 struct ltt_session
*session
, char *channel_name
,
93 struct lttng_event
**events
, size_t *total_size
);
94 ssize_t
cmd_list_channels(enum lttng_domain_type domain
,
95 struct ltt_session
*session
, struct lttng_channel
**channels
);
96 ssize_t
cmd_list_domains(struct ltt_session
*session
,
97 struct lttng_domain
**domains
);
98 void cmd_list_lttng_sessions(struct lttng_session
*sessions
,
99 size_t session_count
, uid_t uid
, gid_t gid
);
100 ssize_t
cmd_list_tracepoint_fields(enum lttng_domain_type domain
,
101 struct lttng_event_field
**fields
);
102 ssize_t
cmd_list_tracepoints(enum lttng_domain_type domain
,
103 struct lttng_event
**events
);
104 ssize_t
cmd_snapshot_list_outputs(struct ltt_session
*session
,
105 struct lttng_snapshot_output
**outputs
);
106 ssize_t
cmd_list_syscalls(struct lttng_event
**events
);
107 int cmd_list_tracker_ids(enum lttng_tracker_type tracker_type
,
108 struct ltt_session
*session
,
109 enum lttng_domain_type domain
,
110 struct lttng_tracker_ids
**ids
);
112 int cmd_data_pending(struct ltt_session
*session
);
115 int cmd_snapshot_add_output(struct ltt_session
*session
,
116 const struct lttng_snapshot_output
*output
, uint32_t *id
);
117 int cmd_snapshot_del_output(struct ltt_session
*session
,
118 const struct lttng_snapshot_output
*output
);
119 int cmd_snapshot_record(struct ltt_session
*session
,
120 const struct lttng_snapshot_output
*output
, int wait
);
122 int cmd_set_session_shm_path(struct ltt_session
*session
,
123 const char *shm_path
);
124 int cmd_regenerate_metadata(struct ltt_session
*session
);
125 int cmd_regenerate_statedump(struct ltt_session
*session
);
127 int cmd_register_trigger(struct command_ctx
*cmd_ctx
, int sock
,
128 struct notification_thread_handle
*notification_thread_handle
);
129 int cmd_unregister_trigger(struct command_ctx
*cmd_ctx
, int sock
,
130 struct notification_thread_handle
*notification_thread_handle
);
132 int cmd_rotate_session(struct ltt_session
*session
,
133 struct lttng_rotate_session_return
*rotate_return
,
135 enum lttng_trace_chunk_command_type command
);
136 int cmd_rotate_get_info(struct ltt_session
*session
,
137 struct lttng_rotation_get_info_return
*info_return
,
139 int cmd_rotation_set_schedule(struct ltt_session
*session
,
140 bool activate
, enum lttng_rotation_schedule_type schedule_type
,
142 struct notification_thread_handle
*notification_thread_handle
);
144 const struct cmd_completion_handler
*cmd_pop_completion_handler(void);
145 int start_kernel_session(struct ltt_kernel_session
*ksess
);
146 int stop_kernel_session(struct ltt_kernel_session
*ksess
);