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 | ||
11 | #include "context.h" | |
aa74bd72 | 12 | #include "lttng-sessiond.h" |
159b042f JG |
13 | #include "lttng/tracker.h" |
14 | #include "session.h" | |
15 | #include <common/tracker.h> | |
2f77fc4b | 16 | |
b0880ae5 JG |
17 | struct notification_thread_handle; |
18 | ||
a503e1ef JG |
19 | /* |
20 | * A callback (and associated user data) that should be run after a command | |
21 | * has been executed. No locks should be taken while executing this handler. | |
22 | * | |
23 | * The command's reply should not be sent until the handler has run and | |
24 | * completed successfully. On failure, the handler's return code should | |
25 | * be the only reply sent to the client. | |
26 | */ | |
27 | typedef enum lttng_error_code (*completion_handler_function)(void *); | |
28 | struct cmd_completion_handler { | |
29 | completion_handler_function run; | |
30 | void *data; | |
31 | }; | |
32 | ||
2f77fc4b DG |
33 | /* |
34 | * Init the command subsystem. Must be called before using any of the functions | |
35 | * above. This is called in the main() of the session daemon. | |
36 | */ | |
37 | void cmd_init(void); | |
38 | ||
39 | /* Session commands */ | |
b178f53e JG |
40 | enum lttng_error_code cmd_create_session(struct command_ctx *cmd_ctx, int sock, |
41 | struct lttng_session_descriptor **return_descriptor); | |
e32d7f27 | 42 | int cmd_destroy_session(struct ltt_session *session, |
3e3665b8 JG |
43 | struct notification_thread_handle *notification_thread_handle, |
44 | int *sock_fd); | |
2f77fc4b DG |
45 | |
46 | /* Channel commands */ | |
56a37563 JG |
47 | int cmd_disable_channel(struct ltt_session *session, |
48 | enum lttng_domain_type domain, char *channel_name); | |
7972aab2 | 49 | int cmd_enable_channel(struct ltt_session *session, |
df4f5a87 | 50 | const struct lttng_domain *domain, const struct lttng_channel *attr, |
56a37563 | 51 | int wpipe); |
159b042f JG |
52 | |
53 | /* Process attribute tracker commands */ | |
54 | enum lttng_error_code cmd_process_attr_tracker_get_tracking_policy( | |
55 | struct ltt_session *session, | |
55c9e7ca | 56 | enum lttng_domain_type domain, |
159b042f JG |
57 | enum lttng_process_attr process_attr, |
58 | enum lttng_tracking_policy *policy); | |
59 | enum lttng_error_code cmd_process_attr_tracker_set_tracking_policy( | |
60 | struct ltt_session *session, | |
61 | enum lttng_domain_type domain, | |
62 | enum lttng_process_attr process_attr, | |
63 | enum lttng_tracking_policy policy); | |
64 | enum lttng_error_code cmd_process_attr_tracker_inclusion_set_add_value( | |
65 | struct ltt_session *session, | |
55c9e7ca | 66 | enum lttng_domain_type domain, |
159b042f JG |
67 | enum lttng_process_attr process_attr, |
68 | const struct process_attr_value *value); | |
69 | enum lttng_error_code cmd_process_attr_tracker_inclusion_set_remove_value( | |
70 | struct ltt_session *session, | |
71 | enum lttng_domain_type domain, | |
72 | enum lttng_process_attr process_attr, | |
73 | const struct process_attr_value *value); | |
74 | enum lttng_error_code cmd_process_attr_tracker_get_inclusion_set( | |
75 | struct ltt_session *session, | |
76 | enum lttng_domain_type domain, | |
77 | enum lttng_process_attr process_attr, | |
78 | struct lttng_process_attr_values **values); | |
2f77fc4b DG |
79 | |
80 | /* Event commands */ | |
56a37563 JG |
81 | int cmd_disable_event(struct ltt_session *session, |
82 | enum lttng_domain_type domain, | |
df4f5a87 JG |
83 | const char *channel_name, |
84 | const struct lttng_event *event); | |
56a37563 | 85 | int cmd_add_context(struct ltt_session *session, enum lttng_domain_type domain, |
df4f5a87 | 86 | char *channel_name, const struct lttng_event_context *ctx, int kwpipe); |
56a37563 | 87 | int cmd_set_filter(struct ltt_session *session, enum lttng_domain_type domain, |
178191b3 | 88 | char *channel_name, struct lttng_event *event, |
2f77fc4b | 89 | struct lttng_filter_bytecode *bytecode); |
df4f5a87 | 90 | int cmd_enable_event(struct ltt_session *session, const struct lttng_domain *domain, |
025faf73 | 91 | char *channel_name, struct lttng_event *event, |
6b453b5e | 92 | char *filter_expression, |
db8f1377 JI |
93 | struct lttng_filter_bytecode *filter, |
94 | struct lttng_event_exclusion *exclusion, | |
95 | int wpipe); | |
2f77fc4b DG |
96 | |
97 | /* Trace session action commands */ | |
98 | int cmd_start_trace(struct ltt_session *session); | |
99 | int cmd_stop_trace(struct ltt_session *session); | |
100 | ||
101 | /* Consumer commands */ | |
56a37563 JG |
102 | int cmd_register_consumer(struct ltt_session *session, |
103 | enum lttng_domain_type domain, | |
2f77fc4b | 104 | const char *sock_path, struct consumer_data *cdata); |
bda32d56 JG |
105 | int cmd_set_consumer_uri(struct ltt_session *session, size_t nb_uri, |
106 | struct lttng_uri *uris); | |
ffe60014 | 107 | int cmd_setup_relayd(struct ltt_session *session); |
2f77fc4b DG |
108 | |
109 | /* Listing commands */ | |
110 | ssize_t cmd_list_domains(struct ltt_session *session, | |
111 | struct lttng_domain **domains); | |
56a37563 JG |
112 | ssize_t cmd_list_events(enum lttng_domain_type domain, |
113 | struct ltt_session *session, char *channel_name, | |
e368fb43 | 114 | struct lttng_payload *payload); |
56a37563 JG |
115 | ssize_t cmd_list_channels(enum lttng_domain_type domain, |
116 | struct ltt_session *session, struct lttng_channel **channels); | |
2f77fc4b DG |
117 | ssize_t cmd_list_domains(struct ltt_session *session, |
118 | struct lttng_domain **domains); | |
b178f53e JG |
119 | void cmd_list_lttng_sessions(struct lttng_session *sessions, |
120 | size_t session_count, uid_t uid, gid_t gid); | |
56a37563 | 121 | ssize_t cmd_list_tracepoint_fields(enum lttng_domain_type domain, |
2f77fc4b | 122 | struct lttng_event_field **fields); |
56a37563 JG |
123 | ssize_t cmd_list_tracepoints(enum lttng_domain_type domain, |
124 | struct lttng_event **events); | |
6dc3064a DG |
125 | ssize_t cmd_snapshot_list_outputs(struct ltt_session *session, |
126 | struct lttng_snapshot_output **outputs); | |
834978fd | 127 | ssize_t cmd_list_syscalls(struct lttng_event **events); |
2f77fc4b | 128 | |
6d805429 | 129 | int cmd_data_pending(struct ltt_session *session); |
2f77fc4b | 130 | |
6dc3064a DG |
131 | /* Snapshot */ |
132 | int cmd_snapshot_add_output(struct ltt_session *session, | |
df4f5a87 | 133 | const struct lttng_snapshot_output *output, uint32_t *id); |
6dc3064a | 134 | int cmd_snapshot_del_output(struct ltt_session *session, |
df4f5a87 | 135 | const struct lttng_snapshot_output *output); |
6dc3064a | 136 | int cmd_snapshot_record(struct ltt_session *session, |
df4f5a87 | 137 | const struct lttng_snapshot_output *output, int wait); |
6dc3064a | 138 | |
d7ba1388 MD |
139 | int cmd_set_session_shm_path(struct ltt_session *session, |
140 | const char *shm_path); | |
eded6438 | 141 | int cmd_regenerate_metadata(struct ltt_session *session); |
c2561365 | 142 | int cmd_regenerate_statedump(struct ltt_session *session); |
d7ba1388 | 143 | |
b0880ae5 JG |
144 | int cmd_register_trigger(struct command_ctx *cmd_ctx, int sock, |
145 | struct notification_thread_handle *notification_thread_handle); | |
146 | int cmd_unregister_trigger(struct command_ctx *cmd_ctx, int sock, | |
147 | struct notification_thread_handle *notification_thread_handle); | |
148 | ||
5c408ad8 | 149 | int cmd_rotate_session(struct ltt_session *session, |
7fdbed1c | 150 | struct lttng_rotate_session_return *rotate_return, |
343defc2 MD |
151 | bool quiet_rotation, |
152 | enum lttng_trace_chunk_command_type command); | |
d68c9a04 JD |
153 | int cmd_rotate_get_info(struct ltt_session *session, |
154 | struct lttng_rotation_get_info_return *info_return, | |
155 | uint64_t rotate_id); | |
66ea93b1 JG |
156 | int cmd_rotation_set_schedule(struct ltt_session *session, |
157 | bool activate, enum lttng_rotation_schedule_type schedule_type, | |
158 | uint64_t value, | |
90936dcf | 159 | struct notification_thread_handle *notification_thread_handle); |
5c408ad8 | 160 | |
a503e1ef | 161 | const struct cmd_completion_handler *cmd_pop_completion_handler(void); |
4dbe1875 MD |
162 | int start_kernel_session(struct ltt_kernel_session *ksess); |
163 | int stop_kernel_session(struct ltt_kernel_session *ksess); | |
a503e1ef | 164 | |
2f77fc4b | 165 | #endif /* CMD_H */ |