Commit | Line | Data |
---|---|---|
af9a82eb | 1 | /* |
af9a82eb | 2 | * Copyright 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com> |
f504043c | 3 | * Copyright 2016 Mathieu Desnoyers <mathieu.desnoyers@efficios.com> |
af9a82eb JG |
4 | * |
5 | * Author: Jérémie Galarneau <jeremie.galarneau@efficios.com> | |
6 | * | |
7 | * Permission is hereby granted, free of charge, to any person obtaining a copy | |
8 | * of this software and associated documentation files (the "Software"), to deal | |
9 | * in the Software without restriction, including without limitation the rights | |
10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
11 | * copies of the Software, and to permit persons to whom the Software is | |
12 | * furnished to do so, subject to the following conditions: | |
13 | * | |
14 | * The above copyright notice and this permission notice shall be included in | |
15 | * all copies or substantial portions of the Software. | |
16 | * | |
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | |
20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |
21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | |
22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | |
23 | * SOFTWARE. | |
24 | */ | |
25 | ||
3fadfbc0 | 26 | #include <babeltrace2/babeltrace.h> |
578e048b MJ |
27 | #include "compat/bitfield.h" |
28 | #include "common/common.h" | |
29 | #include "compat/time.h" | |
30 | #include "common/assert.h" | |
6a18b281 | 31 | #include <inttypes.h> |
93a4161c | 32 | #include <ctype.h> |
91d81473 | 33 | #include <string.h> |
3228cc1d | 34 | #include "pretty.h" |
af9a82eb | 35 | |
1556a1af JG |
36 | #define NSEC_PER_SEC 1000000000LL |
37 | ||
5280f742 | 38 | #define COLOR_NAME BT_COMMON_COLOR_BOLD |
08899d39 | 39 | #define COLOR_FIELD_NAME BT_COMMON_COLOR_FG_CYAN |
5280f742 PP |
40 | #define COLOR_RST BT_COMMON_COLOR_RESET |
41 | #define COLOR_STRING_VALUE BT_COMMON_COLOR_BOLD | |
42 | #define COLOR_NUMBER_VALUE BT_COMMON_COLOR_BOLD | |
43 | #define COLOR_ENUM_MAPPING_NAME BT_COMMON_COLOR_BOLD | |
44 | #define COLOR_UNKNOWN BT_COMMON_COLOR_BOLD BT_COMMON_COLOR_FG_RED | |
08899d39 | 45 | #define COLOR_EVENT_NAME BT_COMMON_COLOR_BOLD BT_COMMON_COLOR_FG_MAGENTA |
5280f742 | 46 | #define COLOR_TIMESTAMP BT_COMMON_COLOR_BOLD BT_COMMON_COLOR_FG_YELLOW |
ad96d936 | 47 | |
af9a82eb JG |
48 | struct timestamp { |
49 | int64_t real_timestamp; /* Relative to UNIX epoch. */ | |
605e1019 | 50 | uint64_t clock_snapshot; /* In cycles. */ |
af9a82eb JG |
51 | }; |
52 | ||
6a18b281 | 53 | static |
d94d92ac | 54 | int print_field(struct pretty_component *pretty, |
b19ff26f | 55 | const bt_field *field, bool print_names, |
2b4c4a7c | 56 | GQuark *filters_fields, int filter_array_len); |
6a18b281 | 57 | |
ad96d936 | 58 | static |
3228cc1d | 59 | void print_name_equal(struct pretty_component *pretty, const char *name) |
ad96d936 | 60 | { |
3228cc1d | 61 | if (pretty->use_colors) { |
5280f742 PP |
62 | g_string_append_printf(pretty->string, "%s%s%s = ", COLOR_NAME, |
63 | name, COLOR_RST); | |
ad96d936 | 64 | } else { |
5280f742 | 65 | g_string_append_printf(pretty->string, "%s = ", name); |
ad96d936 PP |
66 | } |
67 | } | |
68 | ||
69 | static | |
3228cc1d | 70 | void print_field_name_equal(struct pretty_component *pretty, const char *name) |
ad96d936 | 71 | { |
3228cc1d | 72 | if (pretty->use_colors) { |
5280f742 PP |
73 | g_string_append_printf(pretty->string, "%s%s%s = ", |
74 | COLOR_FIELD_NAME, name, COLOR_RST); | |
ad96d936 | 75 | } else { |
5280f742 | 76 | g_string_append_printf(pretty->string, "%s = ", name); |
ad96d936 PP |
77 | } |
78 | } | |
79 | ||
af9a82eb | 80 | static |
3228cc1d | 81 | void print_timestamp_cycles(struct pretty_component *pretty, |
9c202476 | 82 | const bt_clock_snapshot *clock_snapshot, bool update_last) |
af9a82eb | 83 | { |
1556a1af | 84 | uint64_t cycles; |
1556a1af | 85 | |
605e1019 | 86 | cycles = bt_clock_snapshot_get_value(clock_snapshot); |
5280f742 | 87 | g_string_append_printf(pretty->string, "%020" PRIu64, cycles); |
3af83b5a | 88 | |
9c202476 PP |
89 | if (update_last) { |
90 | if (pretty->last_cycles_timestamp != -1ULL) { | |
91 | pretty->delta_cycles = cycles - pretty->last_cycles_timestamp; | |
92 | } | |
2c091c04 | 93 | |
9c202476 PP |
94 | pretty->last_cycles_timestamp = cycles; |
95 | } | |
af9a82eb JG |
96 | } |
97 | ||
98 | static | |
3228cc1d | 99 | void print_timestamp_wall(struct pretty_component *pretty, |
9c202476 | 100 | const bt_clock_snapshot *clock_snapshot, bool update_last) |
af9a82eb | 101 | { |
1556a1af | 102 | int ret; |
1556a1af JG |
103 | int64_t ts_nsec = 0; /* add configurable offset */ |
104 | int64_t ts_sec = 0; /* add configurable offset */ | |
105 | uint64_t ts_sec_abs, ts_nsec_abs; | |
106 | bool is_negative; | |
af9a82eb | 107 | |
605e1019 | 108 | if (!clock_snapshot) { |
5280f742 | 109 | g_string_append(pretty->string, "??:??:??.?????????"); |
1556a1af JG |
110 | return; |
111 | } | |
112 | ||
605e1019 | 113 | ret = bt_clock_snapshot_get_ns_from_origin(clock_snapshot, &ts_nsec); |
1556a1af | 114 | if (ret) { |
5280f742 PP |
115 | // TODO: log, this is unexpected |
116 | g_string_append(pretty->string, "Error"); | |
1556a1af JG |
117 | return; |
118 | } | |
119 | ||
9c202476 PP |
120 | if (update_last) { |
121 | if (pretty->last_real_timestamp != -1ULL) { | |
122 | pretty->delta_real_timestamp = ts_nsec - pretty->last_real_timestamp; | |
123 | } | |
124 | ||
125 | pretty->last_real_timestamp = ts_nsec; | |
3af83b5a | 126 | } |
3af83b5a | 127 | |
1556a1af JG |
128 | ts_sec += ts_nsec / NSEC_PER_SEC; |
129 | ts_nsec = ts_nsec % NSEC_PER_SEC; | |
5280f742 | 130 | |
1556a1af JG |
131 | if (ts_sec >= 0 && ts_nsec >= 0) { |
132 | is_negative = false; | |
133 | ts_sec_abs = ts_sec; | |
134 | ts_nsec_abs = ts_nsec; | |
135 | } else if (ts_sec > 0 && ts_nsec < 0) { | |
136 | is_negative = false; | |
137 | ts_sec_abs = ts_sec - 1; | |
138 | ts_nsec_abs = NSEC_PER_SEC + ts_nsec; | |
139 | } else if (ts_sec == 0 && ts_nsec < 0) { | |
140 | is_negative = true; | |
141 | ts_sec_abs = ts_sec; | |
142 | ts_nsec_abs = -ts_nsec; | |
143 | } else if (ts_sec < 0 && ts_nsec > 0) { | |
144 | is_negative = true; | |
145 | ts_sec_abs = -(ts_sec + 1); | |
146 | ts_nsec_abs = NSEC_PER_SEC - ts_nsec; | |
147 | } else if (ts_sec < 0 && ts_nsec == 0) { | |
148 | is_negative = true; | |
149 | ts_sec_abs = -ts_sec; | |
150 | ts_nsec_abs = ts_nsec; | |
151 | } else { /* (ts_sec < 0 && ts_nsec < 0) */ | |
152 | is_negative = true; | |
153 | ts_sec_abs = -ts_sec; | |
154 | ts_nsec_abs = -ts_nsec; | |
155 | } | |
156 | ||
3228cc1d | 157 | if (!pretty->options.clock_seconds) { |
1556a1af JG |
158 | struct tm tm; |
159 | time_t time_s = (time_t) ts_sec_abs; | |
160 | ||
18adbd19 | 161 | if (is_negative && !pretty->negative_timestamp_warning_done) { |
5280f742 | 162 | // TODO: log instead |
1556a1af | 163 | fprintf(stderr, "[warning] Fallback to [sec.ns] to print negative time value. Use --clock-seconds.\n"); |
18adbd19 | 164 | pretty->negative_timestamp_warning_done = true; |
1556a1af JG |
165 | goto seconds; |
166 | } | |
167 | ||
3228cc1d | 168 | if (!pretty->options.clock_gmt) { |
1556a1af JG |
169 | struct tm *res; |
170 | ||
58a2480d | 171 | res = bt_localtime_r(&time_s, &tm); |
1556a1af | 172 | if (!res) { |
5280f742 | 173 | // TODO: log instead |
1556a1af JG |
174 | fprintf(stderr, "[warning] Unable to get localtime.\n"); |
175 | goto seconds; | |
176 | } | |
177 | } else { | |
178 | struct tm *res; | |
179 | ||
58a2480d | 180 | res = bt_gmtime_r(&time_s, &tm); |
1556a1af | 181 | if (!res) { |
5280f742 | 182 | // TODO: log instead |
1556a1af JG |
183 | fprintf(stderr, "[warning] Unable to get gmtime.\n"); |
184 | goto seconds; | |
185 | } | |
186 | } | |
3228cc1d | 187 | if (pretty->options.clock_date) { |
1556a1af JG |
188 | char timestr[26]; |
189 | size_t res; | |
190 | ||
191 | /* Print date and time */ | |
192 | res = strftime(timestr, sizeof(timestr), | |
4d2a94f1 | 193 | "%Y-%m-%d ", &tm); |
1556a1af | 194 | if (!res) { |
5280f742 | 195 | // TODO: log instead |
1556a1af JG |
196 | fprintf(stderr, "[warning] Unable to print ascii time.\n"); |
197 | goto seconds; | |
198 | } | |
5280f742 PP |
199 | |
200 | g_string_append(pretty->string, timestr); | |
1556a1af | 201 | } |
5280f742 | 202 | |
1556a1af | 203 | /* Print time in HH:MM:SS.ns */ |
5280f742 PP |
204 | g_string_append_printf(pretty->string, |
205 | "%02d:%02d:%02d.%09" PRIu64, tm.tm_hour, tm.tm_min, | |
206 | tm.tm_sec, ts_nsec_abs); | |
1556a1af JG |
207 | goto end; |
208 | } | |
209 | seconds: | |
5280f742 PP |
210 | g_string_append_printf(pretty->string, "%s%" PRId64 ".%09" PRIu64, |
211 | is_negative ? "-" : "", ts_sec_abs, ts_nsec_abs); | |
1556a1af JG |
212 | end: |
213 | return; | |
af9a82eb JG |
214 | } |
215 | ||
216 | static | |
d94d92ac | 217 | int print_event_timestamp(struct pretty_component *pretty, |
2c091c04 | 218 | const bt_message *event_msg, bool *start_line) |
af9a82eb | 219 | { |
3228cc1d | 220 | bool print_names = pretty->options.print_header_field_names; |
d94d92ac | 221 | int ret = 0; |
605e1019 | 222 | const bt_clock_snapshot *clock_snapshot = NULL; |
af9a82eb | 223 | |
81c25620 PP |
224 | if (!bt_message_event_borrow_stream_class_default_clock_class_const( |
225 | event_msg)) { | |
2c091c04 | 226 | /* No default clock class: skip the timestamp without an error */ |
f504043c MD |
227 | goto end; |
228 | } | |
d9f65f09 | 229 | |
0cbc2c33 | 230 | clock_snapshot = bt_message_event_borrow_default_clock_snapshot_const(event_msg); |
af9a82eb | 231 | |
ad96d936 | 232 | if (print_names) { |
3228cc1d | 233 | print_name_equal(pretty, "timestamp"); |
ad96d936 | 234 | } else { |
5280f742 | 235 | g_string_append(pretty->string, "["); |
ad96d936 | 236 | } |
3228cc1d | 237 | if (pretty->use_colors) { |
5280f742 | 238 | g_string_append(pretty->string, COLOR_TIMESTAMP); |
ad96d936 | 239 | } |
3228cc1d | 240 | if (pretty->options.print_timestamp_cycles) { |
9c202476 | 241 | print_timestamp_cycles(pretty, clock_snapshot, true); |
af9a82eb | 242 | } else { |
9c202476 | 243 | print_timestamp_wall(pretty, clock_snapshot, true); |
af9a82eb | 244 | } |
3228cc1d | 245 | if (pretty->use_colors) { |
5280f742 | 246 | g_string_append(pretty->string, COLOR_RST); |
ad96d936 | 247 | } |
af9a82eb | 248 | |
c3c30b08 | 249 | if (!print_names) |
5280f742 | 250 | g_string_append(pretty->string, "] "); |
c3c30b08 | 251 | |
3228cc1d | 252 | if (pretty->options.print_delta_field) { |
ad96d936 | 253 | if (print_names) { |
5280f742 | 254 | g_string_append(pretty->string, ", "); |
3228cc1d | 255 | print_name_equal(pretty, "delta"); |
ad96d936 | 256 | } else { |
5280f742 | 257 | g_string_append(pretty->string, "("); |
ad96d936 | 258 | } |
3228cc1d PP |
259 | if (pretty->options.print_timestamp_cycles) { |
260 | if (pretty->delta_cycles == -1ULL) { | |
5280f742 | 261 | g_string_append(pretty->string, |
c6a871e9 | 262 | "+??????????\?\?"); /* Not a trigraph. */ |
3af83b5a | 263 | } else { |
5280f742 PP |
264 | g_string_append_printf(pretty->string, |
265 | "+%012" PRIu64, pretty->delta_cycles); | |
3af83b5a MD |
266 | } |
267 | } else { | |
3228cc1d | 268 | if (pretty->delta_real_timestamp != -1ULL) { |
3af83b5a | 269 | uint64_t delta_sec, delta_nsec, delta; |
f504043c | 270 | |
3228cc1d | 271 | delta = pretty->delta_real_timestamp; |
3af83b5a MD |
272 | delta_sec = delta / NSEC_PER_SEC; |
273 | delta_nsec = delta % NSEC_PER_SEC; | |
5280f742 PP |
274 | g_string_append_printf(pretty->string, |
275 | "+%" PRIu64 ".%09" PRIu64, | |
3af83b5a MD |
276 | delta_sec, delta_nsec); |
277 | } else { | |
5280f742 | 278 | g_string_append(pretty->string, "+?.?????????"); |
3af83b5a MD |
279 | } |
280 | } | |
281 | if (!print_names) { | |
5280f742 | 282 | g_string_append(pretty->string, ") "); |
3af83b5a MD |
283 | } |
284 | } | |
285 | *start_line = !print_names; | |
f504043c | 286 | |
af9a82eb | 287 | end: |
af9a82eb JG |
288 | return ret; |
289 | } | |
290 | ||
6a18b281 | 291 | static |
d94d92ac | 292 | int print_event_header(struct pretty_component *pretty, |
2c091c04 | 293 | const bt_message *event_msg) |
af9a82eb | 294 | { |
3228cc1d | 295 | bool print_names = pretty->options.print_header_field_names; |
d94d92ac | 296 | int ret = 0; |
b19ff26f PP |
297 | const bt_event_class *event_class = NULL; |
298 | const bt_stream_class *stream_class = NULL; | |
299 | const bt_trace_class *trace_class = NULL; | |
300 | const bt_packet *packet = NULL; | |
301 | const bt_stream *stream = NULL; | |
302 | const bt_trace *trace = NULL; | |
2c091c04 | 303 | const bt_event *event = bt_message_event_borrow_event_const(event_msg); |
64925bba | 304 | const char *ev_name; |
60535549 | 305 | int dom_print = 0; |
4cdfc5e8 | 306 | bt_property_availability prop_avail; |
af9a82eb | 307 | |
40f4ba76 | 308 | event_class = bt_event_borrow_class_const(event); |
40f4ba76 | 309 | stream_class = bt_event_class_borrow_stream_class_const(event_class); |
862ca4ed PP |
310 | trace_class = bt_stream_class_borrow_trace_class_const(stream_class); |
311 | packet = bt_event_borrow_packet_const(event); | |
312 | stream = bt_packet_borrow_stream_const(packet); | |
313 | trace = bt_stream_borrow_trace_const(stream); | |
2c091c04 | 314 | ret = print_event_timestamp(pretty, event_msg, &pretty->start_line); |
d94d92ac | 315 | if (ret) { |
af9a82eb JG |
316 | goto end; |
317 | } | |
3228cc1d | 318 | if (pretty->options.print_trace_field) { |
c3c30b08 MD |
319 | const char *name; |
320 | ||
862ca4ed | 321 | name = bt_trace_get_name(trace); |
c3c30b08 | 322 | if (name) { |
3228cc1d | 323 | if (!pretty->start_line) { |
5280f742 | 324 | g_string_append(pretty->string, ", "); |
c3c30b08 | 325 | } |
c3c30b08 | 326 | if (print_names) { |
3228cc1d | 327 | print_name_equal(pretty, "trace"); |
c3c30b08 | 328 | } |
5280f742 PP |
329 | |
330 | g_string_append(pretty->string, name); | |
331 | ||
22b7fdc6 PP |
332 | if (print_names) { |
333 | g_string_append(pretty->string, ", "); | |
60535549 | 334 | } |
c3c30b08 MD |
335 | } |
336 | } | |
3228cc1d | 337 | if (pretty->options.print_trace_hostname_field) { |
b19ff26f | 338 | const bt_value *hostname_str; |
c3c30b08 | 339 | |
862ca4ed | 340 | hostname_str = bt_trace_class_borrow_environment_entry_value_by_name_const( |
a82e90e8 | 341 | trace_class, "hostname"); |
c3c30b08 MD |
342 | if (hostname_str) { |
343 | const char *str; | |
344 | ||
3228cc1d | 345 | if (!pretty->start_line) { |
5280f742 | 346 | g_string_append(pretty->string, ", "); |
c3c30b08 | 347 | } |
c3c30b08 | 348 | if (print_names) { |
3228cc1d | 349 | print_name_equal(pretty, "trace:hostname"); |
c3c30b08 | 350 | } |
601b0d3c PP |
351 | str = bt_value_string_get(hostname_str); |
352 | g_string_append(pretty->string, str); | |
60535549 | 353 | dom_print = 1; |
c3c30b08 MD |
354 | } |
355 | } | |
3228cc1d | 356 | if (pretty->options.print_trace_domain_field) { |
b19ff26f | 357 | const bt_value *domain_str; |
c3c30b08 | 358 | |
862ca4ed | 359 | domain_str = bt_trace_class_borrow_environment_entry_value_by_name_const( |
a82e90e8 | 360 | trace_class, "domain"); |
c3c30b08 MD |
361 | if (domain_str) { |
362 | const char *str; | |
363 | ||
3228cc1d | 364 | if (!pretty->start_line) { |
5280f742 | 365 | g_string_append(pretty->string, ", "); |
c3c30b08 | 366 | } |
c3c30b08 | 367 | if (print_names) { |
3228cc1d | 368 | print_name_equal(pretty, "trace:domain"); |
60535549 | 369 | } else if (dom_print) { |
5280f742 | 370 | g_string_append(pretty->string, ":"); |
c3c30b08 | 371 | } |
601b0d3c PP |
372 | str = bt_value_string_get(domain_str); |
373 | g_string_append(pretty->string, str); | |
60535549 | 374 | dom_print = 1; |
c3c30b08 MD |
375 | } |
376 | } | |
3228cc1d | 377 | if (pretty->options.print_trace_procname_field) { |
b19ff26f | 378 | const bt_value *procname_str; |
c3c30b08 | 379 | |
862ca4ed | 380 | procname_str = bt_trace_class_borrow_environment_entry_value_by_name_const( |
a82e90e8 | 381 | trace_class, "procname"); |
c3c30b08 MD |
382 | if (procname_str) { |
383 | const char *str; | |
384 | ||
3228cc1d | 385 | if (!pretty->start_line) { |
5280f742 | 386 | g_string_append(pretty->string, ", "); |
c3c30b08 | 387 | } |
c3c30b08 | 388 | if (print_names) { |
3228cc1d | 389 | print_name_equal(pretty, "trace:procname"); |
60535549 | 390 | } else if (dom_print) { |
5280f742 | 391 | g_string_append(pretty->string, ":"); |
c3c30b08 | 392 | } |
601b0d3c PP |
393 | str = bt_value_string_get(procname_str); |
394 | g_string_append(pretty->string, str); | |
60535549 | 395 | dom_print = 1; |
c3c30b08 MD |
396 | } |
397 | } | |
3228cc1d | 398 | if (pretty->options.print_trace_vpid_field) { |
b19ff26f | 399 | const bt_value *vpid_value; |
c3c30b08 | 400 | |
862ca4ed | 401 | vpid_value = bt_trace_class_borrow_environment_entry_value_by_name_const( |
a82e90e8 | 402 | trace_class, "vpid"); |
c3c30b08 MD |
403 | if (vpid_value) { |
404 | int64_t value; | |
405 | ||
3228cc1d | 406 | if (!pretty->start_line) { |
5280f742 | 407 | g_string_append(pretty->string, ", "); |
c3c30b08 | 408 | } |
c3c30b08 | 409 | if (print_names) { |
3228cc1d | 410 | print_name_equal(pretty, "trace:vpid"); |
60535549 | 411 | } else if (dom_print) { |
5280f742 | 412 | g_string_append(pretty->string, ":"); |
c3c30b08 | 413 | } |
fdd3a2da | 414 | value = bt_value_signed_integer_get(vpid_value); |
601b0d3c PP |
415 | g_string_append_printf(pretty->string, |
416 | "(%" PRId64 ")", value); | |
60535549 | 417 | dom_print = 1; |
c3c30b08 MD |
418 | } |
419 | } | |
3228cc1d | 420 | if (pretty->options.print_loglevel_field) { |
cf76ce92 | 421 | static const char *log_level_names[] = { |
50842bdc PP |
422 | [ BT_EVENT_CLASS_LOG_LEVEL_EMERGENCY ] = "TRACE_EMERG", |
423 | [ BT_EVENT_CLASS_LOG_LEVEL_ALERT ] = "TRACE_ALERT", | |
424 | [ BT_EVENT_CLASS_LOG_LEVEL_CRITICAL ] = "TRACE_CRIT", | |
425 | [ BT_EVENT_CLASS_LOG_LEVEL_ERROR ] = "TRACE_ERR", | |
426 | [ BT_EVENT_CLASS_LOG_LEVEL_WARNING ] = "TRACE_WARNING", | |
427 | [ BT_EVENT_CLASS_LOG_LEVEL_NOTICE ] = "TRACE_NOTICE", | |
428 | [ BT_EVENT_CLASS_LOG_LEVEL_INFO ] = "TRACE_INFO", | |
429 | [ BT_EVENT_CLASS_LOG_LEVEL_DEBUG_SYSTEM ] = "TRACE_DEBUG_SYSTEM", | |
430 | [ BT_EVENT_CLASS_LOG_LEVEL_DEBUG_PROGRAM ] = "TRACE_DEBUG_PROGRAM", | |
431 | [ BT_EVENT_CLASS_LOG_LEVEL_DEBUG_PROCESS ] = "TRACE_DEBUG_PROCESS", | |
432 | [ BT_EVENT_CLASS_LOG_LEVEL_DEBUG_MODULE ] = "TRACE_DEBUG_MODULE", | |
433 | [ BT_EVENT_CLASS_LOG_LEVEL_DEBUG_UNIT ] = "TRACE_DEBUG_UNIT", | |
434 | [ BT_EVENT_CLASS_LOG_LEVEL_DEBUG_FUNCTION ] = "TRACE_DEBUG_FUNCTION", | |
435 | [ BT_EVENT_CLASS_LOG_LEVEL_DEBUG_LINE ] = "TRACE_DEBUG_LINE", | |
436 | [ BT_EVENT_CLASS_LOG_LEVEL_DEBUG ] = "TRACE_DEBUG", | |
cf76ce92 | 437 | }; |
4cdfc5e8 | 438 | bt_event_class_log_level log_level; |
cf76ce92 PP |
439 | const char *log_level_str = NULL; |
440 | ||
44c440bc PP |
441 | prop_avail = bt_event_class_get_log_level(event_class, |
442 | &log_level); | |
443 | if (prop_avail == BT_PROPERTY_AVAILABILITY_AVAILABLE) { | |
cf76ce92 | 444 | log_level_str = log_level_names[log_level]; |
44c440bc | 445 | BT_ASSERT(log_level_str); |
c3c30b08 | 446 | |
3228cc1d | 447 | if (!pretty->start_line) { |
5280f742 | 448 | g_string_append(pretty->string, ", "); |
c3c30b08 | 449 | } |
c3c30b08 | 450 | if (print_names) { |
3228cc1d | 451 | print_name_equal(pretty, "loglevel"); |
60535549 | 452 | } else if (dom_print) { |
5280f742 | 453 | g_string_append(pretty->string, ":"); |
c3c30b08 | 454 | } |
cf76ce92 PP |
455 | |
456 | g_string_append(pretty->string, log_level_str); | |
457 | g_string_append_printf( | |
458 | pretty->string, " (%d)", (int) log_level); | |
60535549 | 459 | dom_print = 1; |
c3c30b08 MD |
460 | } |
461 | } | |
3228cc1d | 462 | if (pretty->options.print_emf_field) { |
cf76ce92 | 463 | const char *uri_str; |
c3c30b08 | 464 | |
50842bdc | 465 | uri_str = bt_event_class_get_emf_uri(event_class); |
c3c30b08 | 466 | if (uri_str) { |
3228cc1d | 467 | if (!pretty->start_line) { |
5280f742 | 468 | g_string_append(pretty->string, ", "); |
c3c30b08 | 469 | } |
c3c30b08 | 470 | if (print_names) { |
3228cc1d | 471 | print_name_equal(pretty, "model.emf.uri"); |
60535549 | 472 | } else if (dom_print) { |
5280f742 | 473 | g_string_append(pretty->string, ":"); |
c3c30b08 | 474 | } |
c3c30b08 | 475 | |
cf76ce92 | 476 | g_string_append(pretty->string, uri_str); |
60535549 | 477 | dom_print = 1; |
c3c30b08 MD |
478 | } |
479 | } | |
60535549 | 480 | if (dom_print && !print_names) { |
5280f742 | 481 | g_string_append(pretty->string, " "); |
60535549 | 482 | } |
3228cc1d | 483 | if (!pretty->start_line) { |
5280f742 | 484 | g_string_append(pretty->string, ", "); |
c3c30b08 | 485 | } |
3228cc1d | 486 | pretty->start_line = true; |
6a18b281 | 487 | if (print_names) { |
3228cc1d | 488 | print_name_equal(pretty, "name"); |
ad96d936 | 489 | } |
64925bba | 490 | ev_name = bt_event_class_get_name(event_class); |
3228cc1d | 491 | if (pretty->use_colors) { |
64925bba PP |
492 | if (ev_name) { |
493 | g_string_append(pretty->string, COLOR_EVENT_NAME); | |
494 | } else { | |
495 | g_string_append(pretty->string, COLOR_UNKNOWN); | |
496 | } | |
497 | } | |
498 | if (ev_name) { | |
499 | g_string_append(pretty->string, ev_name); | |
500 | } else { | |
501 | g_string_append(pretty->string, "<unknown>"); | |
6a18b281 | 502 | } |
3228cc1d | 503 | if (pretty->use_colors) { |
5280f742 | 504 | g_string_append(pretty->string, COLOR_RST); |
ad96d936 | 505 | } |
60535549 | 506 | if (!print_names) { |
5280f742 | 507 | g_string_append(pretty->string, ": "); |
60535549 | 508 | } else { |
5280f742 | 509 | g_string_append(pretty->string, ", "); |
60535549 | 510 | } |
a82e90e8 | 511 | |
af9a82eb | 512 | end: |
6a18b281 MD |
513 | return ret; |
514 | } | |
515 | ||
516 | static | |
d94d92ac | 517 | int print_integer(struct pretty_component *pretty, |
b19ff26f | 518 | const bt_field *field) |
6a18b281 | 519 | { |
d94d92ac | 520 | int ret = 0; |
4cdfc5e8 | 521 | bt_field_class_integer_preferred_display_base base; |
b19ff26f | 522 | const bt_field_class *int_fc; |
6a18b281 MD |
523 | union { |
524 | uint64_t u; | |
525 | int64_t s; | |
526 | } v; | |
ad96d936 | 527 | bool rst_color = false; |
4cdfc5e8 | 528 | bt_field_class_type ft_type; |
6a18b281 | 529 | |
40f4ba76 | 530 | int_fc = bt_field_borrow_class_const(field); |
5cd6d0e5 | 531 | BT_ASSERT(int_fc); |
864cad70 PP |
532 | ft_type = bt_field_get_class_type(field); |
533 | if (ft_type == BT_FIELD_CLASS_TYPE_UNSIGNED_INTEGER || | |
534 | ft_type == BT_FIELD_CLASS_TYPE_UNSIGNED_ENUMERATION) { | |
44c440bc | 535 | v.u = bt_field_unsigned_integer_get_value(field); |
6a18b281 | 536 | } else { |
44c440bc | 537 | v.s = bt_field_signed_integer_get_value(field); |
6a18b281 MD |
538 | } |
539 | ||
3228cc1d | 540 | if (pretty->use_colors) { |
5280f742 | 541 | g_string_append(pretty->string, COLOR_NUMBER_VALUE); |
ad96d936 PP |
542 | rst_color = true; |
543 | } | |
544 | ||
5cd6d0e5 | 545 | base = bt_field_class_integer_get_preferred_display_base(int_fc); |
6a18b281 | 546 | switch (base) { |
5cd6d0e5 | 547 | case BT_FIELD_CLASS_INTEGER_PREFERRED_DISPLAY_BASE_BINARY: |
6a18b281 MD |
548 | { |
549 | int bitnr, len; | |
550 | ||
5cd6d0e5 | 551 | len = bt_field_class_integer_get_field_value_range(int_fc); |
5280f742 | 552 | g_string_append(pretty->string, "0b"); |
7f140ae8 | 553 | _bt_safe_lshift(v.u, 64 - len); |
6a18b281 | 554 | for (bitnr = 0; bitnr < len; bitnr++) { |
5280f742 | 555 | g_string_append_printf(pretty->string, "%u", (v.u & (1ULL << 63)) ? 1 : 0); |
7f140ae8 | 556 | _bt_safe_lshift(v.u, 1); |
6a18b281 MD |
557 | } |
558 | break; | |
559 | } | |
5cd6d0e5 | 560 | case BT_FIELD_CLASS_INTEGER_PREFERRED_DISPLAY_BASE_OCTAL: |
6a18b281 | 561 | { |
864cad70 PP |
562 | if (ft_type == BT_FIELD_CLASS_TYPE_SIGNED_INTEGER || |
563 | ft_type == BT_FIELD_CLASS_TYPE_SIGNED_ENUMERATION) { | |
6a18b281 MD |
564 | int len; |
565 | ||
5cd6d0e5 PP |
566 | len = bt_field_class_integer_get_field_value_range( |
567 | int_fc); | |
6a18b281 MD |
568 | if (len < 64) { |
569 | size_t rounded_len; | |
570 | ||
f6ccaed9 | 571 | BT_ASSERT(len != 0); |
6a18b281 MD |
572 | /* Round length to the nearest 3-bit */ |
573 | rounded_len = (((len - 1) / 3) + 1) * 3; | |
574 | v.u &= ((uint64_t) 1 << rounded_len) - 1; | |
575 | } | |
576 | } | |
577 | ||
5280f742 | 578 | g_string_append_printf(pretty->string, "0%" PRIo64, v.u); |
6a18b281 MD |
579 | break; |
580 | } | |
5cd6d0e5 | 581 | case BT_FIELD_CLASS_INTEGER_PREFERRED_DISPLAY_BASE_DECIMAL: |
864cad70 PP |
582 | if (ft_type == BT_FIELD_CLASS_TYPE_UNSIGNED_INTEGER || |
583 | ft_type == BT_FIELD_CLASS_TYPE_UNSIGNED_ENUMERATION) { | |
5280f742 | 584 | g_string_append_printf(pretty->string, "%" PRIu64, v.u); |
6a18b281 | 585 | } else { |
5280f742 | 586 | g_string_append_printf(pretty->string, "%" PRId64, v.s); |
6a18b281 MD |
587 | } |
588 | break; | |
5cd6d0e5 | 589 | case BT_FIELD_CLASS_INTEGER_PREFERRED_DISPLAY_BASE_HEXADECIMAL: |
6a18b281 MD |
590 | { |
591 | int len; | |
592 | ||
5cd6d0e5 | 593 | len = bt_field_class_integer_get_field_value_range(int_fc); |
6a18b281 MD |
594 | if (len < 64) { |
595 | /* Round length to the nearest nibble */ | |
596 | uint8_t rounded_len = ((len + 3) & ~0x3); | |
597 | ||
598 | v.u &= ((uint64_t) 1 << rounded_len) - 1; | |
599 | } | |
600 | ||
5280f742 | 601 | g_string_append_printf(pretty->string, "0x%" PRIX64, v.u); |
6a18b281 MD |
602 | break; |
603 | } | |
604 | default: | |
d94d92ac | 605 | ret = -1; |
6a18b281 MD |
606 | goto end; |
607 | } | |
608 | end: | |
ad96d936 | 609 | if (rst_color) { |
5280f742 | 610 | g_string_append(pretty->string, COLOR_RST); |
ad96d936 | 611 | } |
6a18b281 MD |
612 | return ret; |
613 | } | |
614 | ||
93a4161c | 615 | static |
3228cc1d | 616 | void print_escape_string(struct pretty_component *pretty, const char *str) |
93a4161c JD |
617 | { |
618 | int i; | |
619 | ||
5280f742 PP |
620 | g_string_append_c(pretty->string, '"'); |
621 | ||
93a4161c JD |
622 | for (i = 0; i < strlen(str); i++) { |
623 | /* Escape sequences not recognized by iscntrl(). */ | |
624 | switch (str[i]) { | |
625 | case '\\': | |
5280f742 | 626 | g_string_append(pretty->string, "\\\\"); |
93a4161c JD |
627 | continue; |
628 | case '\'': | |
5280f742 | 629 | g_string_append(pretty->string, "\\\'"); |
93a4161c JD |
630 | continue; |
631 | case '\"': | |
5280f742 | 632 | g_string_append(pretty->string, "\\\""); |
93a4161c JD |
633 | continue; |
634 | case '\?': | |
5280f742 | 635 | g_string_append(pretty->string, "\\\?"); |
93a4161c JD |
636 | continue; |
637 | } | |
638 | ||
639 | /* Standard characters. */ | |
640 | if (!iscntrl(str[i])) { | |
5280f742 | 641 | g_string_append_c(pretty->string, str[i]); |
93a4161c JD |
642 | continue; |
643 | } | |
644 | ||
645 | switch (str[i]) { | |
646 | case '\0': | |
5280f742 | 647 | g_string_append(pretty->string, "\\0"); |
93a4161c JD |
648 | break; |
649 | case '\a': | |
5280f742 | 650 | g_string_append(pretty->string, "\\a"); |
93a4161c JD |
651 | break; |
652 | case '\b': | |
5280f742 | 653 | g_string_append(pretty->string, "\\b"); |
93a4161c JD |
654 | break; |
655 | case '\e': | |
5280f742 | 656 | g_string_append(pretty->string, "\\e"); |
93a4161c JD |
657 | break; |
658 | case '\f': | |
5280f742 | 659 | g_string_append(pretty->string, "\\f"); |
93a4161c JD |
660 | break; |
661 | case '\n': | |
5280f742 | 662 | g_string_append(pretty->string, "\\n"); |
93a4161c JD |
663 | break; |
664 | case '\r': | |
5280f742 | 665 | g_string_append(pretty->string, "\\r"); |
93a4161c JD |
666 | break; |
667 | case '\t': | |
5280f742 | 668 | g_string_append(pretty->string, "\\t"); |
93a4161c JD |
669 | break; |
670 | case '\v': | |
5280f742 | 671 | g_string_append(pretty->string, "\\v"); |
93a4161c JD |
672 | break; |
673 | default: | |
674 | /* Unhandled control-sequence, print as hex. */ | |
5280f742 | 675 | g_string_append_printf(pretty->string, "\\x%02x", str[i]); |
93a4161c JD |
676 | break; |
677 | } | |
678 | } | |
5280f742 PP |
679 | |
680 | g_string_append_c(pretty->string, '"'); | |
93a4161c JD |
681 | } |
682 | ||
6a18b281 | 683 | static |
d94d92ac | 684 | int print_enum(struct pretty_component *pretty, |
b19ff26f | 685 | const bt_field *field) |
6a18b281 | 686 | { |
d94d92ac | 687 | int ret = 0; |
b19ff26f | 688 | const bt_field_class *enumeration_field_class = NULL; |
5cd6d0e5 | 689 | bt_field_class_enumeration_mapping_label_array label_array; |
44c440bc PP |
690 | uint64_t label_count; |
691 | uint64_t i; | |
96e8f959 | 692 | |
40f4ba76 | 693 | enumeration_field_class = bt_field_borrow_class_const(field); |
5cd6d0e5 | 694 | if (!enumeration_field_class) { |
d94d92ac | 695 | ret = -1; |
96e8f959 MD |
696 | goto end; |
697 | } | |
44c440bc | 698 | |
864cad70 PP |
699 | switch (bt_field_get_class_type(field)) { |
700 | case BT_FIELD_CLASS_TYPE_UNSIGNED_ENUMERATION: | |
44c440bc PP |
701 | ret = bt_field_unsigned_enumeration_get_mapping_labels(field, |
702 | &label_array, &label_count); | |
703 | break; | |
864cad70 | 704 | case BT_FIELD_CLASS_TYPE_SIGNED_ENUMERATION: |
44c440bc PP |
705 | ret = bt_field_signed_enumeration_get_mapping_labels(field, |
706 | &label_array, &label_count); | |
707 | break; | |
708 | default: | |
709 | abort(); | |
96e8f959 | 710 | } |
44c440bc PP |
711 | |
712 | if (ret) { | |
d94d92ac | 713 | ret = -1; |
96e8f959 MD |
714 | goto end; |
715 | } | |
44c440bc | 716 | |
83ef3205 | 717 | g_string_append(pretty->string, "( "); |
44c440bc | 718 | if (label_count == 0) { |
83ef3205 MD |
719 | if (pretty->use_colors) { |
720 | g_string_append(pretty->string, COLOR_UNKNOWN); | |
721 | } | |
722 | g_string_append(pretty->string, "<unknown>"); | |
723 | if (pretty->use_colors) { | |
724 | g_string_append(pretty->string, COLOR_RST); | |
725 | } | |
726 | goto skip_loop; | |
96e8f959 | 727 | } |
44c440bc PP |
728 | for (i = 0; i < label_count; i++) { |
729 | const char *mapping_name = label_array[i]; | |
96e8f959 | 730 | |
55c68a1a | 731 | if (i != 0) { |
5280f742 | 732 | g_string_append(pretty->string, ", "); |
44c440bc | 733 | } |
3228cc1d | 734 | if (pretty->use_colors) { |
5280f742 | 735 | g_string_append(pretty->string, COLOR_ENUM_MAPPING_NAME); |
ad96d936 | 736 | } |
3228cc1d PP |
737 | print_escape_string(pretty, mapping_name); |
738 | if (pretty->use_colors) { | |
5280f742 | 739 | g_string_append(pretty->string, COLOR_RST); |
ad96d936 | 740 | } |
96e8f959 | 741 | } |
83ef3205 | 742 | skip_loop: |
5280f742 | 743 | g_string_append(pretty->string, " : container = "); |
312c056a | 744 | ret = print_integer(pretty, field); |
d94d92ac | 745 | if (ret != 0) { |
6a18b281 MD |
746 | goto end; |
747 | } | |
5280f742 | 748 | g_string_append(pretty->string, " )"); |
6a18b281 | 749 | end: |
6a18b281 MD |
750 | return ret; |
751 | } | |
752 | ||
2b4c4a7c | 753 | static |
3228cc1d | 754 | int filter_field_name(struct pretty_component *pretty, const char *field_name, |
2b4c4a7c JD |
755 | GQuark *filter_fields, int filter_array_len) |
756 | { | |
757 | int i; | |
758 | GQuark field_quark = g_quark_try_string(field_name); | |
759 | ||
3228cc1d | 760 | if (!field_quark || pretty->options.verbose) { |
2b4c4a7c JD |
761 | return 1; |
762 | } | |
763 | ||
764 | for (i = 0; i < filter_array_len; i++) { | |
765 | if (field_quark == filter_fields[i]) { | |
766 | return 0; | |
767 | } | |
768 | } | |
769 | return 1; | |
770 | } | |
771 | ||
6a18b281 | 772 | static |
d94d92ac | 773 | int print_struct_field(struct pretty_component *pretty, |
b19ff26f PP |
774 | const bt_field *_struct, |
775 | const bt_field_class *struct_class, | |
44c440bc | 776 | uint64_t i, bool print_names, uint64_t *nr_printed_fields, |
2b4c4a7c | 777 | GQuark *filter_fields, int filter_array_len) |
6a18b281 | 778 | { |
d94d92ac | 779 | int ret = 0; |
6a18b281 | 780 | const char *field_name; |
b19ff26f | 781 | const bt_field *field = NULL; |
1e6fd1d7 | 782 | const bt_field_class_structure_member *member; |
6a18b281 | 783 | |
40f4ba76 | 784 | field = bt_field_structure_borrow_member_field_by_index_const(_struct, i); |
6a18b281 | 785 | if (!field) { |
d94d92ac | 786 | ret = -1; |
6a18b281 MD |
787 | goto end; |
788 | } | |
44c440bc | 789 | |
1e6fd1d7 PP |
790 | member = bt_field_class_structure_borrow_member_by_index_const( |
791 | struct_class, i); | |
792 | field_name = bt_field_class_structure_member_get_name(member); | |
6a18b281 | 793 | |
3228cc1d | 794 | if (filter_fields && !filter_field_name(pretty, field_name, |
2b4c4a7c | 795 | filter_fields, filter_array_len)) { |
d94d92ac | 796 | ret = 0; |
2b4c4a7c JD |
797 | goto end; |
798 | } | |
799 | ||
800 | if (*nr_printed_fields > 0) { | |
5280f742 | 801 | g_string_append(pretty->string, ", "); |
6a18b281 | 802 | } else { |
5280f742 | 803 | g_string_append(pretty->string, " "); |
6a18b281 MD |
804 | } |
805 | if (print_names) { | |
6acddae3 | 806 | print_field_name_equal(pretty, field_name); |
6a18b281 | 807 | } |
3228cc1d | 808 | ret = print_field(pretty, field, print_names, NULL, 0); |
2b4c4a7c | 809 | *nr_printed_fields += 1; |
a82e90e8 | 810 | |
6a18b281 | 811 | end: |
6a18b281 MD |
812 | return ret; |
813 | } | |
814 | ||
815 | static | |
d94d92ac | 816 | int print_struct(struct pretty_component *pretty, |
b19ff26f | 817 | const bt_field *_struct, bool print_names, |
2b4c4a7c | 818 | GQuark *filter_fields, int filter_array_len) |
6a18b281 | 819 | { |
d94d92ac | 820 | int ret = 0; |
b19ff26f | 821 | const bt_field_class *struct_class = NULL; |
44c440bc | 822 | uint64_t nr_fields, i, nr_printed_fields; |
6a18b281 | 823 | |
40f4ba76 | 824 | struct_class = bt_field_borrow_class_const(_struct); |
5cd6d0e5 | 825 | if (!struct_class) { |
d94d92ac | 826 | ret = -1; |
6a18b281 MD |
827 | goto end; |
828 | } | |
53dc85fa | 829 | |
5cd6d0e5 | 830 | nr_fields = bt_field_class_structure_get_member_count(struct_class); |
53dc85fa | 831 | |
5280f742 | 832 | g_string_append(pretty->string, "{"); |
3228cc1d | 833 | pretty->depth++; |
2b4c4a7c | 834 | nr_printed_fields = 0; |
6a18b281 | 835 | for (i = 0; i < nr_fields; i++) { |
5cd6d0e5 | 836 | ret = print_struct_field(pretty, _struct, struct_class, i, |
2b4c4a7c JD |
837 | print_names, &nr_printed_fields, filter_fields, |
838 | filter_array_len); | |
d94d92ac | 839 | if (ret != 0) { |
6a18b281 MD |
840 | goto end; |
841 | } | |
842 | } | |
3228cc1d | 843 | pretty->depth--; |
5280f742 | 844 | g_string_append(pretty->string, " }"); |
a82e90e8 | 845 | |
6a18b281 | 846 | end: |
6a18b281 MD |
847 | return ret; |
848 | } | |
849 | ||
850 | static | |
d94d92ac | 851 | int print_array_field(struct pretty_component *pretty, |
b19ff26f | 852 | const bt_field *array, uint64_t i, bool print_names) |
6a18b281 | 853 | { |
b19ff26f | 854 | const bt_field *field = NULL; |
6a18b281 | 855 | |
44c440bc PP |
856 | if (i != 0) { |
857 | g_string_append(pretty->string, ", "); | |
858 | } else { | |
859 | g_string_append(pretty->string, " "); | |
6a18b281 | 860 | } |
44c440bc PP |
861 | if (print_names) { |
862 | g_string_append_printf(pretty->string, "[%" PRIu64 "] = ", i); | |
6a18b281 | 863 | } |
a82e90e8 | 864 | |
40f4ba76 | 865 | field = bt_field_array_borrow_element_field_by_index_const(array, i); |
44c440bc PP |
866 | BT_ASSERT(field); |
867 | return print_field(pretty, field, print_names, NULL, 0); | |
6a18b281 MD |
868 | } |
869 | ||
870 | static | |
d94d92ac | 871 | int print_array(struct pretty_component *pretty, |
b19ff26f | 872 | const bt_field *array, bool print_names) |
6a18b281 | 873 | { |
d94d92ac | 874 | int ret = 0; |
b19ff26f | 875 | const bt_field_class *array_class = NULL; |
44c440bc | 876 | uint64_t len; |
6a18b281 | 877 | uint64_t i; |
6a18b281 | 878 | |
40f4ba76 | 879 | array_class = bt_field_borrow_class_const(array); |
5cd6d0e5 | 880 | if (!array_class) { |
d94d92ac | 881 | ret = -1; |
6a18b281 MD |
882 | goto end; |
883 | } | |
44c440bc PP |
884 | len = bt_field_array_get_length(array); |
885 | g_string_append(pretty->string, "["); | |
3228cc1d | 886 | pretty->depth++; |
6a18b281 | 887 | for (i = 0; i < len; i++) { |
44c440bc | 888 | ret = print_array_field(pretty, array, i, print_names); |
d94d92ac | 889 | if (ret != 0) { |
6a18b281 MD |
890 | goto end; |
891 | } | |
892 | } | |
3228cc1d | 893 | pretty->depth--; |
44c440bc | 894 | g_string_append(pretty->string, " ]"); |
a82e90e8 | 895 | |
6a18b281 | 896 | end: |
6a18b281 MD |
897 | return ret; |
898 | } | |
899 | ||
900 | static | |
d94d92ac | 901 | int print_sequence_field(struct pretty_component *pretty, |
b19ff26f | 902 | const bt_field *seq, uint64_t i, bool print_names) |
6a18b281 | 903 | { |
b19ff26f | 904 | const bt_field *field = NULL; |
6a18b281 | 905 | |
44c440bc PP |
906 | if (i != 0) { |
907 | g_string_append(pretty->string, ", "); | |
908 | } else { | |
909 | g_string_append(pretty->string, " "); | |
6a18b281 | 910 | } |
44c440bc PP |
911 | if (print_names) { |
912 | g_string_append_printf(pretty->string, "[%" PRIu64 "] = ", i); | |
6a18b281 | 913 | } |
a82e90e8 | 914 | |
40f4ba76 | 915 | field = bt_field_array_borrow_element_field_by_index_const(seq, i); |
44c440bc PP |
916 | BT_ASSERT(field); |
917 | return print_field(pretty, field, print_names, NULL, 0); | |
6a18b281 MD |
918 | } |
919 | ||
920 | static | |
d94d92ac | 921 | int print_sequence(struct pretty_component *pretty, |
b19ff26f | 922 | const bt_field *seq, bool print_names) |
6a18b281 | 923 | { |
d94d92ac | 924 | int ret = 0; |
44c440bc | 925 | uint64_t len; |
6a18b281 | 926 | uint64_t i; |
6a18b281 | 927 | |
44c440bc | 928 | len = bt_field_array_get_length(seq); |
44c440bc | 929 | g_string_append(pretty->string, "["); |
6a18b281 | 930 | |
3228cc1d | 931 | pretty->depth++; |
6a18b281 | 932 | for (i = 0; i < len; i++) { |
44c440bc | 933 | ret = print_sequence_field(pretty, seq, i, print_names); |
d94d92ac | 934 | if (ret != 0) { |
6a18b281 MD |
935 | goto end; |
936 | } | |
937 | } | |
3228cc1d | 938 | pretty->depth--; |
44c440bc | 939 | g_string_append(pretty->string, " ]"); |
a82e90e8 | 940 | |
6a18b281 | 941 | end: |
6a18b281 MD |
942 | return ret; |
943 | } | |
944 | ||
945 | static | |
d94d92ac | 946 | int print_variant(struct pretty_component *pretty, |
b19ff26f | 947 | const bt_field *variant, bool print_names) |
6a18b281 | 948 | { |
d94d92ac | 949 | int ret = 0; |
b19ff26f | 950 | const bt_field *field = NULL; |
6a18b281 | 951 | |
40f4ba76 | 952 | field = bt_field_variant_borrow_selected_option_field_const(variant); |
44c440bc | 953 | BT_ASSERT(field); |
5280f742 | 954 | g_string_append(pretty->string, "{ "); |
3228cc1d | 955 | pretty->depth++; |
6a18b281 | 956 | if (print_names) { |
44c440bc PP |
957 | // TODO: find tag's name using field path |
958 | // print_field_name_equal(pretty, tag_choice); | |
6a18b281 | 959 | } |
3228cc1d | 960 | ret = print_field(pretty, field, print_names, NULL, 0); |
d94d92ac | 961 | if (ret != 0) { |
6a18b281 MD |
962 | goto end; |
963 | } | |
3228cc1d | 964 | pretty->depth--; |
5280f742 | 965 | g_string_append(pretty->string, " }"); |
a82e90e8 | 966 | |
6a18b281 | 967 | end: |
6a18b281 MD |
968 | return ret; |
969 | } | |
970 | ||
971 | static | |
d94d92ac | 972 | int print_field(struct pretty_component *pretty, |
b19ff26f | 973 | const bt_field *field, bool print_names, |
2b4c4a7c | 974 | GQuark *filter_fields, int filter_array_len) |
6a18b281 | 975 | { |
4cdfc5e8 | 976 | bt_field_class_type class_id; |
6a18b281 | 977 | |
864cad70 | 978 | class_id = bt_field_get_class_type(field); |
5cd6d0e5 | 979 | switch (class_id) { |
864cad70 PP |
980 | case BT_FIELD_CLASS_TYPE_UNSIGNED_INTEGER: |
981 | case BT_FIELD_CLASS_TYPE_SIGNED_INTEGER: | |
3228cc1d | 982 | return print_integer(pretty, field); |
864cad70 | 983 | case BT_FIELD_CLASS_TYPE_REAL: |
6a18b281 MD |
984 | { |
985 | double v; | |
986 | ||
44c440bc | 987 | v = bt_field_real_get_value(field); |
3228cc1d | 988 | if (pretty->use_colors) { |
5280f742 | 989 | g_string_append(pretty->string, COLOR_NUMBER_VALUE); |
ad96d936 | 990 | } |
5280f742 | 991 | g_string_append_printf(pretty->string, "%g", v); |
3228cc1d | 992 | if (pretty->use_colors) { |
5280f742 | 993 | g_string_append(pretty->string, COLOR_RST); |
ad96d936 | 994 | } |
d94d92ac | 995 | return 0; |
6a18b281 | 996 | } |
864cad70 PP |
997 | case BT_FIELD_CLASS_TYPE_UNSIGNED_ENUMERATION: |
998 | case BT_FIELD_CLASS_TYPE_SIGNED_ENUMERATION: | |
3228cc1d | 999 | return print_enum(pretty, field); |
864cad70 | 1000 | case BT_FIELD_CLASS_TYPE_STRING: |
95a518bf JG |
1001 | { |
1002 | const char *str; | |
1003 | ||
50842bdc | 1004 | str = bt_field_string_get_value(field); |
95a518bf | 1005 | if (!str) { |
d94d92ac | 1006 | return -1; |
95a518bf JG |
1007 | } |
1008 | ||
3228cc1d | 1009 | if (pretty->use_colors) { |
5280f742 | 1010 | g_string_append(pretty->string, COLOR_STRING_VALUE); |
ad96d936 | 1011 | } |
95a518bf | 1012 | print_escape_string(pretty, str); |
3228cc1d | 1013 | if (pretty->use_colors) { |
5280f742 | 1014 | g_string_append(pretty->string, COLOR_RST); |
ad96d936 | 1015 | } |
d94d92ac | 1016 | return 0; |
95a518bf | 1017 | } |
864cad70 | 1018 | case BT_FIELD_CLASS_TYPE_STRUCTURE: |
3228cc1d | 1019 | return print_struct(pretty, field, print_names, filter_fields, |
2b4c4a7c | 1020 | filter_array_len); |
864cad70 | 1021 | case BT_FIELD_CLASS_TYPE_VARIANT: |
3228cc1d | 1022 | return print_variant(pretty, field, print_names); |
864cad70 | 1023 | case BT_FIELD_CLASS_TYPE_STATIC_ARRAY: |
3228cc1d | 1024 | return print_array(pretty, field, print_names); |
864cad70 | 1025 | case BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY: |
3228cc1d | 1026 | return print_sequence(pretty, field, print_names); |
6a18b281 | 1027 | default: |
5280f742 | 1028 | // TODO: log instead |
5cd6d0e5 | 1029 | fprintf(pretty->err, "[error] Unknown type id: %d\n", (int) class_id); |
d94d92ac | 1030 | return -1; |
6a18b281 MD |
1031 | } |
1032 | } | |
1033 | ||
1034 | static | |
d94d92ac | 1035 | int print_stream_packet_context(struct pretty_component *pretty, |
b19ff26f | 1036 | const bt_event *event) |
6a18b281 | 1037 | { |
d94d92ac | 1038 | int ret = 0; |
b19ff26f PP |
1039 | const bt_packet *packet = NULL; |
1040 | const bt_field *main_field = NULL; | |
6a18b281 | 1041 | |
40f4ba76 | 1042 | packet = bt_event_borrow_packet_const(event); |
6a18b281 | 1043 | if (!packet) { |
d94d92ac | 1044 | ret = -1; |
6a18b281 MD |
1045 | goto end; |
1046 | } | |
40f4ba76 | 1047 | main_field = bt_packet_borrow_context_field_const(packet); |
6a18b281 | 1048 | if (!main_field) { |
6a18b281 MD |
1049 | goto end; |
1050 | } | |
3228cc1d | 1051 | if (!pretty->start_line) { |
5280f742 | 1052 | g_string_append(pretty->string, ", "); |
6e1bc0df | 1053 | } |
3228cc1d PP |
1054 | pretty->start_line = false; |
1055 | if (pretty->options.print_scope_field_names) { | |
1056 | print_name_equal(pretty, "stream.packet.context"); | |
6a18b281 | 1057 | } |
3228cc1d PP |
1058 | ret = print_field(pretty, main_field, |
1059 | pretty->options.print_context_field_names, | |
2b4c4a7c JD |
1060 | stream_packet_context_quarks, |
1061 | STREAM_PACKET_CONTEXT_QUARKS_LEN); | |
a82e90e8 | 1062 | |
6a18b281 | 1063 | end: |
6a18b281 MD |
1064 | return ret; |
1065 | } | |
1066 | ||
6a18b281 | 1067 | static |
d94d92ac | 1068 | int print_stream_event_context(struct pretty_component *pretty, |
b19ff26f | 1069 | const bt_event *event) |
6a18b281 | 1070 | { |
d94d92ac | 1071 | int ret = 0; |
b19ff26f | 1072 | const bt_field *main_field = NULL; |
6a18b281 | 1073 | |
40f4ba76 | 1074 | main_field = bt_event_borrow_common_context_field_const(event); |
6a18b281 | 1075 | if (!main_field) { |
6a18b281 MD |
1076 | goto end; |
1077 | } | |
3228cc1d | 1078 | if (!pretty->start_line) { |
5280f742 | 1079 | g_string_append(pretty->string, ", "); |
6e1bc0df | 1080 | } |
3228cc1d PP |
1081 | pretty->start_line = false; |
1082 | if (pretty->options.print_scope_field_names) { | |
1083 | print_name_equal(pretty, "stream.event.context"); | |
6a18b281 | 1084 | } |
3228cc1d PP |
1085 | ret = print_field(pretty, main_field, |
1086 | pretty->options.print_context_field_names, NULL, 0); | |
a82e90e8 | 1087 | |
6a18b281 | 1088 | end: |
6a18b281 MD |
1089 | return ret; |
1090 | } | |
1091 | ||
1092 | static | |
d94d92ac | 1093 | int print_event_context(struct pretty_component *pretty, |
b19ff26f | 1094 | const bt_event *event) |
6a18b281 | 1095 | { |
d94d92ac | 1096 | int ret = 0; |
b19ff26f | 1097 | const bt_field *main_field = NULL; |
6a18b281 | 1098 | |
40f4ba76 | 1099 | main_field = bt_event_borrow_specific_context_field_const(event); |
6a18b281 | 1100 | if (!main_field) { |
6a18b281 MD |
1101 | goto end; |
1102 | } | |
3228cc1d | 1103 | if (!pretty->start_line) { |
5280f742 | 1104 | g_string_append(pretty->string, ", "); |
6e1bc0df | 1105 | } |
3228cc1d PP |
1106 | pretty->start_line = false; |
1107 | if (pretty->options.print_scope_field_names) { | |
1108 | print_name_equal(pretty, "event.context"); | |
6a18b281 | 1109 | } |
3228cc1d PP |
1110 | ret = print_field(pretty, main_field, |
1111 | pretty->options.print_context_field_names, NULL, 0); | |
a82e90e8 | 1112 | |
6a18b281 | 1113 | end: |
6a18b281 MD |
1114 | return ret; |
1115 | } | |
1116 | ||
1117 | static | |
d94d92ac | 1118 | int print_event_payload(struct pretty_component *pretty, |
b19ff26f | 1119 | const bt_event *event) |
6a18b281 | 1120 | { |
d94d92ac | 1121 | int ret = 0; |
b19ff26f | 1122 | const bt_field *main_field = NULL; |
6a18b281 | 1123 | |
40f4ba76 | 1124 | main_field = bt_event_borrow_payload_field_const(event); |
6a18b281 | 1125 | if (!main_field) { |
6a18b281 MD |
1126 | goto end; |
1127 | } | |
3228cc1d | 1128 | if (!pretty->start_line) { |
5280f742 | 1129 | g_string_append(pretty->string, ", "); |
6e1bc0df | 1130 | } |
3228cc1d PP |
1131 | pretty->start_line = false; |
1132 | if (pretty->options.print_scope_field_names) { | |
1133 | print_name_equal(pretty, "event.fields"); | |
6a18b281 | 1134 | } |
3228cc1d PP |
1135 | ret = print_field(pretty, main_field, |
1136 | pretty->options.print_payload_field_names, NULL, 0); | |
a82e90e8 | 1137 | |
6a18b281 | 1138 | end: |
af9a82eb JG |
1139 | return ret; |
1140 | } | |
1141 | ||
08899d39 | 1142 | static |
0f6bea4e | 1143 | int flush_buf(FILE *stream, struct pretty_component *pretty) |
08899d39 PP |
1144 | { |
1145 | int ret = 0; | |
1146 | ||
1147 | if (pretty->string->len == 0) { | |
1148 | goto end; | |
1149 | } | |
1150 | ||
0f6bea4e | 1151 | if (fwrite(pretty->string->str, pretty->string->len, 1, stream) != 1) { |
08899d39 PP |
1152 | ret = -1; |
1153 | } | |
1154 | ||
1155 | end: | |
1156 | return ret; | |
1157 | } | |
1158 | ||
af9a82eb | 1159 | BT_HIDDEN |
d94d92ac | 1160 | int pretty_print_event(struct pretty_component *pretty, |
d6e69534 | 1161 | const bt_message *event_msg) |
af9a82eb | 1162 | { |
d94d92ac | 1163 | int ret; |
b19ff26f | 1164 | const bt_event *event = |
d6e69534 | 1165 | bt_message_event_borrow_event_const(event_msg); |
af9a82eb | 1166 | |
f6ccaed9 | 1167 | BT_ASSERT(event); |
3228cc1d | 1168 | pretty->start_line = true; |
5280f742 | 1169 | g_string_assign(pretty->string, ""); |
2c091c04 | 1170 | ret = print_event_header(pretty, event_msg); |
d94d92ac | 1171 | if (ret != 0) { |
af9a82eb JG |
1172 | goto end; |
1173 | } | |
6a18b281 | 1174 | |
3228cc1d | 1175 | ret = print_stream_packet_context(pretty, event); |
d94d92ac | 1176 | if (ret != 0) { |
6a18b281 MD |
1177 | goto end; |
1178 | } | |
6a18b281 | 1179 | |
3228cc1d | 1180 | ret = print_stream_event_context(pretty, event); |
d94d92ac | 1181 | if (ret != 0) { |
6a18b281 MD |
1182 | goto end; |
1183 | } | |
6a18b281 | 1184 | |
3228cc1d | 1185 | ret = print_event_context(pretty, event); |
d94d92ac | 1186 | if (ret != 0) { |
6a18b281 MD |
1187 | goto end; |
1188 | } | |
6a18b281 | 1189 | |
3228cc1d | 1190 | ret = print_event_payload(pretty, event); |
d94d92ac | 1191 | if (ret != 0) { |
6a18b281 MD |
1192 | goto end; |
1193 | } | |
af9a82eb | 1194 | |
5280f742 | 1195 | g_string_append_c(pretty->string, '\n'); |
0f6bea4e | 1196 | if (flush_buf(pretty->out, pretty)) { |
d94d92ac | 1197 | ret = -1; |
5280f742 PP |
1198 | goto end; |
1199 | } | |
1200 | ||
af9a82eb JG |
1201 | end: |
1202 | return ret; | |
1203 | } | |
0f6bea4e PP |
1204 | |
1205 | static | |
8e53bed4 PP |
1206 | int print_discarded_elements_msg(struct pretty_component *pretty, |
1207 | const bt_stream *stream, | |
1208 | const bt_clock_snapshot *begin_clock_snapshot, | |
1209 | const bt_clock_snapshot *end_clock_snapshot, | |
0f6bea4e PP |
1210 | uint64_t count, const char *elem_type) |
1211 | { | |
d94d92ac | 1212 | int ret = 0; |
b19ff26f PP |
1213 | const bt_stream_class *stream_class = NULL; |
1214 | const bt_trace *trace = NULL; | |
0f6bea4e PP |
1215 | const char *stream_name; |
1216 | const char *trace_name; | |
8e53bed4 | 1217 | bt_uuid trace_uuid; |
0f6bea4e PP |
1218 | int64_t stream_class_id; |
1219 | int64_t stream_id; | |
697f479d | 1220 | const char *init_msg; |
0f6bea4e PP |
1221 | |
1222 | /* Stream name */ | |
0f6bea4e | 1223 | stream_name = bt_stream_get_name(stream); |
8e53bed4 PP |
1224 | if (!stream_name) { |
1225 | stream_name = "(unknown)"; | |
1226 | } | |
0f6bea4e PP |
1227 | |
1228 | /* Stream class ID */ | |
40f4ba76 | 1229 | stream_class = bt_stream_borrow_class_const(stream); |
0f6bea4e PP |
1230 | BT_ASSERT(stream_class); |
1231 | stream_class_id = bt_stream_class_get_id(stream_class); | |
1232 | ||
1233 | /* Stream ID */ | |
1234 | stream_id = bt_stream_get_id(stream); | |
1235 | ||
1236 | /* Trace name */ | |
8e53bed4 | 1237 | trace = bt_stream_borrow_trace_const(stream); |
0f6bea4e PP |
1238 | BT_ASSERT(trace); |
1239 | trace_name = bt_trace_get_name(trace); | |
1240 | if (!trace_name) { | |
1241 | trace_name = "(unknown)"; | |
1242 | } | |
1243 | ||
1244 | /* Trace UUID */ | |
8e53bed4 PP |
1245 | trace_uuid = bt_trace_class_get_uuid( |
1246 | bt_trace_borrow_class_const(trace)); | |
0f6bea4e PP |
1247 | |
1248 | /* Format message */ | |
1249 | g_string_assign(pretty->string, ""); | |
697f479d PP |
1250 | |
1251 | if (count == UINT64_C(-1)) { | |
1252 | init_msg = "Tracer may have discarded"; | |
1253 | } else { | |
1254 | init_msg = "Tracer discarded"; | |
1255 | } | |
1256 | ||
0f6bea4e | 1257 | g_string_append_printf(pretty->string, |
697f479d | 1258 | "%s%sWARNING%s%s: %s ", |
0f6bea4e PP |
1259 | bt_common_color_fg_yellow(), |
1260 | bt_common_color_bold(), | |
1261 | bt_common_color_reset(), | |
697f479d | 1262 | bt_common_color_fg_yellow(), init_msg); |
8e53bed4 PP |
1263 | |
1264 | if (count == UINT64_C(-1)) { | |
697f479d | 1265 | g_string_append_printf(pretty->string, "%ss", elem_type); |
8e53bed4 PP |
1266 | } else { |
1267 | g_string_append_printf(pretty->string, | |
1268 | "%" PRIu64 " %s%s", count, elem_type, | |
1269 | count == 1 ? "" : "s"); | |
1270 | } | |
0f6bea4e | 1271 | |
3f2f6b21 PP |
1272 | g_string_append_c(pretty->string, ' '); |
1273 | ||
605e1019 | 1274 | if (begin_clock_snapshot && end_clock_snapshot) { |
3f2f6b21 | 1275 | g_string_append(pretty->string, "between ["); |
9c202476 | 1276 | print_timestamp_wall(pretty, begin_clock_snapshot, false); |
0f6bea4e | 1277 | g_string_append(pretty->string, "] and ["); |
9c202476 | 1278 | print_timestamp_wall(pretty, end_clock_snapshot, false); |
0f6bea4e PP |
1279 | g_string_append(pretty->string, "]"); |
1280 | } else { | |
1281 | g_string_append(pretty->string, "(unknown time range)"); | |
1282 | } | |
1283 | ||
1284 | g_string_append_printf(pretty->string, " in trace \"%s\" ", trace_name); | |
1285 | ||
1286 | if (trace_uuid) { | |
1287 | g_string_append_printf(pretty->string, | |
1288 | "(UUID: %02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x) ", | |
1289 | trace_uuid[0], | |
1290 | trace_uuid[1], | |
1291 | trace_uuid[2], | |
1292 | trace_uuid[3], | |
1293 | trace_uuid[4], | |
1294 | trace_uuid[5], | |
1295 | trace_uuid[6], | |
1296 | trace_uuid[7], | |
1297 | trace_uuid[8], | |
1298 | trace_uuid[9], | |
1299 | trace_uuid[10], | |
1300 | trace_uuid[11], | |
1301 | trace_uuid[12], | |
1302 | trace_uuid[13], | |
1303 | trace_uuid[14], | |
1304 | trace_uuid[15]); | |
1305 | } else { | |
1306 | g_string_append(pretty->string, "(no UUID) "); | |
1307 | } | |
1308 | ||
1309 | g_string_append_printf(pretty->string, | |
8e53bed4 | 1310 | "within stream \"%s\" (stream class ID: %" PRIu64 ", ", |
0f6bea4e PP |
1311 | stream_name, stream_class_id); |
1312 | ||
1313 | if (stream_id >= 0) { | |
1314 | g_string_append_printf(pretty->string, | |
8e53bed4 | 1315 | "stream ID: %" PRIu64, stream_id); |
0f6bea4e PP |
1316 | } else { |
1317 | g_string_append(pretty->string, "no stream ID"); | |
1318 | } | |
1319 | ||
1320 | g_string_append_printf(pretty->string, ").%s\n", | |
1321 | bt_common_color_reset()); | |
1322 | ||
1323 | /* | |
1324 | * Print to standard error stream to remain backward compatible | |
1325 | * with Babeltrace 1. | |
1326 | */ | |
1327 | if (flush_buf(stderr, pretty)) { | |
d94d92ac | 1328 | ret = -1; |
0f6bea4e PP |
1329 | } |
1330 | ||
1331 | return ret; | |
1332 | } | |
1333 | ||
1334 | BT_HIDDEN | |
8e53bed4 PP |
1335 | int pretty_print_discarded_items(struct pretty_component *pretty, |
1336 | const bt_message *msg) | |
0f6bea4e | 1337 | { |
8e53bed4 PP |
1338 | const bt_clock_snapshot *begin = NULL; |
1339 | const bt_clock_snapshot *end = NULL; | |
1340 | const bt_stream *stream; | |
1341 | const bt_stream_class *stream_class; | |
1342 | uint64_t count = UINT64_C(-1); | |
1343 | const char *elem_type; | |
1344 | ||
1345 | switch (bt_message_get_type(msg)) { | |
1346 | case BT_MESSAGE_TYPE_DISCARDED_EVENTS: | |
1347 | stream = bt_message_discarded_events_borrow_stream_const(msg); | |
1348 | ||
1349 | if (bt_message_discarded_events_get_count(msg, &count) == | |
1350 | BT_PROPERTY_AVAILABILITY_NOT_AVAILABLE) { | |
1351 | count = UINT64_C(-1); | |
0f6bea4e | 1352 | } |
8e53bed4 PP |
1353 | |
1354 | elem_type = "event"; | |
1355 | break; | |
1356 | case BT_MESSAGE_TYPE_DISCARDED_PACKETS: | |
1357 | stream = bt_message_discarded_packets_borrow_stream_const(msg); | |
1358 | ||
1359 | if (bt_message_discarded_packets_get_count(msg, &count) == | |
1360 | BT_PROPERTY_AVAILABILITY_NOT_AVAILABLE) { | |
1361 | count = UINT64_C(-1); | |
1362 | } | |
1363 | ||
1364 | elem_type = "packet"; | |
1365 | break; | |
1366 | default: | |
1367 | abort(); | |
0f6bea4e PP |
1368 | } |
1369 | ||
8e53bed4 PP |
1370 | BT_ASSERT(stream); |
1371 | stream_class = bt_stream_borrow_class_const(stream); | |
1372 | ||
2e90378a PP |
1373 | switch (bt_message_get_type(msg)) { |
1374 | case BT_MESSAGE_TYPE_DISCARDED_EVENTS: | |
1375 | if (bt_stream_class_discarded_events_have_default_clock_snapshots( | |
1376 | stream_class)) { | |
9b24b6aa | 1377 | begin = bt_message_discarded_events_borrow_beginning_default_clock_snapshot_const( |
0cbc2c33 | 1378 | msg); |
9b24b6aa | 1379 | end = bt_message_discarded_events_borrow_end_default_clock_snapshot_const( |
0cbc2c33 | 1380 | msg); |
2e90378a PP |
1381 | } |
1382 | ||
1383 | break; | |
1384 | case BT_MESSAGE_TYPE_DISCARDED_PACKETS: | |
1385 | if (bt_stream_class_discarded_packets_have_default_clock_snapshots( | |
1386 | stream_class)) { | |
9b24b6aa | 1387 | begin = bt_message_discarded_packets_borrow_beginning_default_clock_snapshot_const( |
0cbc2c33 | 1388 | msg); |
9b24b6aa | 1389 | end = bt_message_discarded_packets_borrow_end_default_clock_snapshot_const( |
0cbc2c33 | 1390 | msg); |
0f6bea4e | 1391 | } |
2e90378a PP |
1392 | |
1393 | break; | |
1394 | default: | |
1395 | abort(); | |
0f6bea4e PP |
1396 | } |
1397 | ||
8e53bed4 PP |
1398 | print_discarded_elements_msg(pretty, stream, begin, end, |
1399 | count, elem_type); | |
44c440bc | 1400 | return 0; |
0f6bea4e | 1401 | } |