2 * Copyright (C) 2014 - Jonathan Rajotte <jonathan.r.julien@gmail.com>
3 * - Olivier Cotte <olivier.cotte@polymtl.ca>
4 * Copyright (C) 2016 - Jérémie Galarneau <jeremie.galarneau@efficios.com>
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License, version 2 only, as
8 * published by the Free Software Foundation.
10 * This program is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
15 * You should have received a copy of the GNU General Public License along with
16 * this program; if not, write to the Free Software Foundation, Inc., 51
17 * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21 #include <common/config/session-config.h>
22 #include <common/defaults.h>
23 #include <lttng/snapshot-internal.h>
24 #include <lttng/channel.h>
29 #define MI_SCHEMA_MAJOR_VERSION 3
30 #define MI_SCHEMA_MINOR_VERSION 0
32 /* Machine interface namespace URI */
33 LTTNG_HIDDEN
const char * const mi_lttng_xmlns
= "xmlns";
34 LTTNG_HIDDEN
const char * const mi_lttng_xmlns_xsi
= "xmlns:xsi";
35 LTTNG_HIDDEN
const char * const mi_lttng_w3_schema_uri
= "http://www.w3.org/2001/XMLSchema-instance";
36 LTTNG_HIDDEN
const char * const mi_lttng_schema_location
= "xsi:schemaLocation";
37 LTTNG_HIDDEN
const char * const mi_lttng_schema_location_uri
=
38 DEFAULT_LTTNG_MI_NAMESPACE
" "
39 "http://lttng.org/xml/schemas/lttng-mi/" XSTR(MI_SCHEMA_MAJOR_VERSION
)
40 "/lttng-mi-" XSTR(MI_SCHEMA_MAJOR_VERSION
) "."
41 XSTR(MI_SCHEMA_MINOR_VERSION
) ".xsd";
42 LTTNG_HIDDEN
const char * const mi_lttng_schema_version
= "schemaVersion";
43 LTTNG_HIDDEN
const char * const mi_lttng_schema_version_value
= XSTR(MI_SCHEMA_MAJOR_VERSION
)
44 "." XSTR(MI_SCHEMA_MINOR_VERSION
);
46 /* Strings related to command */
47 const char * const mi_lttng_element_command
= "command";
48 const char * const mi_lttng_element_command_action
= "snapshot_action";
49 const char * const mi_lttng_element_command_add_context
= "add-context";
50 const char * const mi_lttng_element_command_create
= "create";
51 const char * const mi_lttng_element_command_destroy
= "destroy";
52 const char * const mi_lttng_element_command_disable_channel
= "disable-channel";
53 const char * const mi_lttng_element_command_disable_event
= "disable-event";
54 const char * const mi_lttng_element_command_enable_channels
= "enable-channel";
55 const char * const mi_lttng_element_command_enable_event
= "enable-event";
56 const char * const mi_lttng_element_command_list
= "list";
57 const char * const mi_lttng_element_command_load
= "load";
58 LTTNG_HIDDEN
const char * const mi_lttng_element_command_metadata
= "metadata";
59 LTTNG_HIDDEN
const char * const mi_lttng_element_command_metadata_action
= "metadata_action";
60 LTTNG_HIDDEN
const char * const mi_lttng_element_command_regenerate
= "regenerate";
61 LTTNG_HIDDEN
const char * const mi_lttng_element_command_regenerate_action
= "regenerate_action";
62 const char * const mi_lttng_element_command_name
= "name";
63 const char * const mi_lttng_element_command_output
= "output";
64 const char * const mi_lttng_element_command_save
= "save";
65 const char * const mi_lttng_element_command_set_session
= "set-session";
66 const char * const mi_lttng_element_command_snapshot
= "snapshot";
67 const char * const mi_lttng_element_command_snapshot_add
= "add_snapshot";
68 const char * const mi_lttng_element_command_snapshot_del
= "del_snapshot";
69 const char * const mi_lttng_element_command_snapshot_list
= "list_snapshot";
70 const char * const mi_lttng_element_command_snapshot_record
= "record_snapshot";
71 const char * const mi_lttng_element_command_start
= "start";
72 const char * const mi_lttng_element_command_stop
= "stop";
73 const char * const mi_lttng_element_command_success
= "success";
74 const char * const mi_lttng_element_command_track
= "track";
75 const char * const mi_lttng_element_command_untrack
= "untrack";
76 const char * const mi_lttng_element_command_version
= "version";
77 const char * const mi_lttng_element_command_rotate
= "rotate";
79 /* Strings related to version command */
80 const char * const mi_lttng_element_version
= "version";
81 const char * const mi_lttng_element_version_commit
= "commit";
82 const char * const mi_lttng_element_version_description
= "description";
83 const char * const mi_lttng_element_version_license
= "license";
84 const char * const mi_lttng_element_version_major
= "major";
85 const char * const mi_lttng_element_version_minor
= "minor";
86 const char * const mi_lttng_element_version_patch_level
= "patchLevel";
87 const char * const mi_lttng_element_version_str
= "string";
88 const char * const mi_lttng_element_version_web
= "url";
90 /* String related to a lttng_event_field */
91 const char * const mi_lttng_element_event_field
= "event_field";
92 const char * const mi_lttng_element_event_fields
= "event_fields";
94 /* String related to lttng_event_perf_counter_ctx */
95 const char * const mi_lttng_element_perf_counter_context
= "perf";
97 /* Strings related to pid */
98 const char * const mi_lttng_element_pid_id
= "id";
100 /* Strings related to save command */
101 const char * const mi_lttng_element_save
= "save";
103 /* Strings related to load command */
104 const char * const mi_lttng_element_load
= "load";
105 LTTNG_HIDDEN
const char * const mi_lttng_element_load_overrides
= "overrides";
106 LTTNG_HIDDEN
const char * const mi_lttng_element_load_override_url
= "url";
108 /* General elements of mi_lttng */
109 const char * const mi_lttng_element_empty
= "";
110 const char * const mi_lttng_element_id
= "id";
111 const char * const mi_lttng_element_nowrite
= "nowrite";
112 const char * const mi_lttng_element_success
= "success";
113 const char * const mi_lttng_element_type_enum
= "ENUM";
114 const char * const mi_lttng_element_type_float
= "FLOAT";
115 const char * const mi_lttng_element_type_integer
= "INTEGER";
116 const char * const mi_lttng_element_type_other
= "OTHER";
117 const char * const mi_lttng_element_type_string
= "STRING";
119 /* String related to loglevel */
120 const char * const mi_lttng_loglevel_str_alert
= "TRACE_ALERT";
121 const char * const mi_lttng_loglevel_str_crit
= "TRACE_CRIT";
122 const char * const mi_lttng_loglevel_str_debug
= "TRACE_DEBUG";
123 const char * const mi_lttng_loglevel_str_debug_function
= "TRACE_DEBUG_FUNCTION";
124 const char * const mi_lttng_loglevel_str_debug_line
= "TRACE_DEBUG_LINE";
125 const char * const mi_lttng_loglevel_str_debug_module
= "TRACE_DEBUG_MODULE";
126 const char * const mi_lttng_loglevel_str_debug_process
= "TRACE_DEBUG_PROCESS";
127 const char * const mi_lttng_loglevel_str_debug_program
= "TRACE_DEBUG_PROGRAM";
128 const char * const mi_lttng_loglevel_str_debug_system
= "TRACE_DEBUG_SYSTEM";
129 const char * const mi_lttng_loglevel_str_debug_unit
= "TRACE_DEBUG_UNIT";
130 const char * const mi_lttng_loglevel_str_emerg
= "TRACE_EMERG";
131 const char * const mi_lttng_loglevel_str_err
= "TRACE_ERR";
132 const char * const mi_lttng_loglevel_str_info
= "TRACE_INFO";
133 const char * const mi_lttng_loglevel_str_notice
= "TRACE_NOTICE";
134 const char * const mi_lttng_loglevel_str_unknown
= "UNKNOWN";
135 const char * const mi_lttng_loglevel_str_warning
= "TRACE_WARNING";
137 /* String related to loglevel JUL */
138 const char * const mi_lttng_loglevel_str_jul_all
= "JUL_ALL";
139 const char * const mi_lttng_loglevel_str_jul_config
= "JUL_CONFIG";
140 const char * const mi_lttng_loglevel_str_jul_fine
= "JUL_FINE";
141 const char * const mi_lttng_loglevel_str_jul_finer
= "JUL_FINER";
142 const char * const mi_lttng_loglevel_str_jul_finest
= "JUL_FINEST";
143 const char * const mi_lttng_loglevel_str_jul_info
= "JUL_INFO";
144 const char * const mi_lttng_loglevel_str_jul_off
= "JUL_OFF";
145 const char * const mi_lttng_loglevel_str_jul_severe
= "JUL_SEVERE";
146 const char * const mi_lttng_loglevel_str_jul_warning
= "JUL_WARNING";
148 /* String related to loglevel LOG4J */
149 const char * const mi_lttng_loglevel_str_log4j_off
= "LOG4J_OFF";
150 const char * const mi_lttng_loglevel_str_log4j_fatal
= "LOG4J_FATAL";
151 const char * const mi_lttng_loglevel_str_log4j_error
= "LOG4J_ERROR";
152 const char * const mi_lttng_loglevel_str_log4j_warn
= "LOG4J_WARN";
153 const char * const mi_lttng_loglevel_str_log4j_info
= "LOG4J_INFO";
154 const char * const mi_lttng_loglevel_str_log4j_debug
= "LOG4J_DEBUG";
155 const char * const mi_lttng_loglevel_str_log4j_trace
= "LOG4J_TRACE";
156 const char * const mi_lttng_loglevel_str_log4j_all
= "LOG4J_ALL";
158 /* String related to loglevel Python */
159 const char * const mi_lttng_loglevel_str_python_critical
= "PYTHON_CRITICAL";
160 const char * const mi_lttng_loglevel_str_python_error
= "PYTHON_ERROR";
161 const char * const mi_lttng_loglevel_str_python_warning
= "PYTHON_WARNING";
162 const char * const mi_lttng_loglevel_str_python_info
= "PYTHON_INFO";
163 const char * const mi_lttng_loglevel_str_python_debug
= "PYTHON_DEBUG";
164 const char * const mi_lttng_loglevel_str_python_notset
= "PYTHON_NOTSET";
166 /* String related to loglevel type */
167 const char * const mi_lttng_loglevel_type_all
= "ALL";
168 const char * const mi_lttng_loglevel_type_range
= "RANGE";
169 const char * const mi_lttng_loglevel_type_single
= "SINGLE";
170 const char * const mi_lttng_loglevel_type_unknown
= "UNKNOWN";
172 /* String related to a lttng_snapshot_output */
173 const char * const mi_lttng_element_snapshot_ctrl_url
= "ctrl_url";
174 const char * const mi_lttng_element_snapshot_data_url
= "data_url";
175 const char * const mi_lttng_element_snapshot_max_size
= "max_size";
176 const char * const mi_lttng_element_snapshot_n_ptr
= "n_ptr";
177 const char * const mi_lttng_element_snapshot_session_name
= "session_name";
178 const char * const mi_lttng_element_snapshots
= "snapshots";
180 /* String related to track/untrack command */
181 const char * const mi_lttng_element_track_untrack_all_wildcard
= "*";
183 LTTNG_HIDDEN
const char * const mi_lttng_element_session_name
= "session_name";
185 /* String related to rotate command */
186 LTTNG_HIDDEN
const char * const mi_lttng_element_rotation
= "rotation";
187 LTTNG_HIDDEN
const char * const mi_lttng_element_rotations
= "rotations";
188 LTTNG_HIDDEN
const char * const mi_lttng_element_rotate_status
= "status";
190 /* Deprecated symbols preserved for ABI compatibility. */
191 const char * const mi_lttng_context_type_perf_counter
;
192 const char * const mi_lttng_context_type_perf_cpu_counter
;
193 const char * const mi_lttng_context_type_perf_thread_counter
;
194 const char * const mi_lttng_element_track_untrack_pid_target
;
195 const char * const mi_lttng_element_track_untrack_targets
;
196 const char * const mi_lttng_element_calibrate
;
197 const char * const mi_lttng_element_calibrate_function
;
198 const char * const mi_lttng_element_command_calibrate
;
200 /* This is a merge of jul loglevel and regular loglevel
201 * Those should never overlap by definition
202 * (see struct lttng_event loglevel)
205 const char *mi_lttng_loglevel_string(int value
, enum lttng_domain_type domain
)
208 case LTTNG_DOMAIN_KERNEL
:
209 case LTTNG_DOMAIN_UST
:
212 return mi_lttng_element_empty
;
213 case LTTNG_LOGLEVEL_EMERG
:
214 return mi_lttng_loglevel_str_emerg
;
215 case LTTNG_LOGLEVEL_ALERT
:
216 return mi_lttng_loglevel_str_alert
;
217 case LTTNG_LOGLEVEL_CRIT
:
218 return mi_lttng_loglevel_str_crit
;
219 case LTTNG_LOGLEVEL_ERR
:
220 return mi_lttng_loglevel_str_err
;
221 case LTTNG_LOGLEVEL_WARNING
:
222 return mi_lttng_loglevel_str_warning
;
223 case LTTNG_LOGLEVEL_NOTICE
:
224 return mi_lttng_loglevel_str_notice
;
225 case LTTNG_LOGLEVEL_INFO
:
226 return mi_lttng_loglevel_str_info
;
227 case LTTNG_LOGLEVEL_DEBUG_SYSTEM
:
228 return mi_lttng_loglevel_str_debug_system
;
229 case LTTNG_LOGLEVEL_DEBUG_PROGRAM
:
230 return mi_lttng_loglevel_str_debug_program
;
231 case LTTNG_LOGLEVEL_DEBUG_PROCESS
:
232 return mi_lttng_loglevel_str_debug_process
;
233 case LTTNG_LOGLEVEL_DEBUG_MODULE
:
234 return mi_lttng_loglevel_str_debug_module
;
235 case LTTNG_LOGLEVEL_DEBUG_UNIT
:
236 return mi_lttng_loglevel_str_debug_unit
;
237 case LTTNG_LOGLEVEL_DEBUG_FUNCTION
:
238 return mi_lttng_loglevel_str_debug_function
;
239 case LTTNG_LOGLEVEL_DEBUG_LINE
:
240 return mi_lttng_loglevel_str_debug_line
;
241 case LTTNG_LOGLEVEL_DEBUG
:
242 return mi_lttng_loglevel_str_debug
;
244 return mi_lttng_loglevel_str_unknown
;
247 case LTTNG_DOMAIN_LOG4J
:
250 return mi_lttng_element_empty
;
251 case LTTNG_LOGLEVEL_LOG4J_OFF
:
252 return mi_lttng_loglevel_str_log4j_off
;
253 case LTTNG_LOGLEVEL_LOG4J_FATAL
:
254 return mi_lttng_loglevel_str_log4j_fatal
;
255 case LTTNG_LOGLEVEL_LOG4J_ERROR
:
256 return mi_lttng_loglevel_str_log4j_error
;
257 case LTTNG_LOGLEVEL_LOG4J_WARN
:
258 return mi_lttng_loglevel_str_log4j_warn
;
259 case LTTNG_LOGLEVEL_LOG4J_INFO
:
260 return mi_lttng_loglevel_str_log4j_info
;
261 case LTTNG_LOGLEVEL_LOG4J_DEBUG
:
262 return mi_lttng_loglevel_str_log4j_debug
;
263 case LTTNG_LOGLEVEL_LOG4J_TRACE
:
264 return mi_lttng_loglevel_str_log4j_trace
;
265 case LTTNG_LOGLEVEL_LOG4J_ALL
:
266 return mi_lttng_loglevel_str_log4j_all
;
268 return mi_lttng_loglevel_str_unknown
;
271 case LTTNG_DOMAIN_JUL
:
274 return mi_lttng_element_empty
;
275 case LTTNG_LOGLEVEL_JUL_OFF
:
276 return mi_lttng_loglevel_str_jul_off
;
277 case LTTNG_LOGLEVEL_JUL_SEVERE
:
278 return mi_lttng_loglevel_str_jul_severe
;
279 case LTTNG_LOGLEVEL_JUL_WARNING
:
280 return mi_lttng_loglevel_str_jul_warning
;
281 case LTTNG_LOGLEVEL_JUL_INFO
:
282 return mi_lttng_loglevel_str_jul_info
;
283 case LTTNG_LOGLEVEL_JUL_CONFIG
:
284 return mi_lttng_loglevel_str_jul_config
;
285 case LTTNG_LOGLEVEL_JUL_FINE
:
286 return mi_lttng_loglevel_str_jul_fine
;
287 case LTTNG_LOGLEVEL_JUL_FINER
:
288 return mi_lttng_loglevel_str_jul_finer
;
289 case LTTNG_LOGLEVEL_JUL_FINEST
:
290 return mi_lttng_loglevel_str_jul_finest
;
291 case LTTNG_LOGLEVEL_JUL_ALL
:
292 return mi_lttng_loglevel_str_jul_all
;
294 return mi_lttng_loglevel_str_unknown
;
297 case LTTNG_DOMAIN_PYTHON
:
299 case LTTNG_LOGLEVEL_PYTHON_CRITICAL
:
300 return mi_lttng_loglevel_str_python_critical
;
301 case LTTNG_LOGLEVEL_PYTHON_ERROR
:
302 return mi_lttng_loglevel_str_python_error
;
303 case LTTNG_LOGLEVEL_PYTHON_WARNING
:
304 return mi_lttng_loglevel_str_python_warning
;
305 case LTTNG_LOGLEVEL_PYTHON_INFO
:
306 return mi_lttng_loglevel_str_python_info
;
307 case LTTNG_LOGLEVEL_PYTHON_DEBUG
:
308 return mi_lttng_loglevel_str_python_debug
;
309 case LTTNG_LOGLEVEL_PYTHON_NOTSET
:
310 return mi_lttng_loglevel_str_python_notset
;
312 return mi_lttng_loglevel_str_unknown
;
316 return mi_lttng_loglevel_str_unknown
;
321 const char *mi_lttng_logleveltype_string(enum lttng_loglevel_type value
)
324 case LTTNG_EVENT_LOGLEVEL_ALL
:
325 return mi_lttng_loglevel_type_all
;
326 case LTTNG_EVENT_LOGLEVEL_RANGE
:
327 return mi_lttng_loglevel_type_range
;
328 case LTTNG_EVENT_LOGLEVEL_SINGLE
:
329 return mi_lttng_loglevel_type_single
;
331 return mi_lttng_loglevel_type_unknown
;
336 const char *mi_lttng_eventtype_string(enum lttng_event_type value
)
339 case LTTNG_EVENT_ALL
:
340 return config_event_type_all
;
341 case LTTNG_EVENT_TRACEPOINT
:
342 return config_event_type_tracepoint
;
343 case LTTNG_EVENT_PROBE
:
344 return config_event_type_probe
;
345 case LTTNG_EVENT_FUNCTION
:
346 return config_event_type_function
;
347 case LTTNG_EVENT_FUNCTION_ENTRY
:
348 return config_event_type_function_entry
;
349 case LTTNG_EVENT_SYSCALL
:
350 return config_event_type_syscall
;
351 case LTTNG_EVENT_NOOP
:
352 return config_event_type_noop
;
354 return mi_lttng_element_empty
;
359 const char *mi_lttng_event_contexttype_string(enum lttng_event_context_type val
)
362 case LTTNG_EVENT_CONTEXT_PID
:
363 return config_event_context_pid
;
364 case LTTNG_EVENT_CONTEXT_PROCNAME
:
365 return config_event_context_procname
;
366 case LTTNG_EVENT_CONTEXT_PRIO
:
367 return config_event_context_prio
;
368 case LTTNG_EVENT_CONTEXT_NICE
:
369 return config_event_context_nice
;
370 case LTTNG_EVENT_CONTEXT_VPID
:
371 return config_event_context_vpid
;
372 case LTTNG_EVENT_CONTEXT_TID
:
373 return config_event_context_tid
;
374 case LTTNG_EVENT_CONTEXT_VTID
:
375 return config_event_context_vtid
;
376 case LTTNG_EVENT_CONTEXT_PPID
:
377 return config_event_context_ppid
;
378 case LTTNG_EVENT_CONTEXT_VPPID
:
379 return config_event_context_vppid
;
380 case LTTNG_EVENT_CONTEXT_PTHREAD_ID
:
381 return config_event_context_pthread_id
;
382 case LTTNG_EVENT_CONTEXT_HOSTNAME
:
383 return config_event_context_hostname
;
384 case LTTNG_EVENT_CONTEXT_IP
:
385 return config_event_context_ip
;
386 case LTTNG_EVENT_CONTEXT_INTERRUPTIBLE
:
387 return config_event_context_interruptible
;
388 case LTTNG_EVENT_CONTEXT_PREEMPTIBLE
:
389 return config_event_context_preemptible
;
390 case LTTNG_EVENT_CONTEXT_NEED_RESCHEDULE
:
391 return config_event_context_need_reschedule
;
392 case LTTNG_EVENT_CONTEXT_MIGRATABLE
:
393 return config_event_context_migratable
;
400 const char *mi_lttng_eventfieldtype_string(enum lttng_event_field_type val
)
403 case(LTTNG_EVENT_FIELD_INTEGER
):
404 return mi_lttng_element_type_integer
;
405 case(LTTNG_EVENT_FIELD_ENUM
):
406 return mi_lttng_element_type_enum
;
407 case(LTTNG_EVENT_FIELD_FLOAT
):
408 return mi_lttng_element_type_float
;
409 case(LTTNG_EVENT_FIELD_STRING
):
410 return mi_lttng_element_type_string
;
412 return mi_lttng_element_type_other
;
417 const char *mi_lttng_domaintype_string(enum lttng_domain_type value
)
419 /* Note: This is a *duplicate* of get_domain_str from bin/lttng/utils.c */
421 case LTTNG_DOMAIN_KERNEL
:
422 return config_domain_type_kernel
;
423 case LTTNG_DOMAIN_UST
:
424 return config_domain_type_ust
;
425 case LTTNG_DOMAIN_JUL
:
426 return config_domain_type_jul
;
427 case LTTNG_DOMAIN_LOG4J
:
428 return config_domain_type_log4j
;
429 case LTTNG_DOMAIN_PYTHON
:
430 return config_domain_type_python
;
432 /* Should not have an unknown domain */
439 const char *mi_lttng_buffertype_string(enum lttng_buffer_type value
)
442 case LTTNG_BUFFER_PER_PID
:
443 return config_buffer_type_per_pid
;
444 case LTTNG_BUFFER_PER_UID
:
445 return config_buffer_type_per_uid
;
446 case LTTNG_BUFFER_GLOBAL
:
447 return config_buffer_type_global
;
449 /* Should not have an unknow buffer type */
456 struct mi_writer
*mi_lttng_writer_create(int fd_output
, int mi_output_type
)
458 struct mi_writer
*mi_writer
;
460 mi_writer
= zmalloc(sizeof(struct mi_writer
));
462 PERROR("zmalloc mi_writer_create");
465 if (mi_output_type
== LTTNG_MI_XML
) {
466 mi_writer
->writer
= config_writer_create(fd_output
, 0);
467 if (!mi_writer
->writer
) {
470 mi_writer
->type
= LTTNG_MI_XML
;
484 int mi_lttng_writer_destroy(struct mi_writer
*writer
)
493 ret
= config_writer_destroy(writer
->writer
);
504 int mi_lttng_writer_command_open(struct mi_writer
*writer
, const char *command
)
509 * A command is always the MI's root node, it must declare the current
510 * namespace and schema URIs and the schema's version.
512 ret
= config_writer_open_element(writer
->writer
,
513 mi_lttng_element_command
);
518 ret
= config_writer_write_attribute(writer
->writer
,
519 mi_lttng_xmlns
, DEFAULT_LTTNG_MI_NAMESPACE
);
524 ret
= config_writer_write_attribute(writer
->writer
,
525 mi_lttng_xmlns_xsi
, mi_lttng_w3_schema_uri
);
530 ret
= config_writer_write_attribute(writer
->writer
,
531 mi_lttng_schema_location
,
532 mi_lttng_schema_location_uri
);
537 ret
= config_writer_write_attribute(writer
->writer
,
538 mi_lttng_schema_version
,
539 mi_lttng_schema_version_value
);
544 ret
= mi_lttng_writer_write_element_string(writer
,
545 mi_lttng_element_command_name
, command
);
551 int mi_lttng_writer_command_close(struct mi_writer
*writer
)
553 return mi_lttng_writer_close_element(writer
);
557 int mi_lttng_writer_open_element(struct mi_writer
*writer
,
558 const char *element_name
)
560 return config_writer_open_element(writer
->writer
, element_name
);
564 int mi_lttng_writer_close_element(struct mi_writer
*writer
)
566 return config_writer_close_element(writer
->writer
);
570 int mi_lttng_close_multi_element(struct mi_writer
*writer
,
571 unsigned int nb_element
)
575 if (nb_element
< 1) {
579 for (i
= 0; i
< nb_element
; i
++) {
580 ret
= mi_lttng_writer_close_element(writer
);
590 int mi_lttng_writer_write_element_unsigned_int(struct mi_writer
*writer
,
591 const char *element_name
, uint64_t value
)
593 return config_writer_write_element_unsigned_int(writer
->writer
,
594 element_name
, value
);
598 int mi_lttng_writer_write_element_signed_int(struct mi_writer
*writer
,
599 const char *element_name
, int64_t value
)
601 return config_writer_write_element_signed_int(writer
->writer
,
602 element_name
, value
);
606 int mi_lttng_writer_write_element_bool(struct mi_writer
*writer
,
607 const char *element_name
, int value
)
609 return config_writer_write_element_bool(writer
->writer
,
610 element_name
, value
);
614 int mi_lttng_writer_write_element_string(struct mi_writer
*writer
,
615 const char *element_name
, const char *value
)
617 return config_writer_write_element_string(writer
->writer
,
618 element_name
, value
);
622 int mi_lttng_version(struct mi_writer
*writer
, struct mi_lttng_version
*version
,
623 const char *lttng_description
, const char *lttng_license
)
628 ret
= mi_lttng_writer_open_element(writer
, mi_lttng_element_version
);
633 /* Version string (contain info like rc etc.) */
634 ret
= mi_lttng_writer_write_element_string(writer
,
635 mi_lttng_element_version_str
, version
->version
);
640 /* Major version number */
641 ret
= mi_lttng_writer_write_element_unsigned_int(writer
,
642 mi_lttng_element_version_major
, version
->version_major
);
647 /* Minor version number */
648 ret
= mi_lttng_writer_write_element_unsigned_int(writer
,
649 mi_lttng_element_version_minor
, version
->version_minor
);
654 /* Commit version number */
655 ret
= mi_lttng_writer_write_element_string(writer
,
656 mi_lttng_element_version_commit
, version
->version_commit
);
662 ret
= mi_lttng_writer_write_element_unsigned_int(writer
,
663 mi_lttng_element_version_patch_level
, version
->version_patchlevel
);
668 /* Name of the version */
669 ret
= mi_lttng_writer_write_element_string(writer
,
670 config_element_name
, version
->version_name
);
675 /* Description mostly related to beer... */
676 ret
= mi_lttng_writer_write_element_string(writer
,
677 mi_lttng_element_version_description
, lttng_description
);
683 ret
= mi_lttng_writer_write_element_string(writer
,
684 mi_lttng_element_version_web
, version
->package_url
);
689 /* License: free as in free beer...no...*speech* */
690 ret
= mi_lttng_writer_write_element_string(writer
,
691 mi_lttng_element_version_license
, lttng_license
);
696 /* Close version element */
697 ret
= mi_lttng_writer_close_element(writer
);
704 int mi_lttng_sessions_open(struct mi_writer
*writer
)
706 return mi_lttng_writer_open_element(writer
, config_element_sessions
);
710 int mi_lttng_session(struct mi_writer
*writer
,
711 struct lttng_session
*session
, int is_open
)
717 /* Open sessions element */
718 ret
= mi_lttng_writer_open_element(writer
,
719 config_element_session
);
724 /* Name of the session */
725 ret
= mi_lttng_writer_write_element_string(writer
,
726 config_element_name
, session
->name
);
732 ret
= mi_lttng_writer_write_element_string(writer
,
733 config_element_path
, session
->path
);
739 ret
= mi_lttng_writer_write_element_bool(writer
,
740 config_element_enabled
, session
->enabled
);
746 ret
= mi_lttng_writer_write_element_unsigned_int(writer
,
747 config_element_snapshot_mode
, session
->snapshot_mode
);
752 /* Live timer interval in usec */
753 ret
= mi_lttng_writer_write_element_unsigned_int(writer
,
754 config_element_live_timer_interval
,
755 session
->live_timer_interval
);
761 /* Closing session element */
762 ret
= mi_lttng_writer_close_element(writer
);
770 int mi_lttng_domains_open(struct mi_writer
*writer
)
772 return mi_lttng_writer_open_element(writer
, config_element_domains
);
776 int mi_lttng_domain(struct mi_writer
*writer
,
777 struct lttng_domain
*domain
, int is_open
)
780 const char *str_domain
;
781 const char *str_buffer
;
785 /* Open domain element */
786 ret
= mi_lttng_writer_open_element(writer
, config_element_domain
);
792 str_domain
= mi_lttng_domaintype_string(domain
->type
);
793 ret
= mi_lttng_writer_write_element_string(writer
, config_element_type
,
800 str_buffer
= mi_lttng_buffertype_string(domain
->buf_type
);
801 ret
= mi_lttng_writer_write_element_string(writer
,
802 config_element_buffer_type
, str_buffer
);
808 * This union is not currently used and was added for
809 * future ust domain support.
814 /* Closing domain element */
815 ret
= mi_lttng_writer_close_element(writer
);
824 int mi_lttng_channels_open(struct mi_writer
*writer
)
826 return mi_lttng_writer_open_element(writer
, config_element_channels
);
830 int mi_lttng_channel(struct mi_writer
*writer
,
831 struct lttng_channel
*channel
, int is_open
)
837 /* Opening channel element */
838 ret
= mi_lttng_writer_open_element(writer
, config_element_channel
);
844 ret
= mi_lttng_writer_write_element_string(writer
, config_element_name
,
851 ret
= mi_lttng_writer_write_element_bool(writer
,
852 config_element_enabled
, channel
->enabled
);
858 ret
= mi_lttng_channel_attr(writer
, &channel
->attr
);
864 /* Closing channel element */
865 ret
= mi_lttng_writer_close_element(writer
);
875 int mi_lttng_channel_attr(struct mi_writer
*writer
,
876 struct lttng_channel_attr
*attr
)
879 struct lttng_channel
*chan
= caa_container_of(attr
,
880 struct lttng_channel
, attr
);
881 uint64_t discarded_events
, lost_packets
, monitor_timer_interval
;
882 int64_t blocking_timeout
;
886 ret
= lttng_channel_get_discarded_event_count(chan
, &discarded_events
);
891 ret
= lttng_channel_get_lost_packet_count(chan
, &lost_packets
);
896 ret
= lttng_channel_get_monitor_timer_interval(chan
,
897 &monitor_timer_interval
);
902 ret
= lttng_channel_get_blocking_timeout(chan
,
908 /* Opening Attributes */
909 ret
= mi_lttng_writer_open_element(writer
, config_element_attributes
);
915 ret
= mi_lttng_writer_write_element_string(writer
,
916 config_element_overwrite_mode
,
917 attr
->overwrite
? config_overwrite_mode_overwrite
:
918 config_overwrite_mode_discard
);
923 /* Sub buffer size in byte */
924 ret
= mi_lttng_writer_write_element_unsigned_int(writer
,
925 config_element_subbuf_size
, attr
->subbuf_size
);
930 /* Number of subbuffer (power of two) */
931 ret
= mi_lttng_writer_write_element_unsigned_int(writer
,
932 config_element_num_subbuf
,
938 /* Switch timer interval in usec */
939 ret
= mi_lttng_writer_write_element_unsigned_int(writer
,
940 config_element_switch_timer_interval
,
941 attr
->switch_timer_interval
);
946 /* Read timer interval in usec */
947 ret
= mi_lttng_writer_write_element_unsigned_int(writer
,
948 config_element_read_timer_interval
,
949 attr
->read_timer_interval
);
954 /* Monitor timer interval in usec */
955 ret
= mi_lttng_writer_write_element_unsigned_int(writer
,
956 config_element_monitor_timer_interval
,
957 monitor_timer_interval
);
962 /* Retry timeout in usec */
963 ret
= mi_lttng_writer_write_element_signed_int(writer
,
964 config_element_blocking_timeout
,
971 ret
= mi_lttng_writer_write_element_string(writer
,
972 config_element_output_type
,
973 attr
->output
== LTTNG_EVENT_SPLICE
?
974 config_output_type_splice
: config_output_type_mmap
);
979 /* Tracefile size in bytes */
980 ret
= mi_lttng_writer_write_element_unsigned_int(writer
,
981 config_element_tracefile_size
, attr
->tracefile_size
);
986 /* Count of tracefiles */
987 ret
= mi_lttng_writer_write_element_unsigned_int(writer
,
988 config_element_tracefile_count
,
989 attr
->tracefile_count
);
994 /* Live timer interval in usec*/
995 ret
= mi_lttng_writer_write_element_unsigned_int(writer
,
996 config_element_live_timer_interval
,
997 attr
->live_timer_interval
);
1002 /* Discarded events */
1003 ret
= mi_lttng_writer_write_element_unsigned_int(writer
,
1004 config_element_discarded_events
,
1011 ret
= mi_lttng_writer_write_element_unsigned_int(writer
,
1012 config_element_lost_packets
,
1018 /* Closing attributes */
1019 ret
= mi_lttng_writer_close_element(writer
);
1029 int mi_lttng_event_common_attributes(struct mi_writer
*writer
,
1030 struct lttng_event
*event
)
1033 const char *filter_expression
;
1035 /* Open event element */
1036 ret
= mi_lttng_writer_open_element(writer
, config_element_event
);
1042 ret
= mi_lttng_writer_write_element_string(writer
,
1043 config_element_name
, event
->name
);
1049 ret
= mi_lttng_writer_write_element_string(writer
,
1050 config_element_type
, mi_lttng_eventtype_string(event
->type
));
1055 /* Is event enabled */
1056 ret
= mi_lttng_writer_write_element_bool(writer
,
1057 config_element_enabled
, event
->enabled
);
1062 /* Event filter expression */
1063 ret
= lttng_event_get_filter_expression(event
, &filter_expression
);
1068 if (filter_expression
) {
1069 ret
= mi_lttng_writer_write_element_string(writer
,
1070 config_element_filter_expression
,
1081 static int write_event_exclusions(struct mi_writer
*writer
,
1082 struct lttng_event
*event
)
1086 int exclusion_count
;
1088 /* Open event exclusions */
1089 ret
= mi_lttng_writer_open_element(writer
, config_element_exclusions
);
1094 exclusion_count
= lttng_event_get_exclusion_name_count(event
);
1095 if (exclusion_count
< 0) {
1096 ret
= exclusion_count
;
1100 for (i
= 0; i
< exclusion_count
; i
++) {
1103 ret
= lttng_event_get_exclusion_name(event
, i
, &name
);
1105 /* Close exclusions */
1106 mi_lttng_writer_close_element(writer
);
1110 ret
= mi_lttng_writer_write_element_string(writer
,
1111 config_element_exclusion
, name
);
1113 /* Close exclusions */
1114 mi_lttng_writer_close_element(writer
);
1119 /* Close exclusions */
1120 ret
= mi_lttng_writer_close_element(writer
);
1127 int mi_lttng_event_tracepoint_loglevel(struct mi_writer
*writer
,
1128 struct lttng_event
*event
, enum lttng_domain_type domain
)
1132 /* Event loglevel */
1133 ret
= mi_lttng_writer_write_element_string(writer
,
1134 config_element_loglevel
,
1135 mi_lttng_loglevel_string(event
->loglevel
, domain
));
1140 /* Log level type */
1141 ret
= mi_lttng_writer_write_element_string(writer
,
1142 config_element_loglevel_type
,
1143 mi_lttng_logleveltype_string(event
->loglevel_type
));
1148 /* Event exclusions */
1149 ret
= write_event_exclusions(writer
, event
);
1156 int mi_lttng_event_tracepoint_no_loglevel(struct mi_writer
*writer
,
1157 struct lttng_event
*event
)
1159 /* event exclusion filter */
1160 return write_event_exclusions(writer
, event
);
1164 int mi_lttng_event_function_probe(struct mi_writer
*writer
,
1165 struct lttng_event
*event
)
1169 ret
= mi_lttng_writer_open_element(writer
, config_element_attributes
);
1174 ret
= mi_lttng_writer_open_element(writer
, config_element_probe_attributes
);
1179 if (event
->attr
.probe
.addr
!= 0) {
1180 /* event probe address */
1181 ret
= mi_lttng_writer_write_element_unsigned_int(writer
,
1182 config_element_address
, event
->attr
.probe
.addr
);
1187 /* event probe offset */
1188 ret
= mi_lttng_writer_write_element_unsigned_int(writer
,
1189 config_element_offset
, event
->attr
.probe
.offset
);
1194 /* event probe symbol_name */
1195 ret
= mi_lttng_writer_write_element_string(writer
,
1196 config_element_symbol_name
, event
->attr
.probe
.symbol_name
);
1202 /* Close probe_attributes and attributes */
1203 ret
= mi_lttng_close_multi_element(writer
, 2);
1209 int mi_lttng_event_function_entry(struct mi_writer
*writer
,
1210 struct lttng_event
*event
)
1214 ret
= mi_lttng_writer_open_element(writer
, config_element_attributes
);
1219 ret
= mi_lttng_writer_open_element(writer
, config_element_probe_attributes
);
1224 /* event probe symbol_name */
1225 ret
= mi_lttng_writer_write_element_string(writer
,
1226 config_element_symbol_name
, event
->attr
.ftrace
.symbol_name
);
1231 /* Close function_attributes and attributes */
1232 ret
= mi_lttng_close_multi_element(writer
, 2);
1238 int mi_lttng_events_open(struct mi_writer
*writer
)
1240 return mi_lttng_writer_open_element(writer
, config_element_events
);
1244 int mi_lttng_event(struct mi_writer
*writer
,
1245 struct lttng_event
*event
, int is_open
, enum lttng_domain_type domain
)
1249 ret
= mi_lttng_event_common_attributes(writer
, event
);
1254 switch (event
->type
) {
1255 case LTTNG_EVENT_TRACEPOINT
:
1257 if (event
->loglevel
!= -1) {
1258 ret
= mi_lttng_event_tracepoint_loglevel(writer
, event
, domain
);
1260 ret
= mi_lttng_event_tracepoint_no_loglevel(writer
, event
);
1264 case LTTNG_EVENT_FUNCTION
:
1266 case LTTNG_EVENT_PROBE
:
1267 ret
= mi_lttng_event_function_probe(writer
, event
);
1269 case LTTNG_EVENT_FUNCTION_ENTRY
:
1270 ret
= mi_lttng_event_function_entry(writer
, event
);
1272 case LTTNG_EVENT_ALL
:
1279 ret
= mi_lttng_writer_close_element(writer
);
1287 int mi_lttng_trackers_open(struct mi_writer
*writer
)
1289 return mi_lttng_writer_open_element(writer
, config_element_trackers
);
1293 int mi_lttng_pid_tracker_open(struct mi_writer
*writer
)
1297 /* Open element pid_tracker */
1298 ret
= mi_lttng_writer_open_element(writer
, config_element_pid_tracker
);
1303 /* Open targets element */
1304 ret
= mi_lttng_targets_open(writer
);
1310 int mi_lttng_pids_open(struct mi_writer
*writer
)
1312 return mi_lttng_writer_open_element(writer
, config_element_pids
);
1316 * TODO: move the listing of pid for user agent to process semantic on
1317 * mi api bump. The use of process element break the mi api.
1320 int mi_lttng_pid(struct mi_writer
*writer
, pid_t pid
, const char *name
,
1325 /* Open pid process */
1326 ret
= mi_lttng_writer_open_element(writer
, config_element_pid
);
1331 /* Writing pid number */
1332 ret
= mi_lttng_writer_write_element_signed_int(writer
,
1333 mi_lttng_element_pid_id
, (int)pid
);
1338 /* Writing name of the process */
1340 ret
= mi_lttng_writer_write_element_string(writer
, config_element_name
,
1349 ret
= mi_lttng_writer_close_element(writer
);
1357 int mi_lttng_targets_open(struct mi_writer
*writer
)
1359 return mi_lttng_writer_open_element(writer
,
1360 config_element_targets
);
1364 int mi_lttng_pid_target(struct mi_writer
*writer
, pid_t pid
, int is_open
)
1368 ret
= mi_lttng_writer_open_element(writer
,
1369 config_element_target_pid
);
1374 /* Writing pid number
1375 * Special case for element all on track untrack command
1376 * All pid is represented as wildcard *
1378 if ((int) pid
== -1) {
1379 ret
= mi_lttng_writer_write_element_string(writer
,
1381 mi_lttng_element_track_untrack_all_wildcard
);
1383 ret
= mi_lttng_writer_write_element_signed_int(writer
,
1384 config_element_pid
, (int) pid
);
1391 ret
= mi_lttng_writer_close_element(writer
);
1402 int mi_lttng_event_fields_open(struct mi_writer
*writer
)
1404 return mi_lttng_writer_open_element(writer
, mi_lttng_element_event_fields
);
1408 int mi_lttng_event_field(struct mi_writer
*writer
,
1409 struct lttng_event_field
*field
)
1413 if (!field
->field_name
[0]) {
1419 ret
= mi_lttng_writer_open_element(writer
, mi_lttng_element_event_field
);
1424 if (!field
->field_name
[0]) {
1429 ret
= mi_lttng_writer_write_element_string(writer
, config_element_name
,
1436 ret
= mi_lttng_writer_write_element_string(writer
, config_element_type
,
1437 mi_lttng_eventfieldtype_string(field
->type
));
1443 ret
= mi_lttng_writer_write_element_signed_int(writer
,
1444 mi_lttng_element_nowrite
, field
->nowrite
);
1450 /* Close field element */
1451 ret
= mi_lttng_writer_close_element(writer
);
1458 int mi_lttng_perf_counter_context(struct mi_writer
*writer
,
1459 struct lttng_event_perf_counter_ctx
*perf_context
)
1463 /* Open perf_counter_context */
1464 ret
= mi_lttng_writer_open_element(writer
,
1465 mi_lttng_element_perf_counter_context
);
1471 ret
= mi_lttng_writer_write_element_unsigned_int(writer
,
1472 config_element_type
, perf_context
->type
);
1478 ret
= mi_lttng_writer_write_element_unsigned_int(writer
,
1479 config_element_config
, perf_context
->config
);
1484 /* Name of the perf counter */
1485 ret
= mi_lttng_writer_write_element_string(writer
,
1486 config_element_name
, perf_context
->name
);
1491 /* Close perf_counter_context */
1492 ret
= mi_lttng_writer_close_element(writer
);
1498 int mi_lttng_app_context(struct mi_writer
*writer
,
1499 const char *provider_name
, const char *ctx_name
)
1504 ret
= mi_lttng_writer_open_element(writer
,
1505 config_element_context_app
);
1511 ret
= mi_lttng_writer_write_element_string(writer
,
1512 config_element_context_app_provider_name
,
1519 ret
= mi_lttng_writer_write_element_string(writer
,
1520 config_element_context_app_ctx_name
, ctx_name
);
1526 ret
= mi_lttng_writer_close_element(writer
);
1532 int mi_lttng_context(struct mi_writer
*writer
,
1533 struct lttng_event_context
*context
, int is_open
)
1538 ret
= mi_lttng_writer_open_element(writer
, config_element_context
);
1543 /* Special case for PERF_*_COUNTER
1544 * print the lttng_event_perf_counter_ctx*/
1545 switch (context
->ctx
) {
1546 case LTTNG_EVENT_CONTEXT_PERF_COUNTER
:
1547 case LTTNG_EVENT_CONTEXT_PERF_THREAD_COUNTER
:
1548 case LTTNG_EVENT_CONTEXT_PERF_CPU_COUNTER
:
1550 struct lttng_event_perf_counter_ctx
*perf_context
=
1551 &context
->u
.perf_counter
;
1552 ret
= mi_lttng_perf_counter_context(writer
, perf_context
);
1558 case LTTNG_EVENT_CONTEXT_APP_CONTEXT
:
1560 ret
= mi_lttng_app_context(writer
,
1561 context
->u
.app_ctx
.provider_name
,
1562 context
->u
.app_ctx
.ctx_name
);
1570 const char *type_string
= mi_lttng_event_contexttype_string(
1573 ret
= -LTTNG_ERR_INVALID
;
1577 /* Print context type */
1578 ret
= mi_lttng_writer_write_element_string(writer
,
1579 config_element_type
, type_string
);
1586 ret
= mi_lttng_writer_close_element(writer
);
1594 int mi_lttng_snapshot_output_session_name(struct mi_writer
*writer
,
1595 const char *session_name
)
1599 /* Open session element */
1600 ret
= mi_lttng_writer_open_element(writer
, config_element_session
);
1605 /* Snapshot output list for current session name */
1606 ret
= mi_lttng_writer_write_element_string(writer
, config_element_name
,
1612 /* Open element snapshots (sequence one snapshot) */
1613 ret
= mi_lttng_writer_open_element(writer
, mi_lttng_element_snapshots
);
1623 int mi_lttng_snapshot_list_output(struct mi_writer
*writer
,
1624 struct lttng_snapshot_output
*output
)
1628 /* Open element snapshot output */
1629 ret
= mi_lttng_writer_open_element(writer
,
1630 mi_lttng_element_command_snapshot
);
1635 /* ID of the snapshot output */
1636 ret
= mi_lttng_writer_write_element_unsigned_int(writer
,
1637 mi_lttng_element_id
, output
->id
);
1642 /* Name of the output */
1643 ret
= mi_lttng_writer_write_element_string(writer
, config_element_name
,
1649 /* Destination of the output (ctrl_url)*/
1650 ret
= mi_lttng_writer_write_element_string(writer
,
1651 mi_lttng_element_snapshot_ctrl_url
, output
->ctrl_url
);
1656 /* Destination of the output (data_url) */
1657 ret
= mi_lttng_writer_write_element_string(writer
,
1658 mi_lttng_element_snapshot_data_url
, output
->data_url
);
1663 /* total size of all stream combined */
1664 ret
= mi_lttng_writer_write_element_unsigned_int(writer
,
1665 mi_lttng_element_snapshot_max_size
, output
->max_size
);
1670 /* Close snapshot output element */
1671 ret
= mi_lttng_writer_close_element(writer
);
1678 int mi_lttng_snapshot_del_output(struct mi_writer
*writer
, int id
,
1679 const char *name
, const char *current_session_name
)
1683 /* Open element del_snapshot */
1684 ret
= mi_lttng_writer_open_element(writer
,
1685 mi_lttng_element_command_snapshot
);
1691 if (id
!= UINT32_MAX
) {
1692 /* "Snapshot output "id" successfully deleted
1693 * for "current_session_name"
1694 * ID of the snapshot output
1696 ret
= mi_lttng_writer_write_element_unsigned_int(writer
,
1697 mi_lttng_element_id
, id
);
1702 /* "Snapshot output "name" successfully deleted
1703 * for session "current_session_name"
1704 * Name of the output
1706 ret
= mi_lttng_writer_write_element_string(writer
, config_element_name
,
1713 /* Snapshot was deleted for session "current_session_name"*/
1714 ret
= mi_lttng_writer_write_element_string(writer
,
1715 mi_lttng_element_snapshot_session_name
,
1716 current_session_name
);
1721 /* Close snapshot element */
1722 ret
= mi_lttng_writer_close_element(writer
);
1729 int mi_lttng_snapshot_add_output(struct mi_writer
*writer
,
1730 const char *current_session_name
, const char *n_ptr
,
1731 struct lttng_snapshot_output
*output
)
1735 /* Open element snapshot */
1736 ret
= mi_lttng_writer_open_element(writer
,
1737 mi_lttng_element_command_snapshot
);
1742 /* Snapshot output id */
1743 ret
= mi_lttng_writer_write_element_unsigned_int(writer
,
1744 mi_lttng_element_id
, output
->id
);
1749 /* Snapshot output names */
1750 ret
= mi_lttng_writer_write_element_string(writer
,
1751 config_element_name
, n_ptr
);
1756 /* Destination of the output (ctrl_url)*/
1757 ret
= mi_lttng_writer_write_element_string(writer
,
1758 mi_lttng_element_snapshot_ctrl_url
, output
->ctrl_url
);
1763 /* Snapshot added for session "current_session_name"*/
1764 ret
= mi_lttng_writer_write_element_string(writer
,
1765 mi_lttng_element_snapshot_session_name
, current_session_name
);
1770 /* total size of all stream combined */
1771 ret
= mi_lttng_writer_write_element_unsigned_int(writer
,
1772 mi_lttng_element_snapshot_max_size
, output
->max_size
);
1777 /* Close snapshot element */
1778 ret
= mi_lttng_writer_close_element(writer
);
1785 int mi_lttng_snapshot_record(struct mi_writer
*writer
,
1786 const char *current_session_name
, const char *url
,
1787 const char *cmdline_ctrl_url
, const char *cmdline_data_url
)
1791 /* Open element snapshot */
1792 ret
= mi_lttng_writer_open_element(writer
,
1793 mi_lttng_element_command_snapshot
);
1799 * If a valid an URL was given, serialize it,
1800 * else take the command line data and ctrl urls*/
1802 /* Destination of the output (ctrl_url)*/
1803 ret
= mi_lttng_writer_write_element_string(writer
,
1804 mi_lttng_element_snapshot_ctrl_url
, url
);
1808 } else if (cmdline_ctrl_url
) {
1809 /* Destination of the output (ctrl_url)*/
1810 ret
= mi_lttng_writer_write_element_string(writer
,
1811 mi_lttng_element_snapshot_ctrl_url
, cmdline_ctrl_url
);
1816 /* Destination of the output (data_url) */
1817 ret
= mi_lttng_writer_write_element_string(writer
,
1818 mi_lttng_element_snapshot_data_url
, cmdline_data_url
);
1824 /* Close record_snapshot element */
1825 ret
= mi_lttng_writer_close_element(writer
);