| 1 | /* |
| 2 | * Babeltrace - Debug Information State Tracker |
| 3 | * |
| 4 | * Copyright (c) 2015 EfficiOS Inc. and Linux Foundation |
| 5 | * Copyright (c) 2015 Philippe Proulx <pproulx@efficios.com> |
| 6 | * Copyright (c) 2015 Antoine Busque <abusque@efficios.com> |
| 7 | * Copyright (c) 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com> |
| 8 | * Copyright (c) 2019 Francis Deslauriers <francis.deslauriers@efficios.com> |
| 9 | * |
| 10 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
| 11 | * of this software and associated documentation files (the "Software"), to deal |
| 12 | * in the Software without restriction, including without limitation the rights |
| 13 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 14 | * copies of the Software, and to permit persons to whom the Software is |
| 15 | * furnished to do so, subject to the following conditions: |
| 16 | * |
| 17 | * The above copyright notice and this permission notice shall be included in |
| 18 | * all copies or substantial portions of the Software. |
| 19 | * |
| 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 21 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 22 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 23 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 24 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 25 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 26 | * SOFTWARE. |
| 27 | */ |
| 28 | |
| 29 | #define BT_COMP_LOG_SELF_COMP self_comp |
| 30 | #define BT_LOG_OUTPUT_LEVEL log_level |
| 31 | #define BT_LOG_TAG "PLUGIN/FLT.LTTNG-UTILS.DEBUG-INFO" |
| 32 | #include "plugins/comp-logging.h" |
| 33 | |
| 34 | #include <glib.h> |
| 35 | |
| 36 | #include "common/assert.h" |
| 37 | #include "common/common.h" |
| 38 | #include "fd-cache/fd-cache.h" |
| 39 | |
| 40 | #include "bin-info.h" |
| 41 | #include "debug-info.h" |
| 42 | #include "trace-ir-data-copy.h" |
| 43 | #include "trace-ir-mapping.h" |
| 44 | #include "trace-ir-metadata-copy.h" |
| 45 | #include "utils.h" |
| 46 | |
| 47 | #define DEFAULT_DEBUG_INFO_FIELD_NAME "debug_info" |
| 48 | #define LTTNG_UST_STATEDUMP_PREFIX "lttng_ust" |
| 49 | #define VPID_FIELD_NAME "vpid" |
| 50 | #define IP_FIELD_NAME "ip" |
| 51 | #define BADDR_FIELD_NAME "baddr" |
| 52 | #define CRC32_FIELD_NAME "crc" |
| 53 | #define BUILD_ID_FIELD_NAME "build_id" |
| 54 | #define FILENAME_FIELD_NAME "filename" |
| 55 | #define IS_PIC_FIELD_NAME "is_pic" |
| 56 | #define MEMSZ_FIELD_NAME "memsz" |
| 57 | #define PATH_FIELD_NAME "path" |
| 58 | |
| 59 | struct debug_info_component { |
| 60 | bt_logging_level log_level; |
| 61 | bt_self_component *self_comp; |
| 62 | gchar *arg_debug_dir; |
| 63 | gchar *arg_debug_info_field_name; |
| 64 | gchar *arg_target_prefix; |
| 65 | bt_bool arg_full_path; |
| 66 | }; |
| 67 | |
| 68 | struct debug_info_msg_iter { |
| 69 | bt_logging_level log_level; |
| 70 | struct debug_info_component *debug_info_component; |
| 71 | bt_self_message_iterator *input_iterator; |
| 72 | bt_self_component *self_comp; |
| 73 | bt_self_component_port_input_message_iterator *msg_iter; |
| 74 | |
| 75 | struct trace_ir_maps *ir_maps; |
| 76 | /* in_trace -> debug_info_mapping. */ |
| 77 | GHashTable *debug_info_map; |
| 78 | |
| 79 | struct bt_fd_cache fd_cache; |
| 80 | }; |
| 81 | |
| 82 | struct debug_info_source { |
| 83 | /* Strings are owned by debug_info_source. */ |
| 84 | gchar *func; |
| 85 | /* |
| 86 | * Store the line number as a string so that the allocation and |
| 87 | * conversion to string is only done once. |
| 88 | */ |
| 89 | gchar *line_no; |
| 90 | gchar *src_path; |
| 91 | /* short_src_path points inside src_path, no need to free. */ |
| 92 | const gchar *short_src_path; |
| 93 | gchar *bin_path; |
| 94 | /* short_bin_path points inside bin_path, no need to free. */ |
| 95 | const gchar *short_bin_path; |
| 96 | /* |
| 97 | * Location within the binary. Either absolute (@0x1234) or |
| 98 | * relative (+0x4321). |
| 99 | */ |
| 100 | gchar *bin_loc; |
| 101 | }; |
| 102 | |
| 103 | struct proc_debug_info_sources { |
| 104 | /* |
| 105 | * Hash table: base address (pointer to uint64_t) to bin info; owned by |
| 106 | * proc_debug_info_sources. |
| 107 | */ |
| 108 | GHashTable *baddr_to_bin_info; |
| 109 | |
| 110 | /* |
| 111 | * Hash table: IP (pointer to uint64_t) to (struct debug_info_source *); |
| 112 | * owned by proc_debug_info_sources. |
| 113 | */ |
| 114 | GHashTable *ip_to_debug_info_src; |
| 115 | }; |
| 116 | |
| 117 | struct debug_info { |
| 118 | bt_logging_level log_level; |
| 119 | bt_self_component *self_comp; |
| 120 | struct debug_info_component *comp; |
| 121 | const bt_trace *input_trace; |
| 122 | uint64_t destruction_listener_id; |
| 123 | |
| 124 | /* |
| 125 | * Hash table of VPIDs (pointer to int64_t) to |
| 126 | * (struct proc_debug_info_sources*); owned by debug_info. |
| 127 | */ |
| 128 | GHashTable *vpid_to_proc_dbg_info_src; |
| 129 | GQuark q_statedump_bin_info; |
| 130 | GQuark q_statedump_debug_link; |
| 131 | GQuark q_statedump_build_id; |
| 132 | GQuark q_statedump_start; |
| 133 | GQuark q_dl_open; |
| 134 | GQuark q_lib_load; |
| 135 | GQuark q_lib_unload; |
| 136 | struct bt_fd_cache *fd_cache; /* Weak ref. Owned by the iterator. */ |
| 137 | }; |
| 138 | |
| 139 | static |
| 140 | int debug_info_init(struct debug_info *info) |
| 141 | { |
| 142 | info->q_statedump_bin_info = g_quark_from_string( |
| 143 | "lttng_ust_statedump:bin_info"); |
| 144 | info->q_statedump_debug_link = g_quark_from_string( |
| 145 | "lttng_ust_statedump:debug_link"); |
| 146 | info->q_statedump_build_id = g_quark_from_string( |
| 147 | "lttng_ust_statedump:build_id"); |
| 148 | info->q_statedump_start = g_quark_from_string( |
| 149 | "lttng_ust_statedump:start"); |
| 150 | info->q_dl_open = g_quark_from_string("lttng_ust_dl:dlopen"); |
| 151 | info->q_lib_load = g_quark_from_string("lttng_ust_lib:load"); |
| 152 | info->q_lib_unload = g_quark_from_string("lttng_ust_lib:unload"); |
| 153 | |
| 154 | return bin_info_init(info->log_level, info->self_comp); |
| 155 | } |
| 156 | |
| 157 | static |
| 158 | void debug_info_source_destroy(struct debug_info_source *debug_info_src) |
| 159 | { |
| 160 | if (!debug_info_src) { |
| 161 | return; |
| 162 | } |
| 163 | |
| 164 | g_free(debug_info_src->func); |
| 165 | g_free(debug_info_src->line_no); |
| 166 | g_free(debug_info_src->src_path); |
| 167 | g_free(debug_info_src->bin_path); |
| 168 | g_free(debug_info_src->bin_loc); |
| 169 | g_free(debug_info_src); |
| 170 | } |
| 171 | |
| 172 | static |
| 173 | struct debug_info_source *debug_info_source_create_from_bin( |
| 174 | struct bin_info *bin, uint64_t ip, |
| 175 | bt_self_component *self_comp) |
| 176 | { |
| 177 | int ret; |
| 178 | struct debug_info_source *debug_info_src = NULL; |
| 179 | struct source_location *src_loc = NULL; |
| 180 | bt_logging_level log_level = bin->log_level; |
| 181 | |
| 182 | debug_info_src = g_new0(struct debug_info_source, 1); |
| 183 | |
| 184 | if (!debug_info_src) { |
| 185 | goto end; |
| 186 | } |
| 187 | |
| 188 | /* Lookup function name */ |
| 189 | ret = bin_info_lookup_function_name(bin, ip, &debug_info_src->func); |
| 190 | if (ret) { |
| 191 | goto error; |
| 192 | } |
| 193 | |
| 194 | /* Can't retrieve src_loc from ELF, or could not find binary, skip. */ |
| 195 | if (!bin->is_elf_only || !debug_info_src->func) { |
| 196 | /* Lookup source location */ |
| 197 | ret = bin_info_lookup_source_location(bin, ip, &src_loc); |
| 198 | if (ret) { |
| 199 | BT_COMP_LOGI("Failed to lookup source location: ret=%d", ret); |
| 200 | } |
| 201 | } |
| 202 | |
| 203 | if (src_loc) { |
| 204 | debug_info_src->line_no = |
| 205 | g_strdup_printf("%"PRId64, src_loc->line_no); |
| 206 | if (!debug_info_src->line_no) { |
| 207 | BT_COMP_LOGE("Error occured when setting line_no field."); |
| 208 | goto error; |
| 209 | } |
| 210 | |
| 211 | if (src_loc->filename) { |
| 212 | debug_info_src->src_path = g_strdup(src_loc->filename); |
| 213 | if (!debug_info_src->src_path) { |
| 214 | goto error; |
| 215 | } |
| 216 | |
| 217 | debug_info_src->short_src_path = get_filename_from_path( |
| 218 | debug_info_src->src_path); |
| 219 | } |
| 220 | source_location_destroy(src_loc); |
| 221 | } |
| 222 | |
| 223 | if (bin->elf_path) { |
| 224 | debug_info_src->bin_path = g_strdup(bin->elf_path); |
| 225 | if (!debug_info_src->bin_path) { |
| 226 | goto error; |
| 227 | } |
| 228 | |
| 229 | debug_info_src->short_bin_path = get_filename_from_path( |
| 230 | debug_info_src->bin_path); |
| 231 | |
| 232 | ret = bin_info_get_bin_loc(bin, ip, &(debug_info_src->bin_loc)); |
| 233 | if (ret) { |
| 234 | goto error; |
| 235 | } |
| 236 | } |
| 237 | |
| 238 | end: |
| 239 | return debug_info_src; |
| 240 | |
| 241 | error: |
| 242 | debug_info_source_destroy(debug_info_src); |
| 243 | return NULL; |
| 244 | } |
| 245 | |
| 246 | static |
| 247 | void proc_debug_info_sources_destroy( |
| 248 | struct proc_debug_info_sources *proc_dbg_info_src) |
| 249 | { |
| 250 | if (!proc_dbg_info_src) { |
| 251 | return; |
| 252 | } |
| 253 | |
| 254 | if (proc_dbg_info_src->baddr_to_bin_info) { |
| 255 | g_hash_table_destroy(proc_dbg_info_src->baddr_to_bin_info); |
| 256 | } |
| 257 | |
| 258 | if (proc_dbg_info_src->ip_to_debug_info_src) { |
| 259 | g_hash_table_destroy(proc_dbg_info_src->ip_to_debug_info_src); |
| 260 | } |
| 261 | |
| 262 | g_free(proc_dbg_info_src); |
| 263 | } |
| 264 | |
| 265 | static |
| 266 | struct proc_debug_info_sources *proc_debug_info_sources_create(void) |
| 267 | { |
| 268 | struct proc_debug_info_sources *proc_dbg_info_src = NULL; |
| 269 | |
| 270 | proc_dbg_info_src = g_new0(struct proc_debug_info_sources, 1); |
| 271 | if (!proc_dbg_info_src) { |
| 272 | goto end; |
| 273 | } |
| 274 | |
| 275 | proc_dbg_info_src->baddr_to_bin_info = g_hash_table_new_full( |
| 276 | g_int64_hash, g_int64_equal, (GDestroyNotify) g_free, |
| 277 | (GDestroyNotify) bin_info_destroy); |
| 278 | if (!proc_dbg_info_src->baddr_to_bin_info) { |
| 279 | goto error; |
| 280 | } |
| 281 | |
| 282 | proc_dbg_info_src->ip_to_debug_info_src = g_hash_table_new_full( |
| 283 | g_int64_hash, g_int64_equal, (GDestroyNotify) g_free, |
| 284 | (GDestroyNotify) debug_info_source_destroy); |
| 285 | if (!proc_dbg_info_src->ip_to_debug_info_src) { |
| 286 | goto error; |
| 287 | } |
| 288 | |
| 289 | end: |
| 290 | return proc_dbg_info_src; |
| 291 | |
| 292 | error: |
| 293 | proc_debug_info_sources_destroy(proc_dbg_info_src); |
| 294 | return NULL; |
| 295 | } |
| 296 | |
| 297 | static |
| 298 | struct proc_debug_info_sources *proc_debug_info_sources_ht_get_entry( |
| 299 | GHashTable *ht, int64_t vpid) |
| 300 | { |
| 301 | gpointer key = g_new0(int64_t, 1); |
| 302 | struct proc_debug_info_sources *proc_dbg_info_src = NULL; |
| 303 | |
| 304 | if (!key) { |
| 305 | goto end; |
| 306 | } |
| 307 | |
| 308 | *((int64_t *) key) = vpid; |
| 309 | |
| 310 | /* Exists? Return it */ |
| 311 | proc_dbg_info_src = g_hash_table_lookup(ht, key); |
| 312 | if (proc_dbg_info_src) { |
| 313 | goto end; |
| 314 | } |
| 315 | |
| 316 | /* Otherwise, create and return it */ |
| 317 | proc_dbg_info_src = proc_debug_info_sources_create(); |
| 318 | if (!proc_dbg_info_src) { |
| 319 | goto end; |
| 320 | } |
| 321 | |
| 322 | g_hash_table_insert(ht, key, proc_dbg_info_src); |
| 323 | /* Ownership passed to ht */ |
| 324 | key = NULL; |
| 325 | end: |
| 326 | g_free(key); |
| 327 | return proc_dbg_info_src; |
| 328 | } |
| 329 | |
| 330 | static inline |
| 331 | const bt_field *event_borrow_payload_field(const bt_event *event, |
| 332 | const char *field_name) |
| 333 | { |
| 334 | const bt_field *event_payload, *field; |
| 335 | |
| 336 | event_payload = bt_event_borrow_payload_field_const(event); |
| 337 | BT_ASSERT(event_payload); |
| 338 | |
| 339 | field = bt_field_structure_borrow_member_field_by_name_const( |
| 340 | event_payload, field_name); |
| 341 | return field; |
| 342 | } |
| 343 | |
| 344 | static inline |
| 345 | const bt_field *event_borrow_common_context_field(const bt_event *event, |
| 346 | const char *field_name) |
| 347 | { |
| 348 | const bt_field *event_common_ctx, *field = NULL; |
| 349 | |
| 350 | event_common_ctx = bt_event_borrow_common_context_field_const(event); |
| 351 | if (!event_common_ctx) { |
| 352 | goto end; |
| 353 | } |
| 354 | |
| 355 | field = bt_field_structure_borrow_member_field_by_name_const( |
| 356 | event_common_ctx, field_name); |
| 357 | |
| 358 | end: |
| 359 | return field; |
| 360 | } |
| 361 | |
| 362 | static inline |
| 363 | void event_get_common_context_signed_integer_field_value( |
| 364 | const bt_event *event, const char *field_name, int64_t *value) |
| 365 | { |
| 366 | *value = bt_field_signed_integer_get_value( |
| 367 | event_borrow_common_context_field(event, field_name)); |
| 368 | } |
| 369 | |
| 370 | static inline |
| 371 | int event_get_payload_build_id_length(const bt_event *event, |
| 372 | const char *field_name, uint64_t *build_id_len) |
| 373 | { |
| 374 | const bt_field *build_id_field; |
| 375 | const bt_field_class *build_id_field_class; |
| 376 | |
| 377 | build_id_field = event_borrow_payload_field(event, field_name); |
| 378 | build_id_field_class = bt_field_borrow_class_const(build_id_field); |
| 379 | |
| 380 | BT_ASSERT(bt_field_class_get_type(build_id_field_class) == |
| 381 | BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY); |
| 382 | BT_ASSERT(bt_field_class_get_type( |
| 383 | bt_field_class_array_borrow_element_field_class_const( |
| 384 | build_id_field_class)) == |
| 385 | BT_FIELD_CLASS_TYPE_UNSIGNED_INTEGER); |
| 386 | |
| 387 | *build_id_len = bt_field_array_get_length(build_id_field); |
| 388 | |
| 389 | return 0; |
| 390 | } |
| 391 | |
| 392 | static inline |
| 393 | int event_get_payload_build_id_value(const bt_event *event, |
| 394 | const char *field_name, uint8_t *build_id) |
| 395 | { |
| 396 | const bt_field *curr_field, *build_id_field; |
| 397 | const bt_field_class *build_id_field_class; |
| 398 | uint64_t i, build_id_len; |
| 399 | int ret; |
| 400 | |
| 401 | ret = 0; |
| 402 | |
| 403 | build_id_field = event_borrow_payload_field(event, field_name); |
| 404 | build_id_field_class = bt_field_borrow_class_const(build_id_field); |
| 405 | |
| 406 | BT_ASSERT(bt_field_class_get_type(build_id_field_class) == |
| 407 | BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY); |
| 408 | BT_ASSERT(bt_field_class_get_type( |
| 409 | bt_field_class_array_borrow_element_field_class_const( |
| 410 | build_id_field_class)) == |
| 411 | BT_FIELD_CLASS_TYPE_UNSIGNED_INTEGER); |
| 412 | |
| 413 | build_id_len = bt_field_array_get_length(build_id_field); |
| 414 | |
| 415 | for (i = 0; i < build_id_len; i++) { |
| 416 | curr_field = |
| 417 | bt_field_array_borrow_element_field_by_index_const( |
| 418 | build_id_field, i); |
| 419 | |
| 420 | build_id[i] = bt_field_unsigned_integer_get_value(curr_field); |
| 421 | } |
| 422 | |
| 423 | return ret; |
| 424 | } |
| 425 | |
| 426 | static |
| 427 | void event_get_payload_unsigned_integer_field_value(const bt_event *event, |
| 428 | const char *field_name, uint64_t *value) |
| 429 | { |
| 430 | *value = bt_field_unsigned_integer_get_value( |
| 431 | event_borrow_payload_field(event, field_name)); |
| 432 | } |
| 433 | |
| 434 | static |
| 435 | void event_get_payload_string_field_value(const bt_event *event, |
| 436 | const char *field_name, const char **value) |
| 437 | { |
| 438 | *value = bt_field_string_get_value( |
| 439 | event_borrow_payload_field(event, field_name)); |
| 440 | } |
| 441 | |
| 442 | static inline |
| 443 | bool event_has_payload_field(const bt_event *event, |
| 444 | const char *field_name) |
| 445 | { |
| 446 | return event_borrow_payload_field(event, field_name) != NULL; |
| 447 | } |
| 448 | |
| 449 | static |
| 450 | struct debug_info_source *proc_debug_info_sources_get_entry( |
| 451 | struct debug_info *debug_info, |
| 452 | struct proc_debug_info_sources *proc_dbg_info_src, uint64_t ip) |
| 453 | { |
| 454 | struct debug_info_source *debug_info_src = NULL; |
| 455 | gpointer key = g_new0(uint64_t, 1); |
| 456 | GHashTableIter iter; |
| 457 | gpointer baddr, value; |
| 458 | |
| 459 | if (!key) { |
| 460 | goto end; |
| 461 | } |
| 462 | |
| 463 | *((uint64_t *) key) = ip; |
| 464 | |
| 465 | /* Look in IP to debug infos hash table first. */ |
| 466 | debug_info_src = g_hash_table_lookup( |
| 467 | proc_dbg_info_src->ip_to_debug_info_src, |
| 468 | key); |
| 469 | if (debug_info_src) { |
| 470 | goto end; |
| 471 | } |
| 472 | |
| 473 | /* Check in all bin_infos. */ |
| 474 | g_hash_table_iter_init(&iter, proc_dbg_info_src->baddr_to_bin_info); |
| 475 | |
| 476 | while (g_hash_table_iter_next(&iter, &baddr, &value)) |
| 477 | { |
| 478 | struct bin_info *bin = value; |
| 479 | |
| 480 | if (!bin_info_has_address(value, ip)) { |
| 481 | continue; |
| 482 | } |
| 483 | |
| 484 | /* |
| 485 | * Found; add it to cache. |
| 486 | * |
| 487 | * FIXME: this should be bounded in size (and implement |
| 488 | * a caching policy), and entries should be prunned when |
| 489 | * libraries are unmapped. |
| 490 | */ |
| 491 | debug_info_src = debug_info_source_create_from_bin(bin, ip, |
| 492 | debug_info->self_comp); |
| 493 | if (debug_info_src) { |
| 494 | g_hash_table_insert( |
| 495 | proc_dbg_info_src->ip_to_debug_info_src, |
| 496 | key, debug_info_src); |
| 497 | /* Ownership passed to ht. */ |
| 498 | key = NULL; |
| 499 | } |
| 500 | break; |
| 501 | } |
| 502 | |
| 503 | end: |
| 504 | free(key); |
| 505 | return debug_info_src; |
| 506 | } |
| 507 | |
| 508 | static |
| 509 | struct debug_info_source *debug_info_query(struct debug_info *debug_info, |
| 510 | int64_t vpid, uint64_t ip) |
| 511 | { |
| 512 | struct debug_info_source *dbg_info_src = NULL; |
| 513 | struct proc_debug_info_sources *proc_dbg_info_src; |
| 514 | |
| 515 | proc_dbg_info_src = proc_debug_info_sources_ht_get_entry( |
| 516 | debug_info->vpid_to_proc_dbg_info_src, vpid); |
| 517 | if (!proc_dbg_info_src) { |
| 518 | goto end; |
| 519 | } |
| 520 | |
| 521 | dbg_info_src = proc_debug_info_sources_get_entry(debug_info, |
| 522 | proc_dbg_info_src, ip); |
| 523 | |
| 524 | end: |
| 525 | return dbg_info_src; |
| 526 | } |
| 527 | |
| 528 | static |
| 529 | struct debug_info *debug_info_create(struct debug_info_component *comp, |
| 530 | const bt_trace *trace, struct bt_fd_cache *fdc) |
| 531 | { |
| 532 | int ret; |
| 533 | struct debug_info *debug_info; |
| 534 | |
| 535 | BT_ASSERT(comp); |
| 536 | BT_ASSERT(trace); |
| 537 | BT_ASSERT(fdc); |
| 538 | |
| 539 | debug_info = g_new0(struct debug_info, 1); |
| 540 | if (!debug_info) { |
| 541 | goto end; |
| 542 | } |
| 543 | |
| 544 | debug_info->log_level = comp->log_level; |
| 545 | debug_info->self_comp = comp->self_comp; |
| 546 | debug_info->vpid_to_proc_dbg_info_src = g_hash_table_new_full( |
| 547 | g_int64_hash, g_int64_equal, (GDestroyNotify) g_free, |
| 548 | (GDestroyNotify) proc_debug_info_sources_destroy); |
| 549 | if (!debug_info->vpid_to_proc_dbg_info_src) { |
| 550 | goto error; |
| 551 | } |
| 552 | |
| 553 | debug_info->comp = comp; |
| 554 | ret = debug_info_init(debug_info); |
| 555 | if (ret) { |
| 556 | goto error; |
| 557 | } |
| 558 | |
| 559 | debug_info->input_trace = trace; |
| 560 | debug_info->fd_cache = fdc; |
| 561 | |
| 562 | end: |
| 563 | return debug_info; |
| 564 | error: |
| 565 | g_free(debug_info); |
| 566 | return NULL; |
| 567 | } |
| 568 | |
| 569 | static |
| 570 | void debug_info_destroy(struct debug_info *debug_info) |
| 571 | { |
| 572 | bt_logging_level log_level; |
| 573 | bt_self_component *self_comp; |
| 574 | bt_trace_status status; |
| 575 | if (!debug_info) { |
| 576 | goto end; |
| 577 | } |
| 578 | |
| 579 | log_level = debug_info->log_level; |
| 580 | self_comp = debug_info->self_comp; |
| 581 | |
| 582 | if (debug_info->vpid_to_proc_dbg_info_src) { |
| 583 | g_hash_table_destroy(debug_info->vpid_to_proc_dbg_info_src); |
| 584 | } |
| 585 | |
| 586 | status = bt_trace_remove_destruction_listener(debug_info->input_trace, |
| 587 | debug_info->destruction_listener_id); |
| 588 | if (status != BT_TRACE_STATUS_OK) { |
| 589 | BT_COMP_LOGE("Trace destruction listener removal failed."); |
| 590 | } |
| 591 | |
| 592 | g_free(debug_info); |
| 593 | end: |
| 594 | return; |
| 595 | } |
| 596 | |
| 597 | static |
| 598 | void handle_event_statedump_build_id(struct debug_info *debug_info, |
| 599 | const bt_event *event) |
| 600 | { |
| 601 | struct proc_debug_info_sources *proc_dbg_info_src; |
| 602 | uint64_t build_id_len, baddr; |
| 603 | uint8_t *build_id = NULL; |
| 604 | struct bin_info *bin; |
| 605 | int64_t vpid; |
| 606 | int ret = 0; |
| 607 | |
| 608 | event_get_common_context_signed_integer_field_value(event, |
| 609 | VPID_FIELD_NAME, &vpid); |
| 610 | event_get_payload_unsigned_integer_field_value(event, |
| 611 | BADDR_FIELD_NAME, &baddr); |
| 612 | |
| 613 | proc_dbg_info_src = proc_debug_info_sources_ht_get_entry( |
| 614 | debug_info->vpid_to_proc_dbg_info_src, vpid); |
| 615 | if (!proc_dbg_info_src) { |
| 616 | goto end; |
| 617 | } |
| 618 | |
| 619 | bin = g_hash_table_lookup(proc_dbg_info_src->baddr_to_bin_info, |
| 620 | (gpointer) &baddr); |
| 621 | if (!bin) { |
| 622 | /* |
| 623 | * The build_id event comes after the bin has been |
| 624 | * created. If it isn't found, just ignore this event. |
| 625 | */ |
| 626 | goto end; |
| 627 | } |
| 628 | ret = event_get_payload_build_id_length(event, BUILD_ID_FIELD_NAME, |
| 629 | &build_id_len); |
| 630 | |
| 631 | build_id = g_new0(uint8_t, build_id_len); |
| 632 | if (!build_id) { |
| 633 | goto end; |
| 634 | } |
| 635 | |
| 636 | ret = event_get_payload_build_id_value(event, BUILD_ID_FIELD_NAME, |
| 637 | build_id); |
| 638 | if (ret) { |
| 639 | goto end; |
| 640 | } |
| 641 | |
| 642 | ret = bin_info_set_build_id(bin, build_id, build_id_len); |
| 643 | if (ret) { |
| 644 | goto end; |
| 645 | } |
| 646 | |
| 647 | /* |
| 648 | * Reset the is_elf_only flag in case it had been set |
| 649 | * previously, because we might find separate debug info using |
| 650 | * the new build id information. |
| 651 | */ |
| 652 | bin->is_elf_only = false; |
| 653 | |
| 654 | end: |
| 655 | g_free(build_id); |
| 656 | return; |
| 657 | } |
| 658 | |
| 659 | static |
| 660 | void handle_event_statedump_debug_link(struct debug_info *debug_info, |
| 661 | const bt_event *event) |
| 662 | { |
| 663 | struct proc_debug_info_sources *proc_dbg_info_src; |
| 664 | struct bin_info *bin = NULL; |
| 665 | int64_t vpid; |
| 666 | uint64_t baddr; |
| 667 | const char *filename = NULL; |
| 668 | uint32_t crc32; |
| 669 | uint64_t crc_field_value; |
| 670 | |
| 671 | event_get_common_context_signed_integer_field_value(event, |
| 672 | VPID_FIELD_NAME, &vpid); |
| 673 | |
| 674 | event_get_payload_unsigned_integer_field_value(event, |
| 675 | BADDR_FIELD_NAME, &baddr); |
| 676 | |
| 677 | event_get_payload_unsigned_integer_field_value(event, |
| 678 | CRC32_FIELD_NAME, &crc_field_value); |
| 679 | |
| 680 | crc32 = (uint32_t) crc_field_value; |
| 681 | |
| 682 | event_get_payload_string_field_value(event, |
| 683 | FILENAME_FIELD_NAME, &filename); |
| 684 | |
| 685 | proc_dbg_info_src = proc_debug_info_sources_ht_get_entry( |
| 686 | debug_info->vpid_to_proc_dbg_info_src, vpid); |
| 687 | if (!proc_dbg_info_src) { |
| 688 | goto end; |
| 689 | } |
| 690 | |
| 691 | bin = g_hash_table_lookup(proc_dbg_info_src->baddr_to_bin_info, |
| 692 | (gpointer) &baddr); |
| 693 | if (!bin) { |
| 694 | /* |
| 695 | * The debug_link event comes after the bin has been |
| 696 | * created. If it isn't found, just ignore this event. |
| 697 | */ |
| 698 | goto end; |
| 699 | } |
| 700 | |
| 701 | bin_info_set_debug_link(bin, filename, crc32); |
| 702 | |
| 703 | end: |
| 704 | return; |
| 705 | } |
| 706 | |
| 707 | static |
| 708 | void handle_bin_info_event(struct debug_info *debug_info, |
| 709 | const bt_event *event, bool has_pic_field) |
| 710 | { |
| 711 | struct proc_debug_info_sources *proc_dbg_info_src; |
| 712 | struct bin_info *bin; |
| 713 | uint64_t baddr, memsz; |
| 714 | int64_t vpid; |
| 715 | const char *path; |
| 716 | gpointer key = NULL; |
| 717 | bool is_pic; |
| 718 | |
| 719 | event_get_payload_unsigned_integer_field_value(event, |
| 720 | MEMSZ_FIELD_NAME, &memsz); |
| 721 | if (memsz == 0) { |
| 722 | /* Ignore VDSO. */ |
| 723 | goto end; |
| 724 | } |
| 725 | |
| 726 | event_get_payload_unsigned_integer_field_value(event, |
| 727 | BADDR_FIELD_NAME, &baddr); |
| 728 | |
| 729 | /* |
| 730 | * This field is not produced by the dlopen event emitted before |
| 731 | * lttng-ust 2.9. |
| 732 | */ |
| 733 | if (!event_has_payload_field(event, PATH_FIELD_NAME)) { |
| 734 | goto end; |
| 735 | } |
| 736 | event_get_payload_string_field_value(event, PATH_FIELD_NAME, &path); |
| 737 | |
| 738 | if (has_pic_field) { |
| 739 | uint64_t is_pic_field_value; |
| 740 | |
| 741 | event_get_payload_unsigned_integer_field_value(event, |
| 742 | IS_PIC_FIELD_NAME, &is_pic_field_value); |
| 743 | is_pic = is_pic_field_value == 1; |
| 744 | } else { |
| 745 | /* |
| 746 | * dlopen has no is_pic field, because the shared |
| 747 | * object is always PIC. |
| 748 | */ |
| 749 | is_pic = true; |
| 750 | } |
| 751 | |
| 752 | event_get_common_context_signed_integer_field_value(event, |
| 753 | VPID_FIELD_NAME, &vpid); |
| 754 | |
| 755 | proc_dbg_info_src = proc_debug_info_sources_ht_get_entry( |
| 756 | debug_info->vpid_to_proc_dbg_info_src, vpid); |
| 757 | if (!proc_dbg_info_src) { |
| 758 | goto end; |
| 759 | } |
| 760 | |
| 761 | key = g_new0(uint64_t, 1); |
| 762 | if (!key) { |
| 763 | goto end; |
| 764 | } |
| 765 | |
| 766 | *((uint64_t *) key) = baddr; |
| 767 | |
| 768 | bin = g_hash_table_lookup(proc_dbg_info_src->baddr_to_bin_info, key); |
| 769 | if (bin) { |
| 770 | goto end; |
| 771 | } |
| 772 | |
| 773 | bin = bin_info_create(debug_info->fd_cache, path, baddr, memsz, is_pic, |
| 774 | debug_info->comp->arg_debug_dir, |
| 775 | debug_info->comp->arg_target_prefix, |
| 776 | debug_info->log_level, debug_info->self_comp); |
| 777 | if (!bin) { |
| 778 | goto end; |
| 779 | } |
| 780 | |
| 781 | g_hash_table_insert(proc_dbg_info_src->baddr_to_bin_info, key, bin); |
| 782 | /* Ownership passed to ht. */ |
| 783 | key = NULL; |
| 784 | |
| 785 | end: |
| 786 | g_free(key); |
| 787 | return; |
| 788 | } |
| 789 | |
| 790 | static inline |
| 791 | void handle_event_statedump_bin_info(struct debug_info *debug_info, |
| 792 | const bt_event *event) |
| 793 | { |
| 794 | handle_bin_info_event(debug_info, event, true); |
| 795 | } |
| 796 | |
| 797 | static inline |
| 798 | void handle_event_lib_load(struct debug_info *debug_info, |
| 799 | const bt_event *event) |
| 800 | { |
| 801 | handle_bin_info_event(debug_info, event, false); |
| 802 | } |
| 803 | |
| 804 | static |
| 805 | void handle_event_lib_unload(struct debug_info *debug_info, |
| 806 | const bt_event *event) |
| 807 | { |
| 808 | gboolean ret; |
| 809 | struct proc_debug_info_sources *proc_dbg_info_src; |
| 810 | uint64_t baddr; |
| 811 | int64_t vpid; |
| 812 | |
| 813 | event_get_payload_unsigned_integer_field_value(event, BADDR_FIELD_NAME, |
| 814 | &baddr); |
| 815 | |
| 816 | event_get_common_context_signed_integer_field_value(event, |
| 817 | VPID_FIELD_NAME, &vpid); |
| 818 | |
| 819 | proc_dbg_info_src = proc_debug_info_sources_ht_get_entry( |
| 820 | debug_info->vpid_to_proc_dbg_info_src, vpid); |
| 821 | if (!proc_dbg_info_src) { |
| 822 | /* |
| 823 | * It's an unload event for a library for which no load event |
| 824 | * was previously received. |
| 825 | */ |
| 826 | goto end; |
| 827 | } |
| 828 | |
| 829 | ret = g_hash_table_remove(proc_dbg_info_src->baddr_to_bin_info, |
| 830 | (gpointer) &baddr); |
| 831 | BT_ASSERT(ret); |
| 832 | end: |
| 833 | return; |
| 834 | } |
| 835 | |
| 836 | static |
| 837 | void handle_event_statedump_start(struct debug_info *debug_info, |
| 838 | const bt_event *event) |
| 839 | { |
| 840 | struct proc_debug_info_sources *proc_dbg_info_src; |
| 841 | int64_t vpid; |
| 842 | |
| 843 | event_get_common_context_signed_integer_field_value( |
| 844 | event, VPID_FIELD_NAME, &vpid); |
| 845 | |
| 846 | proc_dbg_info_src = proc_debug_info_sources_ht_get_entry( |
| 847 | debug_info->vpid_to_proc_dbg_info_src, vpid); |
| 848 | if (!proc_dbg_info_src) { |
| 849 | goto end; |
| 850 | } |
| 851 | |
| 852 | g_hash_table_remove_all(proc_dbg_info_src->baddr_to_bin_info); |
| 853 | g_hash_table_remove_all(proc_dbg_info_src->ip_to_debug_info_src); |
| 854 | |
| 855 | end: |
| 856 | return; |
| 857 | } |
| 858 | |
| 859 | void trace_debug_info_remove_func(const bt_trace *in_trace, void *data) |
| 860 | { |
| 861 | struct debug_info_msg_iter *debug_it = data; |
| 862 | if (debug_it->debug_info_map) { |
| 863 | gboolean ret; |
| 864 | ret = g_hash_table_remove(debug_it->debug_info_map, |
| 865 | (gpointer) in_trace); |
| 866 | BT_ASSERT(ret); |
| 867 | } |
| 868 | } |
| 869 | |
| 870 | static |
| 871 | void handle_event_statedump(struct debug_info_msg_iter *debug_it, |
| 872 | const bt_event *event) |
| 873 | { |
| 874 | const bt_event_class *event_class; |
| 875 | const char *event_name; |
| 876 | GQuark q_event_name; |
| 877 | const bt_trace *trace; |
| 878 | struct debug_info *debug_info; |
| 879 | |
| 880 | BT_ASSERT(debug_it); |
| 881 | BT_ASSERT(event); |
| 882 | |
| 883 | event_class = bt_event_borrow_class_const(event); |
| 884 | |
| 885 | event_name = bt_event_class_get_name(event_class); |
| 886 | |
| 887 | trace = bt_stream_borrow_trace_const( |
| 888 | bt_event_borrow_stream_const(event)); |
| 889 | |
| 890 | debug_info = g_hash_table_lookup(debug_it->debug_info_map, trace); |
| 891 | if (!debug_info) { |
| 892 | debug_info = debug_info_create(debug_it->debug_info_component, |
| 893 | trace, &debug_it->fd_cache); |
| 894 | g_hash_table_insert(debug_it->debug_info_map, (gpointer) trace, |
| 895 | debug_info); |
| 896 | bt_trace_add_destruction_listener(trace, |
| 897 | trace_debug_info_remove_func, debug_it, |
| 898 | &debug_info->destruction_listener_id); |
| 899 | } |
| 900 | |
| 901 | q_event_name = g_quark_try_string(event_name); |
| 902 | |
| 903 | if (q_event_name == debug_info->q_statedump_bin_info) { |
| 904 | /* State dump */ |
| 905 | handle_event_statedump_bin_info(debug_info, event); |
| 906 | } else if (q_event_name == debug_info->q_dl_open || |
| 907 | q_event_name == debug_info->q_lib_load) { |
| 908 | /* |
| 909 | * dl_open and lib_load events are both checked for since |
| 910 | * only dl_open was produced as of lttng-ust 2.8. |
| 911 | * |
| 912 | * lib_load, which is produced from lttng-ust 2.9+, is a lot |
| 913 | * more reliable since it will be emitted when other functions |
| 914 | * of the dlopen family are called (e.g. dlmopen) and when |
| 915 | * library are transitively loaded. |
| 916 | */ |
| 917 | handle_event_lib_load(debug_info, event); |
| 918 | } else if (q_event_name == debug_info->q_statedump_start) { |
| 919 | /* Start state dump */ |
| 920 | handle_event_statedump_start(debug_info, event); |
| 921 | } else if (q_event_name == debug_info->q_statedump_debug_link) { |
| 922 | /* Debug link info */ |
| 923 | handle_event_statedump_debug_link(debug_info, event); |
| 924 | } else if (q_event_name == debug_info->q_statedump_build_id) { |
| 925 | /* Build ID info */ |
| 926 | handle_event_statedump_build_id(debug_info, event); |
| 927 | } else if (q_event_name == debug_info-> q_lib_unload) { |
| 928 | handle_event_lib_unload(debug_info, event); |
| 929 | } |
| 930 | |
| 931 | return; |
| 932 | } |
| 933 | |
| 934 | static |
| 935 | void destroy_debug_info_comp(struct debug_info_component *debug_info) |
| 936 | { |
| 937 | if (!debug_info) { |
| 938 | return; |
| 939 | } |
| 940 | |
| 941 | g_free(debug_info->arg_debug_dir); |
| 942 | g_free(debug_info->arg_debug_info_field_name); |
| 943 | g_free(debug_info->arg_target_prefix); |
| 944 | g_free(debug_info); |
| 945 | } |
| 946 | |
| 947 | static |
| 948 | void fill_debug_info_bin_field(struct debug_info_source *dbg_info_src, |
| 949 | bool full_path, bt_field *curr_field, |
| 950 | bt_logging_level log_level, bt_self_component *self_comp) |
| 951 | { |
| 952 | bt_field_status status; |
| 953 | |
| 954 | BT_ASSERT(bt_field_get_class_type(curr_field) == |
| 955 | BT_FIELD_CLASS_TYPE_STRING); |
| 956 | |
| 957 | if (dbg_info_src) { |
| 958 | if (full_path) { |
| 959 | status = bt_field_string_set_value(curr_field, |
| 960 | dbg_info_src->bin_path); |
| 961 | } else { |
| 962 | status = bt_field_string_set_value(curr_field, |
| 963 | dbg_info_src->short_bin_path); |
| 964 | } |
| 965 | if (status != BT_FIELD_STATUS_OK) { |
| 966 | BT_COMP_LOGE("Cannot set path component of \"bin\" " |
| 967 | "curr_field field's value: str-fc-addr=%p", |
| 968 | curr_field); |
| 969 | } |
| 970 | |
| 971 | status = bt_field_string_append(curr_field, dbg_info_src->bin_loc); |
| 972 | if (status != BT_FIELD_STATUS_OK) { |
| 973 | BT_COMP_LOGE("Cannot set bin location component of \"bin\" " |
| 974 | "curr_field field's value: str-fc-addr=%p", |
| 975 | curr_field); |
| 976 | } |
| 977 | } else { |
| 978 | status = bt_field_string_set_value(curr_field, ""); |
| 979 | if (status != BT_FIELD_STATUS_OK) { |
| 980 | BT_COMP_LOGE("Cannot set \"bin\" curr_field field's value: " |
| 981 | "str-fc-addr=%p", curr_field); |
| 982 | } |
| 983 | } |
| 984 | } |
| 985 | |
| 986 | static |
| 987 | void fill_debug_info_func_field(struct debug_info_source *dbg_info_src, |
| 988 | bt_field *curr_field, bt_logging_level log_level, |
| 989 | bt_self_component *self_comp) |
| 990 | { |
| 991 | bt_field_status status; |
| 992 | |
| 993 | BT_ASSERT(bt_field_get_class_type(curr_field) == |
| 994 | BT_FIELD_CLASS_TYPE_STRING); |
| 995 | if (dbg_info_src && dbg_info_src->func) { |
| 996 | status = bt_field_string_set_value(curr_field, |
| 997 | dbg_info_src->func); |
| 998 | } else { |
| 999 | status = bt_field_string_set_value(curr_field, ""); |
| 1000 | } |
| 1001 | if (status != BT_FIELD_STATUS_OK) { |
| 1002 | BT_COMP_LOGE("Cannot set \"func\" curr_field field's value: " |
| 1003 | "str-fc-addr=%p", curr_field); |
| 1004 | } |
| 1005 | } |
| 1006 | |
| 1007 | static |
| 1008 | void fill_debug_info_src_field(struct debug_info_source *dbg_info_src, |
| 1009 | bool full_path, bt_field *curr_field, |
| 1010 | bt_logging_level log_level, |
| 1011 | bt_self_component *self_comp) |
| 1012 | { |
| 1013 | bt_field_status status; |
| 1014 | |
| 1015 | BT_ASSERT(bt_field_get_class_type(curr_field) == |
| 1016 | BT_FIELD_CLASS_TYPE_STRING); |
| 1017 | |
| 1018 | if (dbg_info_src && dbg_info_src->src_path) { |
| 1019 | if (full_path) { |
| 1020 | status = bt_field_string_set_value(curr_field, |
| 1021 | dbg_info_src->src_path); |
| 1022 | } else { |
| 1023 | status = bt_field_string_set_value(curr_field, |
| 1024 | dbg_info_src->short_src_path); |
| 1025 | } |
| 1026 | if (status != BT_FIELD_STATUS_OK) { |
| 1027 | BT_COMP_LOGE("Cannot set path component of \"src\" " |
| 1028 | "curr_field field's value: str-fc-addr=%p", |
| 1029 | curr_field); |
| 1030 | } |
| 1031 | |
| 1032 | status = bt_field_string_append(curr_field, ":"); |
| 1033 | if (status != BT_FIELD_STATUS_OK) { |
| 1034 | BT_COMP_LOGE("Cannot set colon component of \"src\" " |
| 1035 | "curr_field field's value: str-fc-addr=%p", |
| 1036 | curr_field); |
| 1037 | } |
| 1038 | |
| 1039 | status = bt_field_string_append(curr_field, dbg_info_src->line_no); |
| 1040 | if (status != BT_FIELD_STATUS_OK) { |
| 1041 | BT_COMP_LOGE("Cannot set line number component of \"src\" " |
| 1042 | "curr_field field's value: str-fc-addr=%p", |
| 1043 | curr_field); |
| 1044 | } |
| 1045 | } else { |
| 1046 | status = bt_field_string_set_value(curr_field, ""); |
| 1047 | if (status != BT_FIELD_STATUS_OK) { |
| 1048 | BT_COMP_LOGE("Cannot set \"src\" curr_field field's value: " |
| 1049 | "str-fc-addr=%p", curr_field); |
| 1050 | } |
| 1051 | } |
| 1052 | } |
| 1053 | |
| 1054 | static |
| 1055 | void fill_debug_info_field_empty(bt_field *debug_info_field, |
| 1056 | bt_logging_level log_level, bt_self_component *self_comp) |
| 1057 | { |
| 1058 | bt_field_status status; |
| 1059 | bt_field *bin_field, *func_field, *src_field; |
| 1060 | |
| 1061 | BT_ASSERT(bt_field_get_class_type(debug_info_field) == |
| 1062 | BT_FIELD_CLASS_TYPE_STRUCTURE); |
| 1063 | |
| 1064 | bin_field = bt_field_structure_borrow_member_field_by_name( |
| 1065 | debug_info_field, "bin"); |
| 1066 | func_field = bt_field_structure_borrow_member_field_by_name( |
| 1067 | debug_info_field, "func"); |
| 1068 | src_field = bt_field_structure_borrow_member_field_by_name( |
| 1069 | debug_info_field, "src"); |
| 1070 | |
| 1071 | BT_ASSERT(bt_field_get_class_type(bin_field) == |
| 1072 | BT_FIELD_CLASS_TYPE_STRING); |
| 1073 | BT_ASSERT(bt_field_get_class_type(func_field) == |
| 1074 | BT_FIELD_CLASS_TYPE_STRING); |
| 1075 | BT_ASSERT(bt_field_get_class_type(src_field) == |
| 1076 | BT_FIELD_CLASS_TYPE_STRING); |
| 1077 | |
| 1078 | status = bt_field_string_set_value(bin_field, ""); |
| 1079 | if (status != BT_FIELD_STATUS_OK) { |
| 1080 | BT_COMP_LOGE("Cannot set \"bin\" bin_field field's value: " |
| 1081 | "str-fc-addr=%p", bin_field); |
| 1082 | } |
| 1083 | |
| 1084 | status = bt_field_string_set_value(func_field, ""); |
| 1085 | if (status != BT_FIELD_STATUS_OK) { |
| 1086 | BT_COMP_LOGE("Cannot set \"func\" func_field field's value: " |
| 1087 | "str-fc-addr=%p", func_field); |
| 1088 | } |
| 1089 | |
| 1090 | status = bt_field_string_set_value(src_field, ""); |
| 1091 | if (status != BT_FIELD_STATUS_OK) { |
| 1092 | BT_COMP_LOGE("Cannot set \"src\" src_field field's value: " |
| 1093 | "str-fc-addr=%p", src_field); |
| 1094 | } |
| 1095 | } |
| 1096 | static |
| 1097 | void fill_debug_info_field(struct debug_info *debug_info, int64_t vpid, |
| 1098 | uint64_t ip, bt_field *debug_info_field) |
| 1099 | { |
| 1100 | struct debug_info_source *dbg_info_src; |
| 1101 | const bt_field_class *debug_info_fc; |
| 1102 | |
| 1103 | BT_ASSERT(bt_field_get_class_type(debug_info_field) == |
| 1104 | BT_FIELD_CLASS_TYPE_STRUCTURE); |
| 1105 | |
| 1106 | debug_info_fc = bt_field_borrow_class_const(debug_info_field); |
| 1107 | |
| 1108 | BT_ASSERT(bt_field_class_structure_get_member_count(debug_info_fc) == 3); |
| 1109 | |
| 1110 | dbg_info_src = debug_info_query(debug_info, vpid, ip); |
| 1111 | |
| 1112 | fill_debug_info_bin_field(dbg_info_src, |
| 1113 | debug_info->comp->arg_full_path, |
| 1114 | bt_field_structure_borrow_member_field_by_name( |
| 1115 | debug_info_field, "bin"), |
| 1116 | debug_info->log_level, debug_info->self_comp); |
| 1117 | fill_debug_info_func_field(dbg_info_src, |
| 1118 | bt_field_structure_borrow_member_field_by_name( |
| 1119 | debug_info_field, "func"), |
| 1120 | debug_info->log_level, debug_info->self_comp); |
| 1121 | fill_debug_info_src_field(dbg_info_src, |
| 1122 | debug_info->comp->arg_full_path, |
| 1123 | bt_field_structure_borrow_member_field_by_name( |
| 1124 | debug_info_field, "src"), |
| 1125 | debug_info->log_level, debug_info->self_comp); |
| 1126 | } |
| 1127 | |
| 1128 | static |
| 1129 | void fill_debug_info_event_if_needed(struct debug_info_msg_iter *debug_it, |
| 1130 | const bt_event *in_event, bt_event *out_event) |
| 1131 | { |
| 1132 | bt_field *out_common_ctx_field, *out_debug_info_field; |
| 1133 | const bt_field *vpid_field, *ip_field, *in_common_ctx_field; |
| 1134 | const bt_field_class *in_common_ctx_fc; |
| 1135 | struct debug_info *debug_info; |
| 1136 | uint64_t vpid; |
| 1137 | int64_t ip; |
| 1138 | gchar *debug_info_field_name = |
| 1139 | debug_it->debug_info_component->arg_debug_info_field_name; |
| 1140 | bt_logging_level log_level = debug_it->log_level; |
| 1141 | bt_self_component *self_comp = debug_it->self_comp; |
| 1142 | |
| 1143 | in_common_ctx_field = bt_event_borrow_common_context_field_const( |
| 1144 | in_event); |
| 1145 | if (!in_common_ctx_field) { |
| 1146 | /* |
| 1147 | * There is no event common context so no need to add debug |
| 1148 | * info field. |
| 1149 | */ |
| 1150 | goto end; |
| 1151 | } |
| 1152 | |
| 1153 | in_common_ctx_fc = bt_field_borrow_class_const(in_common_ctx_field); |
| 1154 | if (!is_event_common_ctx_dbg_info_compatible(in_common_ctx_fc, |
| 1155 | debug_it->ir_maps->debug_info_field_class_name)) { |
| 1156 | /* |
| 1157 | * The input event common context does not have the necessary |
| 1158 | * fields to resolve debug information. |
| 1159 | */ |
| 1160 | goto end; |
| 1161 | } |
| 1162 | |
| 1163 | /* Borrow the debug-info field. */ |
| 1164 | out_common_ctx_field = bt_event_borrow_common_context_field(out_event); |
| 1165 | if (!out_common_ctx_field) { |
| 1166 | goto end; |
| 1167 | } |
| 1168 | |
| 1169 | out_debug_info_field = bt_field_structure_borrow_member_field_by_name( |
| 1170 | out_common_ctx_field, debug_info_field_name); |
| 1171 | |
| 1172 | vpid_field = bt_field_structure_borrow_member_field_by_name_const( |
| 1173 | out_common_ctx_field, VPID_FIELD_NAME); |
| 1174 | ip_field = bt_field_structure_borrow_member_field_by_name_const( |
| 1175 | out_common_ctx_field, IP_FIELD_NAME); |
| 1176 | |
| 1177 | vpid = bt_field_signed_integer_get_value(vpid_field); |
| 1178 | ip = bt_field_unsigned_integer_get_value(ip_field); |
| 1179 | |
| 1180 | /* |
| 1181 | * Borrow the debug_info structure needed for the source |
| 1182 | * resolving. |
| 1183 | */ |
| 1184 | debug_info = g_hash_table_lookup(debug_it->debug_info_map, |
| 1185 | bt_stream_borrow_trace_const( |
| 1186 | bt_event_borrow_stream_const(in_event))); |
| 1187 | |
| 1188 | if (debug_info) { |
| 1189 | /* |
| 1190 | * Perform the debug-info resolving and set the event fields |
| 1191 | * accordingly. |
| 1192 | */ |
| 1193 | fill_debug_info_field(debug_info, vpid, ip, out_debug_info_field); |
| 1194 | } else { |
| 1195 | BT_COMP_LOGD("No debug information for this trace. Setting debug " |
| 1196 | "info fields to empty strings."); |
| 1197 | fill_debug_info_field_empty(out_debug_info_field, |
| 1198 | log_level, self_comp); |
| 1199 | } |
| 1200 | end: |
| 1201 | return; |
| 1202 | } |
| 1203 | |
| 1204 | static |
| 1205 | void update_event_statedump_if_needed(struct debug_info_msg_iter *debug_it, |
| 1206 | const bt_event *in_event) |
| 1207 | { |
| 1208 | const bt_field *event_common_ctx; |
| 1209 | const bt_field_class *event_common_ctx_fc; |
| 1210 | const bt_event_class *in_event_class = bt_event_borrow_class_const(in_event); |
| 1211 | |
| 1212 | /* |
| 1213 | * If the event is an lttng_ust_statedump event AND has the right event |
| 1214 | * common context fields update the debug-info view for this process. |
| 1215 | */ |
| 1216 | event_common_ctx = bt_event_borrow_common_context_field_const(in_event); |
| 1217 | if (!event_common_ctx) { |
| 1218 | goto end; |
| 1219 | } |
| 1220 | |
| 1221 | event_common_ctx_fc = bt_field_borrow_class_const(event_common_ctx); |
| 1222 | if (is_event_common_ctx_dbg_info_compatible(event_common_ctx_fc, |
| 1223 | debug_it->ir_maps->debug_info_field_class_name)) { |
| 1224 | /* Checkout if it might be a one of lttng ust statedump events. */ |
| 1225 | const char *in_event_name = bt_event_class_get_name(in_event_class); |
| 1226 | if (strncmp(in_event_name, LTTNG_UST_STATEDUMP_PREFIX, |
| 1227 | strlen(LTTNG_UST_STATEDUMP_PREFIX)) == 0) { |
| 1228 | /* Handle statedump events. */ |
| 1229 | handle_event_statedump(debug_it, in_event); |
| 1230 | } |
| 1231 | } |
| 1232 | end: |
| 1233 | return; |
| 1234 | } |
| 1235 | |
| 1236 | static |
| 1237 | bt_message *handle_event_message(struct debug_info_msg_iter *debug_it, |
| 1238 | const bt_message *in_message) |
| 1239 | { |
| 1240 | const bt_clock_snapshot *cs; |
| 1241 | const bt_clock_class *default_cc; |
| 1242 | const bt_packet *in_packet; |
| 1243 | bt_event_class *out_event_class; |
| 1244 | bt_packet *out_packet; |
| 1245 | bt_event *out_event; |
| 1246 | bt_logging_level log_level = debug_it->log_level; |
| 1247 | bt_self_component *self_comp = debug_it->self_comp; |
| 1248 | |
| 1249 | bt_message *out_message = NULL; |
| 1250 | |
| 1251 | /* Borrow the input event and its event class. */ |
| 1252 | const bt_event *in_event = |
| 1253 | bt_message_event_borrow_event_const(in_message); |
| 1254 | const bt_event_class *in_event_class = |
| 1255 | bt_event_borrow_class_const(in_event); |
| 1256 | |
| 1257 | update_event_statedump_if_needed(debug_it, in_event); |
| 1258 | |
| 1259 | out_event_class = trace_ir_mapping_borrow_mapped_event_class( |
| 1260 | debug_it->ir_maps, in_event_class); |
| 1261 | if (!out_event_class) { |
| 1262 | out_event_class = trace_ir_mapping_create_new_mapped_event_class( |
| 1263 | debug_it->ir_maps, in_event_class); |
| 1264 | } |
| 1265 | BT_ASSERT(out_event_class); |
| 1266 | |
| 1267 | /* Borrow the input and output packets. */ |
| 1268 | in_packet = bt_event_borrow_packet_const(in_event); |
| 1269 | out_packet = trace_ir_mapping_borrow_mapped_packet(debug_it->ir_maps, |
| 1270 | in_packet); |
| 1271 | |
| 1272 | default_cc = bt_stream_class_borrow_default_clock_class_const( |
| 1273 | bt_event_class_borrow_stream_class_const(in_event_class)); |
| 1274 | if (default_cc) { |
| 1275 | /* Borrow event clock snapshot. */ |
| 1276 | cs = bt_message_event_borrow_default_clock_snapshot_const( |
| 1277 | in_message); |
| 1278 | |
| 1279 | /* Create an output event message. */ |
| 1280 | out_message = bt_message_event_create_with_default_clock_snapshot( |
| 1281 | debug_it->input_iterator, |
| 1282 | out_event_class, out_packet, |
| 1283 | bt_clock_snapshot_get_value(cs)); |
| 1284 | } else { |
| 1285 | out_message = bt_message_event_create(debug_it->input_iterator, |
| 1286 | out_event_class, out_packet); |
| 1287 | } |
| 1288 | |
| 1289 | if (!out_message) { |
| 1290 | BT_COMP_LOGE("Error creating output event message."); |
| 1291 | goto error; |
| 1292 | } |
| 1293 | |
| 1294 | out_event = bt_message_event_borrow_event(out_message); |
| 1295 | |
| 1296 | /* Copy the original fields to the output event. */ |
| 1297 | copy_event_content(in_event, out_event, log_level, self_comp); |
| 1298 | |
| 1299 | /* |
| 1300 | * Try to set the debug-info fields based on debug information that is |
| 1301 | * gathered so far. |
| 1302 | */ |
| 1303 | fill_debug_info_event_if_needed(debug_it, in_event, out_event); |
| 1304 | |
| 1305 | error: |
| 1306 | return out_message; |
| 1307 | } |
| 1308 | |
| 1309 | static |
| 1310 | bt_message *handle_stream_begin_message(struct debug_info_msg_iter *debug_it, |
| 1311 | const bt_message *in_message) |
| 1312 | { |
| 1313 | const bt_stream *in_stream; |
| 1314 | bt_message *out_message; |
| 1315 | bt_stream *out_stream; |
| 1316 | bt_logging_level log_level = debug_it->log_level; |
| 1317 | bt_self_component *self_comp = debug_it->self_comp; |
| 1318 | |
| 1319 | in_stream = bt_message_stream_beginning_borrow_stream_const(in_message); |
| 1320 | BT_ASSERT(in_stream); |
| 1321 | |
| 1322 | /* Create a duplicated output stream. */ |
| 1323 | out_stream = trace_ir_mapping_create_new_mapped_stream( |
| 1324 | debug_it->ir_maps, in_stream); |
| 1325 | if (!out_stream) { |
| 1326 | out_message = NULL; |
| 1327 | goto error; |
| 1328 | } |
| 1329 | |
| 1330 | /* Create an output stream beginning message. */ |
| 1331 | out_message = bt_message_stream_beginning_create( |
| 1332 | debug_it->input_iterator, out_stream); |
| 1333 | if (!out_message) { |
| 1334 | BT_COMP_LOGE("Error creating output stream beginning message: " |
| 1335 | "out-s-addr=%p", out_stream); |
| 1336 | } |
| 1337 | error: |
| 1338 | return out_message; |
| 1339 | } |
| 1340 | |
| 1341 | static |
| 1342 | bt_message *handle_stream_end_message(struct debug_info_msg_iter *debug_it, |
| 1343 | const bt_message *in_message) |
| 1344 | { |
| 1345 | const bt_stream *in_stream; |
| 1346 | bt_message *out_message = NULL; |
| 1347 | bt_stream *out_stream; |
| 1348 | bt_logging_level log_level = debug_it->log_level; |
| 1349 | bt_self_component *self_comp = debug_it->self_comp; |
| 1350 | |
| 1351 | in_stream = bt_message_stream_end_borrow_stream_const(in_message); |
| 1352 | BT_ASSERT(in_stream); |
| 1353 | |
| 1354 | out_stream = trace_ir_mapping_borrow_mapped_stream( |
| 1355 | debug_it->ir_maps, in_stream); |
| 1356 | BT_ASSERT(out_stream); |
| 1357 | |
| 1358 | /* Create an output stream end message. */ |
| 1359 | out_message = bt_message_stream_end_create(debug_it->input_iterator, |
| 1360 | out_stream); |
| 1361 | if (!out_message) { |
| 1362 | BT_COMP_LOGE("Error creating output stream end message: out-s-addr=%p", |
| 1363 | out_stream); |
| 1364 | } |
| 1365 | |
| 1366 | /* Remove stream from trace mapping hashtable. */ |
| 1367 | trace_ir_mapping_remove_mapped_stream(debug_it->ir_maps, in_stream); |
| 1368 | |
| 1369 | return out_message; |
| 1370 | } |
| 1371 | |
| 1372 | static |
| 1373 | bt_message *handle_packet_begin_message(struct debug_info_msg_iter *debug_it, |
| 1374 | const bt_message *in_message) |
| 1375 | { |
| 1376 | bool has_default_clock_snapshot; |
| 1377 | const bt_clock_snapshot *cs; |
| 1378 | bt_message *out_message = NULL; |
| 1379 | bt_packet *out_packet; |
| 1380 | bt_logging_level log_level = debug_it->log_level; |
| 1381 | bt_self_component *self_comp = debug_it->self_comp; |
| 1382 | |
| 1383 | const bt_packet *in_packet = |
| 1384 | bt_message_packet_beginning_borrow_packet_const(in_message); |
| 1385 | BT_ASSERT(in_packet); |
| 1386 | |
| 1387 | /* This packet should not be already mapped. */ |
| 1388 | BT_ASSERT(!trace_ir_mapping_borrow_mapped_packet( |
| 1389 | debug_it->ir_maps, in_packet)); |
| 1390 | |
| 1391 | out_packet = trace_ir_mapping_create_new_mapped_packet(debug_it->ir_maps, |
| 1392 | in_packet); |
| 1393 | |
| 1394 | BT_ASSERT(out_packet); |
| 1395 | |
| 1396 | has_default_clock_snapshot = |
| 1397 | bt_stream_class_packets_have_beginning_default_clock_snapshot( |
| 1398 | bt_stream_borrow_class_const( |
| 1399 | bt_packet_borrow_stream_const(in_packet))); |
| 1400 | if (has_default_clock_snapshot) { |
| 1401 | /* Borrow clock snapshot. */ |
| 1402 | cs = bt_message_packet_beginning_borrow_default_clock_snapshot_const( |
| 1403 | in_message); |
| 1404 | |
| 1405 | /* Create an output packet beginning message. */ |
| 1406 | out_message = bt_message_packet_beginning_create_with_default_clock_snapshot( |
| 1407 | debug_it->input_iterator, out_packet, |
| 1408 | bt_clock_snapshot_get_value(cs)); |
| 1409 | } else { |
| 1410 | out_message = bt_message_packet_beginning_create( |
| 1411 | debug_it->input_iterator, out_packet); |
| 1412 | } |
| 1413 | if (!out_message) { |
| 1414 | BT_COMP_LOGE("Error creating output packet beginning message: " |
| 1415 | "out-p-addr=%p", out_packet); |
| 1416 | } |
| 1417 | |
| 1418 | return out_message; |
| 1419 | } |
| 1420 | |
| 1421 | static |
| 1422 | bt_message *handle_packet_end_message(struct debug_info_msg_iter *debug_it, |
| 1423 | const bt_message *in_message) |
| 1424 | { |
| 1425 | bool has_default_clock_snapshot; |
| 1426 | const bt_clock_snapshot *cs; |
| 1427 | const bt_packet *in_packet; |
| 1428 | bt_message *out_message = NULL; |
| 1429 | bt_packet *out_packet; |
| 1430 | bt_logging_level log_level = debug_it->log_level; |
| 1431 | bt_self_component *self_comp = debug_it->self_comp; |
| 1432 | |
| 1433 | in_packet = bt_message_packet_end_borrow_packet_const(in_message); |
| 1434 | BT_ASSERT(in_packet); |
| 1435 | |
| 1436 | out_packet = trace_ir_mapping_borrow_mapped_packet(debug_it->ir_maps, in_packet); |
| 1437 | BT_ASSERT(out_packet); |
| 1438 | |
| 1439 | has_default_clock_snapshot = |
| 1440 | bt_stream_class_packets_have_end_default_clock_snapshot( |
| 1441 | bt_stream_borrow_class_const( |
| 1442 | bt_packet_borrow_stream_const(in_packet))); |
| 1443 | if (has_default_clock_snapshot) { |
| 1444 | /* Borrow clock snapshot. */ |
| 1445 | cs = bt_message_packet_end_borrow_default_clock_snapshot_const( |
| 1446 | in_message); |
| 1447 | |
| 1448 | /* Create an outpute packet end message. */ |
| 1449 | out_message = bt_message_packet_end_create_with_default_clock_snapshot( |
| 1450 | debug_it->input_iterator, out_packet, |
| 1451 | bt_clock_snapshot_get_value(cs)); |
| 1452 | } else { |
| 1453 | out_message = bt_message_packet_end_create( |
| 1454 | debug_it->input_iterator, out_packet); |
| 1455 | } |
| 1456 | |
| 1457 | if (!out_message) { |
| 1458 | BT_COMP_LOGE("Error creating output packet end message: " |
| 1459 | "out-p-addr=%p", out_packet); |
| 1460 | } |
| 1461 | |
| 1462 | /* Remove packet from data mapping hashtable. */ |
| 1463 | trace_ir_mapping_remove_mapped_packet(debug_it->ir_maps, in_packet); |
| 1464 | |
| 1465 | return out_message; |
| 1466 | } |
| 1467 | |
| 1468 | static |
| 1469 | bt_message *handle_msg_iterator_inactivity(struct debug_info_msg_iter *debug_it, |
| 1470 | const bt_message *in_message) |
| 1471 | { |
| 1472 | /* |
| 1473 | * This message type can be forwarded directly because it does |
| 1474 | * not refer to any objects in the trace class. |
| 1475 | */ |
| 1476 | bt_message_get_ref(in_message); |
| 1477 | return (bt_message*) in_message; |
| 1478 | } |
| 1479 | |
| 1480 | static |
| 1481 | bt_message *handle_stream_act_begin_message(struct debug_info_msg_iter *debug_it, |
| 1482 | const bt_message *in_message) |
| 1483 | { |
| 1484 | const bt_clock_snapshot *cs; |
| 1485 | const bt_clock_class *default_cc; |
| 1486 | bt_message *out_message = NULL; |
| 1487 | bt_stream *out_stream; |
| 1488 | uint64_t cs_value; |
| 1489 | bt_message_stream_activity_clock_snapshot_state cs_state; |
| 1490 | bt_logging_level log_level = debug_it->log_level; |
| 1491 | bt_self_component *self_comp = debug_it->self_comp; |
| 1492 | |
| 1493 | const bt_stream *in_stream = |
| 1494 | bt_message_stream_activity_beginning_borrow_stream_const( |
| 1495 | in_message); |
| 1496 | BT_ASSERT(in_stream); |
| 1497 | |
| 1498 | out_stream = trace_ir_mapping_borrow_mapped_stream(debug_it->ir_maps, |
| 1499 | in_stream); |
| 1500 | BT_ASSERT(out_stream); |
| 1501 | |
| 1502 | out_message = bt_message_stream_activity_beginning_create( |
| 1503 | debug_it->input_iterator, out_stream); |
| 1504 | if (!out_message) { |
| 1505 | BT_COMP_LOGE("Error creating output stream activity beginning " |
| 1506 | "message: out-s-addr=%p", out_stream); |
| 1507 | goto error; |
| 1508 | } |
| 1509 | |
| 1510 | default_cc = bt_stream_class_borrow_default_clock_class_const( |
| 1511 | bt_stream_borrow_class_const(in_stream)); |
| 1512 | if (default_cc) { |
| 1513 | /* Borrow clock snapshot. */ |
| 1514 | cs_state = |
| 1515 | bt_message_stream_activity_beginning_borrow_default_clock_snapshot_const( |
| 1516 | in_message, &cs); |
| 1517 | |
| 1518 | if (cs_state == BT_MESSAGE_STREAM_ACTIVITY_CLOCK_SNAPSHOT_STATE_KNOWN) { |
| 1519 | cs_value = bt_clock_snapshot_get_value(cs); |
| 1520 | bt_message_stream_activity_beginning_set_default_clock_snapshot( |
| 1521 | out_message, cs_value); |
| 1522 | } else { |
| 1523 | bt_message_stream_activity_beginning_set_default_clock_snapshot_state( |
| 1524 | out_message, cs_state); |
| 1525 | } |
| 1526 | } |
| 1527 | |
| 1528 | error: |
| 1529 | return out_message; |
| 1530 | } |
| 1531 | |
| 1532 | static |
| 1533 | bt_message *handle_stream_act_end_message(struct debug_info_msg_iter *debug_it, |
| 1534 | const bt_message *in_message) |
| 1535 | { |
| 1536 | const bt_clock_snapshot *cs; |
| 1537 | const bt_clock_class *default_cc; |
| 1538 | const bt_stream *in_stream; |
| 1539 | bt_message *out_message; |
| 1540 | bt_stream *out_stream; |
| 1541 | uint64_t cs_value; |
| 1542 | bt_message_stream_activity_clock_snapshot_state cs_state; |
| 1543 | bt_logging_level log_level = debug_it->log_level; |
| 1544 | bt_self_component *self_comp = debug_it->self_comp; |
| 1545 | |
| 1546 | in_stream = bt_message_stream_activity_end_borrow_stream_const( |
| 1547 | in_message); |
| 1548 | BT_ASSERT(in_stream); |
| 1549 | |
| 1550 | out_stream = trace_ir_mapping_borrow_mapped_stream(debug_it->ir_maps, |
| 1551 | in_stream); |
| 1552 | BT_ASSERT(out_stream); |
| 1553 | |
| 1554 | out_message = bt_message_stream_activity_end_create( |
| 1555 | debug_it->input_iterator, out_stream); |
| 1556 | if (!out_message) { |
| 1557 | BT_COMP_LOGE("Error creating output stream activity end message: " |
| 1558 | "out-s-addr=%p", out_stream); |
| 1559 | goto error; |
| 1560 | } |
| 1561 | |
| 1562 | default_cc = bt_stream_class_borrow_default_clock_class_const( |
| 1563 | bt_stream_borrow_class_const(in_stream)); |
| 1564 | |
| 1565 | if (default_cc) { |
| 1566 | cs_state = |
| 1567 | bt_message_stream_activity_end_borrow_default_clock_snapshot_const( |
| 1568 | in_message, &cs); |
| 1569 | |
| 1570 | if (cs_state == BT_MESSAGE_STREAM_ACTIVITY_CLOCK_SNAPSHOT_STATE_KNOWN ) { |
| 1571 | cs_value = bt_clock_snapshot_get_value(cs); |
| 1572 | bt_message_stream_activity_end_set_default_clock_snapshot( |
| 1573 | out_message, cs_value); |
| 1574 | } else { |
| 1575 | bt_message_stream_activity_end_set_default_clock_snapshot_state( |
| 1576 | out_message, cs_state); |
| 1577 | } |
| 1578 | } |
| 1579 | |
| 1580 | error: |
| 1581 | return out_message; |
| 1582 | } |
| 1583 | |
| 1584 | static |
| 1585 | bt_message *handle_discarded_events_message(struct debug_info_msg_iter *debug_it, |
| 1586 | const bt_message *in_message) |
| 1587 | { |
| 1588 | const bt_clock_snapshot *begin_cs, *end_cs; |
| 1589 | const bt_stream *in_stream; |
| 1590 | bool has_default_clock_snapshots; |
| 1591 | uint64_t discarded_events, begin_cs_value, end_cs_value; |
| 1592 | bt_property_availability prop_avail; |
| 1593 | bt_message *out_message = NULL; |
| 1594 | bt_stream *out_stream; |
| 1595 | bt_logging_level log_level = debug_it->log_level; |
| 1596 | bt_self_component *self_comp = debug_it->self_comp; |
| 1597 | |
| 1598 | in_stream = bt_message_discarded_events_borrow_stream_const( |
| 1599 | in_message); |
| 1600 | BT_ASSERT(in_stream); |
| 1601 | |
| 1602 | out_stream = trace_ir_mapping_borrow_mapped_stream( |
| 1603 | debug_it->ir_maps, in_stream); |
| 1604 | BT_ASSERT(out_stream); |
| 1605 | |
| 1606 | has_default_clock_snapshots = |
| 1607 | bt_stream_class_discarded_events_have_default_clock_snapshots( |
| 1608 | bt_stream_borrow_class_const(in_stream)); |
| 1609 | if (has_default_clock_snapshots) { |
| 1610 | begin_cs = |
| 1611 | bt_message_discarded_events_borrow_beginning_default_clock_snapshot_const( |
| 1612 | in_message); |
| 1613 | end_cs = |
| 1614 | bt_message_discarded_events_borrow_end_default_clock_snapshot_const( |
| 1615 | in_message); |
| 1616 | |
| 1617 | begin_cs_value = bt_clock_snapshot_get_value(begin_cs); |
| 1618 | end_cs_value = bt_clock_snapshot_get_value(end_cs); |
| 1619 | |
| 1620 | out_message = |
| 1621 | bt_message_discarded_events_create_with_default_clock_snapshots( |
| 1622 | debug_it->input_iterator, out_stream, |
| 1623 | begin_cs_value, end_cs_value); |
| 1624 | } else { |
| 1625 | out_message = bt_message_discarded_events_create( |
| 1626 | debug_it->input_iterator, out_stream); |
| 1627 | } |
| 1628 | if (!out_message) { |
| 1629 | BT_COMP_LOGE("Error creating output discarded events message: " |
| 1630 | "out-s-addr=%p", out_stream); |
| 1631 | goto error; |
| 1632 | } |
| 1633 | |
| 1634 | prop_avail = bt_message_discarded_events_get_count(in_message, |
| 1635 | &discarded_events); |
| 1636 | |
| 1637 | if (prop_avail == BT_PROPERTY_AVAILABILITY_NOT_AVAILABLE) { |
| 1638 | bt_message_discarded_events_set_count(out_message, |
| 1639 | discarded_events); |
| 1640 | } |
| 1641 | |
| 1642 | error: |
| 1643 | return out_message; |
| 1644 | } |
| 1645 | |
| 1646 | static |
| 1647 | bt_message *handle_discarded_packets_message(struct debug_info_msg_iter *debug_it, |
| 1648 | const bt_message *in_message) |
| 1649 | { |
| 1650 | const bt_clock_snapshot *begin_cs, *end_cs; |
| 1651 | bool has_default_clock_snapshots; |
| 1652 | const bt_stream *in_stream; |
| 1653 | uint64_t discarded_packets, begin_cs_value, end_cs_value; |
| 1654 | bt_property_availability prop_avail; |
| 1655 | bt_message *out_message = NULL; |
| 1656 | bt_stream *out_stream; |
| 1657 | bt_logging_level log_level = debug_it->log_level; |
| 1658 | bt_self_component *self_comp = debug_it->self_comp; |
| 1659 | |
| 1660 | in_stream = bt_message_discarded_packets_borrow_stream_const( |
| 1661 | in_message); |
| 1662 | BT_ASSERT(in_stream); |
| 1663 | |
| 1664 | out_stream = trace_ir_mapping_borrow_mapped_stream( |
| 1665 | debug_it->ir_maps, in_stream); |
| 1666 | BT_ASSERT(out_stream); |
| 1667 | |
| 1668 | has_default_clock_snapshots = |
| 1669 | bt_stream_class_discarded_packets_have_default_clock_snapshots( |
| 1670 | bt_stream_borrow_class_const(in_stream)); |
| 1671 | if (has_default_clock_snapshots) { |
| 1672 | begin_cs = |
| 1673 | bt_message_discarded_packets_borrow_beginning_default_clock_snapshot_const( |
| 1674 | in_message); |
| 1675 | |
| 1676 | end_cs = |
| 1677 | bt_message_discarded_packets_borrow_end_default_clock_snapshot_const( |
| 1678 | in_message); |
| 1679 | |
| 1680 | begin_cs_value = bt_clock_snapshot_get_value(begin_cs); |
| 1681 | end_cs_value = bt_clock_snapshot_get_value(end_cs); |
| 1682 | |
| 1683 | out_message = bt_message_discarded_packets_create_with_default_clock_snapshots( |
| 1684 | debug_it->input_iterator, out_stream, |
| 1685 | begin_cs_value, end_cs_value); |
| 1686 | } else { |
| 1687 | out_message = bt_message_discarded_packets_create( |
| 1688 | debug_it->input_iterator, out_stream); |
| 1689 | } |
| 1690 | if (!out_message) { |
| 1691 | BT_COMP_LOGE("Error creating output discarded packet message: " |
| 1692 | "out-s-addr=%p", out_stream); |
| 1693 | goto error; |
| 1694 | } |
| 1695 | |
| 1696 | prop_avail = bt_message_discarded_packets_get_count(in_message, |
| 1697 | &discarded_packets); |
| 1698 | if (prop_avail == BT_PROPERTY_AVAILABILITY_NOT_AVAILABLE) { |
| 1699 | bt_message_discarded_packets_set_count(out_message, |
| 1700 | discarded_packets); |
| 1701 | } |
| 1702 | |
| 1703 | error: |
| 1704 | return out_message; |
| 1705 | } |
| 1706 | |
| 1707 | static |
| 1708 | const bt_message *handle_message(struct debug_info_msg_iter *debug_it, |
| 1709 | const bt_message *in_message) |
| 1710 | { |
| 1711 | bt_message *out_message = NULL; |
| 1712 | |
| 1713 | switch (bt_message_get_type(in_message)) { |
| 1714 | case BT_MESSAGE_TYPE_EVENT: |
| 1715 | out_message = handle_event_message(debug_it, |
| 1716 | in_message); |
| 1717 | break; |
| 1718 | case BT_MESSAGE_TYPE_PACKET_BEGINNING: |
| 1719 | out_message = handle_packet_begin_message(debug_it, |
| 1720 | in_message); |
| 1721 | break; |
| 1722 | case BT_MESSAGE_TYPE_PACKET_END: |
| 1723 | out_message = handle_packet_end_message(debug_it, |
| 1724 | in_message); |
| 1725 | break; |
| 1726 | case BT_MESSAGE_TYPE_STREAM_BEGINNING: |
| 1727 | out_message = handle_stream_begin_message(debug_it, |
| 1728 | in_message); |
| 1729 | break; |
| 1730 | case BT_MESSAGE_TYPE_STREAM_END: |
| 1731 | out_message = handle_stream_end_message(debug_it, |
| 1732 | in_message); |
| 1733 | break; |
| 1734 | case BT_MESSAGE_TYPE_MESSAGE_ITERATOR_INACTIVITY: |
| 1735 | out_message = handle_msg_iterator_inactivity(debug_it, |
| 1736 | in_message); |
| 1737 | break; |
| 1738 | case BT_MESSAGE_TYPE_STREAM_ACTIVITY_BEGINNING: |
| 1739 | out_message = handle_stream_act_begin_message(debug_it, |
| 1740 | in_message); |
| 1741 | break; |
| 1742 | case BT_MESSAGE_TYPE_STREAM_ACTIVITY_END: |
| 1743 | out_message = handle_stream_act_end_message(debug_it, |
| 1744 | in_message); |
| 1745 | break; |
| 1746 | case BT_MESSAGE_TYPE_DISCARDED_EVENTS: |
| 1747 | out_message = handle_discarded_events_message(debug_it, |
| 1748 | in_message); |
| 1749 | break; |
| 1750 | case BT_MESSAGE_TYPE_DISCARDED_PACKETS: |
| 1751 | out_message = handle_discarded_packets_message(debug_it, |
| 1752 | in_message); |
| 1753 | break; |
| 1754 | default: |
| 1755 | abort(); |
| 1756 | break; |
| 1757 | } |
| 1758 | |
| 1759 | return out_message; |
| 1760 | } |
| 1761 | |
| 1762 | static |
| 1763 | int init_from_params(struct debug_info_component *debug_info_component, |
| 1764 | const bt_value *params) |
| 1765 | { |
| 1766 | const bt_value *value = NULL; |
| 1767 | int ret = 0; |
| 1768 | |
| 1769 | BT_ASSERT(params); |
| 1770 | |
| 1771 | value = bt_value_map_borrow_entry_value_const(params, |
| 1772 | "debug-info-field-name"); |
| 1773 | if (value) { |
| 1774 | debug_info_component->arg_debug_info_field_name = |
| 1775 | g_strdup(bt_value_string_get(value)); |
| 1776 | } else { |
| 1777 | debug_info_component->arg_debug_info_field_name = |
| 1778 | g_strdup(DEFAULT_DEBUG_INFO_FIELD_NAME); |
| 1779 | } |
| 1780 | |
| 1781 | value = bt_value_map_borrow_entry_value_const(params, "debug-info-dir"); |
| 1782 | if (value) { |
| 1783 | debug_info_component->arg_debug_dir = |
| 1784 | g_strdup(bt_value_string_get(value)); |
| 1785 | } else { |
| 1786 | debug_info_component->arg_debug_dir = NULL; |
| 1787 | } |
| 1788 | |
| 1789 | |
| 1790 | value = bt_value_map_borrow_entry_value_const(params, "target-prefix"); |
| 1791 | if (value) { |
| 1792 | debug_info_component->arg_target_prefix = |
| 1793 | g_strdup(bt_value_string_get(value)); |
| 1794 | } else { |
| 1795 | debug_info_component->arg_target_prefix = NULL; |
| 1796 | } |
| 1797 | |
| 1798 | value = bt_value_map_borrow_entry_value_const(params, "full-path"); |
| 1799 | if (value) { |
| 1800 | debug_info_component->arg_full_path = bt_value_bool_get(value); |
| 1801 | } else { |
| 1802 | debug_info_component->arg_full_path = BT_FALSE; |
| 1803 | } |
| 1804 | |
| 1805 | return ret; |
| 1806 | } |
| 1807 | |
| 1808 | BT_HIDDEN |
| 1809 | bt_self_component_status debug_info_comp_init( |
| 1810 | bt_self_component_filter *self_comp_flt, |
| 1811 | const bt_value *params, __attribute__((unused)) void *init_method_data) |
| 1812 | { |
| 1813 | int ret; |
| 1814 | struct debug_info_component *debug_info_comp; |
| 1815 | bt_self_component_status status = BT_SELF_COMPONENT_STATUS_OK; |
| 1816 | bt_self_component *self_comp = |
| 1817 | bt_self_component_filter_as_self_component(self_comp_flt); |
| 1818 | bt_logging_level log_level = bt_component_get_logging_level( |
| 1819 | bt_self_component_as_component(self_comp)); |
| 1820 | |
| 1821 | |
| 1822 | BT_COMP_LOGI("Initializing debug_info component: " |
| 1823 | "comp-addr=%p, params-addr=%p", self_comp, params); |
| 1824 | |
| 1825 | debug_info_comp = g_new0(struct debug_info_component, 1); |
| 1826 | if (!debug_info_comp) { |
| 1827 | BT_COMP_LOGE_STR("Failed to allocate one debug_info component."); |
| 1828 | goto error; |
| 1829 | } |
| 1830 | |
| 1831 | debug_info_comp->log_level = log_level; |
| 1832 | debug_info_comp->self_comp = self_comp; |
| 1833 | bt_self_component_set_data(self_comp, debug_info_comp); |
| 1834 | |
| 1835 | status = bt_self_component_filter_add_input_port(self_comp_flt, "in", |
| 1836 | NULL, NULL); |
| 1837 | if (status != BT_SELF_COMPONENT_STATUS_OK) { |
| 1838 | goto error; |
| 1839 | } |
| 1840 | |
| 1841 | status = bt_self_component_filter_add_output_port(self_comp_flt, "out", |
| 1842 | NULL, NULL); |
| 1843 | if (status != BT_SELF_COMPONENT_STATUS_OK) { |
| 1844 | goto error; |
| 1845 | } |
| 1846 | |
| 1847 | ret = init_from_params(debug_info_comp, params); |
| 1848 | if (ret) { |
| 1849 | BT_COMP_LOGE("Cannot configure debug_info component: " |
| 1850 | "debug_info-comp-addr=%p, params-addr=%p", |
| 1851 | debug_info_comp, params); |
| 1852 | goto error; |
| 1853 | } |
| 1854 | |
| 1855 | goto end; |
| 1856 | |
| 1857 | error: |
| 1858 | destroy_debug_info_comp(debug_info_comp); |
| 1859 | bt_self_component_set_data(self_comp, NULL); |
| 1860 | |
| 1861 | if (status == BT_SELF_COMPONENT_STATUS_OK) { |
| 1862 | status = BT_SELF_COMPONENT_STATUS_ERROR; |
| 1863 | } |
| 1864 | end: |
| 1865 | return status; |
| 1866 | } |
| 1867 | |
| 1868 | BT_HIDDEN |
| 1869 | void debug_info_comp_finalize(bt_self_component_filter *self_comp_flt) |
| 1870 | { |
| 1871 | struct debug_info_component *debug_info = |
| 1872 | bt_self_component_get_data( |
| 1873 | bt_self_component_filter_as_self_component( |
| 1874 | self_comp_flt)); |
| 1875 | bt_logging_level log_level = debug_info->log_level; |
| 1876 | bt_self_component *self_comp = debug_info->self_comp; |
| 1877 | |
| 1878 | BT_COMP_LOGI("Finalizing debug_info self_component: comp-addr=%p", |
| 1879 | self_comp); |
| 1880 | |
| 1881 | destroy_debug_info_comp(debug_info); |
| 1882 | } |
| 1883 | |
| 1884 | BT_HIDDEN |
| 1885 | bt_self_message_iterator_status debug_info_msg_iter_next( |
| 1886 | bt_self_message_iterator *self_msg_iter, |
| 1887 | const bt_message_array_const msgs, uint64_t capacity, |
| 1888 | uint64_t *count) |
| 1889 | { |
| 1890 | bt_self_component_port_input_message_iterator *upstream_iterator = NULL; |
| 1891 | bt_message_iterator_status upstream_iterator_ret_status; |
| 1892 | struct debug_info_msg_iter *debug_info_msg_iter; |
| 1893 | struct debug_info_component *debug_info = NULL; |
| 1894 | bt_self_message_iterator_status status; |
| 1895 | bt_self_component *self_comp = NULL; |
| 1896 | bt_message_array_const input_msgs; |
| 1897 | const bt_message *out_message; |
| 1898 | uint64_t curr_msg_idx, i; |
| 1899 | |
| 1900 | status = BT_SELF_MESSAGE_ITERATOR_STATUS_OK; |
| 1901 | |
| 1902 | self_comp = bt_self_message_iterator_borrow_component(self_msg_iter); |
| 1903 | BT_ASSERT(self_comp); |
| 1904 | |
| 1905 | debug_info = bt_self_component_get_data(self_comp); |
| 1906 | BT_ASSERT(debug_info); |
| 1907 | |
| 1908 | debug_info_msg_iter = bt_self_message_iterator_get_data(self_msg_iter); |
| 1909 | BT_ASSERT(debug_info_msg_iter); |
| 1910 | |
| 1911 | upstream_iterator = debug_info_msg_iter->msg_iter; |
| 1912 | BT_ASSERT(upstream_iterator); |
| 1913 | |
| 1914 | upstream_iterator_ret_status = |
| 1915 | bt_self_component_port_input_message_iterator_next( |
| 1916 | upstream_iterator, &input_msgs, count); |
| 1917 | if (upstream_iterator_ret_status != BT_MESSAGE_ITERATOR_STATUS_OK) { |
| 1918 | /* |
| 1919 | * No messages were returned. Not necessarily an error. Convert |
| 1920 | * the upstream message iterator status to a self status. |
| 1921 | */ |
| 1922 | status = bt_common_message_iterator_status_to_self( |
| 1923 | upstream_iterator_ret_status); |
| 1924 | goto end; |
| 1925 | } |
| 1926 | |
| 1927 | /* |
| 1928 | * There should never be more received messages than the capacity we |
| 1929 | * provided. |
| 1930 | */ |
| 1931 | BT_ASSERT(*count <= capacity); |
| 1932 | |
| 1933 | for (curr_msg_idx = 0; curr_msg_idx < *count; curr_msg_idx++) { |
| 1934 | out_message = handle_message(debug_info_msg_iter, |
| 1935 | input_msgs[curr_msg_idx]); |
| 1936 | if (!out_message) { |
| 1937 | goto handle_msg_error; |
| 1938 | } |
| 1939 | |
| 1940 | msgs[curr_msg_idx] = out_message; |
| 1941 | /* |
| 1942 | * Drop our reference of the input message as we are done with |
| 1943 | * it and created a output copy. |
| 1944 | */ |
| 1945 | bt_message_put_ref(input_msgs[curr_msg_idx]); |
| 1946 | } |
| 1947 | |
| 1948 | goto end; |
| 1949 | |
| 1950 | handle_msg_error: |
| 1951 | /* |
| 1952 | * Drop references of all the output messages created before the |
| 1953 | * failure. |
| 1954 | */ |
| 1955 | for (i = 0; i < curr_msg_idx; i++) { |
| 1956 | bt_message_put_ref(msgs[i]); |
| 1957 | } |
| 1958 | |
| 1959 | status = BT_SELF_MESSAGE_ITERATOR_STATUS_NOMEM; |
| 1960 | end: |
| 1961 | return status; |
| 1962 | } |
| 1963 | |
| 1964 | static |
| 1965 | void debug_info_msg_iter_destroy(struct debug_info_msg_iter *debug_info_msg_iter) |
| 1966 | { |
| 1967 | if (!debug_info_msg_iter) { |
| 1968 | goto end; |
| 1969 | } |
| 1970 | |
| 1971 | if (debug_info_msg_iter->msg_iter) { |
| 1972 | bt_self_component_port_input_message_iterator_put_ref( |
| 1973 | debug_info_msg_iter->msg_iter); |
| 1974 | } |
| 1975 | |
| 1976 | if (debug_info_msg_iter->ir_maps) { |
| 1977 | trace_ir_maps_destroy(debug_info_msg_iter->ir_maps); |
| 1978 | } |
| 1979 | |
| 1980 | if (debug_info_msg_iter->debug_info_map) { |
| 1981 | g_hash_table_destroy(debug_info_msg_iter->debug_info_map); |
| 1982 | } |
| 1983 | |
| 1984 | bt_fd_cache_fini(&debug_info_msg_iter->fd_cache); |
| 1985 | g_free(debug_info_msg_iter); |
| 1986 | |
| 1987 | end: |
| 1988 | return; |
| 1989 | } |
| 1990 | |
| 1991 | BT_HIDDEN |
| 1992 | bt_self_message_iterator_status debug_info_msg_iter_init( |
| 1993 | bt_self_message_iterator *self_msg_iter, |
| 1994 | bt_self_component_filter *self_comp_flt, |
| 1995 | bt_self_component_port_output *self_port) |
| 1996 | { |
| 1997 | bt_self_message_iterator_status status = BT_SELF_MESSAGE_ITERATOR_STATUS_OK; |
| 1998 | struct bt_self_component_port_input *input_port = NULL; |
| 1999 | bt_self_component_port_input_message_iterator *upstream_iterator = NULL; |
| 2000 | struct debug_info_msg_iter *debug_info_msg_iter = NULL; |
| 2001 | gchar *debug_info_field_name; |
| 2002 | int ret; |
| 2003 | bt_self_component *self_comp = |
| 2004 | bt_self_component_filter_as_self_component(self_comp_flt); |
| 2005 | bt_logging_level log_level = bt_component_get_logging_level( |
| 2006 | bt_self_component_as_component(self_comp)); |
| 2007 | |
| 2008 | /* Borrow the upstream input port. */ |
| 2009 | input_port = bt_self_component_filter_borrow_input_port_by_name( |
| 2010 | self_comp_flt, "in"); |
| 2011 | if (!input_port) { |
| 2012 | status = BT_SELF_MESSAGE_ITERATOR_STATUS_ERROR; |
| 2013 | goto error; |
| 2014 | } |
| 2015 | |
| 2016 | debug_info_msg_iter = g_new0(struct debug_info_msg_iter, 1); |
| 2017 | if (!debug_info_msg_iter) { |
| 2018 | status = BT_SELF_MESSAGE_ITERATOR_STATUS_NOMEM; |
| 2019 | goto error; |
| 2020 | } |
| 2021 | |
| 2022 | debug_info_msg_iter->log_level = log_level; |
| 2023 | debug_info_msg_iter->self_comp = self_comp; |
| 2024 | |
| 2025 | /* Create an iterator on the upstream component. */ |
| 2026 | upstream_iterator = bt_self_component_port_input_message_iterator_create( |
| 2027 | input_port); |
| 2028 | if (!upstream_iterator) { |
| 2029 | status = BT_SELF_MESSAGE_ITERATOR_STATUS_NOMEM; |
| 2030 | goto error; |
| 2031 | } |
| 2032 | |
| 2033 | BT_SELF_COMPONENT_PORT_INPUT_MESSAGE_ITERATOR_MOVE_REF( |
| 2034 | debug_info_msg_iter->msg_iter, upstream_iterator); |
| 2035 | |
| 2036 | /* Create hashtable that will contain debug info mapping. */ |
| 2037 | debug_info_msg_iter->debug_info_map = g_hash_table_new_full( |
| 2038 | g_direct_hash, g_direct_equal, (GDestroyNotify) NULL, |
| 2039 | (GDestroyNotify) debug_info_destroy); |
| 2040 | if (!debug_info_msg_iter->debug_info_map) { |
| 2041 | status = BT_SELF_MESSAGE_ITERATOR_STATUS_NOMEM; |
| 2042 | goto error; |
| 2043 | } |
| 2044 | |
| 2045 | debug_info_msg_iter->debug_info_component = |
| 2046 | bt_self_component_get_data(self_comp); |
| 2047 | |
| 2048 | debug_info_field_name = |
| 2049 | debug_info_msg_iter->debug_info_component->arg_debug_info_field_name; |
| 2050 | |
| 2051 | debug_info_msg_iter->ir_maps = trace_ir_maps_create(self_comp, |
| 2052 | debug_info_field_name, log_level); |
| 2053 | if (!debug_info_msg_iter->ir_maps) { |
| 2054 | status = BT_SELF_MESSAGE_ITERATOR_STATUS_NOMEM; |
| 2055 | goto error; |
| 2056 | } |
| 2057 | |
| 2058 | ret = bt_fd_cache_init(&debug_info_msg_iter->fd_cache, log_level); |
| 2059 | if (ret) { |
| 2060 | status = BT_SELF_MESSAGE_ITERATOR_STATUS_NOMEM; |
| 2061 | goto error; |
| 2062 | } |
| 2063 | |
| 2064 | bt_self_message_iterator_set_data(self_msg_iter, debug_info_msg_iter); |
| 2065 | debug_info_msg_iter->input_iterator = self_msg_iter; |
| 2066 | |
| 2067 | goto end; |
| 2068 | |
| 2069 | error: |
| 2070 | debug_info_msg_iter_destroy(debug_info_msg_iter); |
| 2071 | end: |
| 2072 | return status; |
| 2073 | } |
| 2074 | |
| 2075 | BT_HIDDEN |
| 2076 | bt_bool debug_info_msg_iter_can_seek_beginning( |
| 2077 | bt_self_message_iterator *self_msg_iter) |
| 2078 | { |
| 2079 | struct debug_info_msg_iter *debug_info_msg_iter = |
| 2080 | bt_self_message_iterator_get_data(self_msg_iter); |
| 2081 | BT_ASSERT(debug_info_msg_iter); |
| 2082 | |
| 2083 | return bt_self_component_port_input_message_iterator_can_seek_beginning( |
| 2084 | debug_info_msg_iter->msg_iter); |
| 2085 | } |
| 2086 | |
| 2087 | BT_HIDDEN |
| 2088 | bt_self_message_iterator_status debug_info_msg_iter_seek_beginning( |
| 2089 | bt_self_message_iterator *self_msg_iter) |
| 2090 | { |
| 2091 | struct debug_info_msg_iter *debug_info_msg_iter = |
| 2092 | bt_self_message_iterator_get_data(self_msg_iter); |
| 2093 | bt_message_iterator_status status = BT_MESSAGE_ITERATOR_STATUS_OK; |
| 2094 | |
| 2095 | BT_ASSERT(debug_info_msg_iter); |
| 2096 | |
| 2097 | /* Ask the upstream component to seek to the beginning. */ |
| 2098 | status = bt_self_component_port_input_message_iterator_seek_beginning( |
| 2099 | debug_info_msg_iter->msg_iter); |
| 2100 | if (status != BT_MESSAGE_ITERATOR_STATUS_OK) { |
| 2101 | goto end; |
| 2102 | } |
| 2103 | |
| 2104 | /* Clear this iterator data. */ |
| 2105 | trace_ir_maps_clear(debug_info_msg_iter->ir_maps); |
| 2106 | g_hash_table_remove_all(debug_info_msg_iter->debug_info_map); |
| 2107 | end: |
| 2108 | return bt_common_message_iterator_status_to_self(status); |
| 2109 | } |
| 2110 | |
| 2111 | BT_HIDDEN |
| 2112 | void debug_info_msg_iter_finalize(bt_self_message_iterator *it) |
| 2113 | { |
| 2114 | struct debug_info_msg_iter *debug_info_msg_iter; |
| 2115 | |
| 2116 | debug_info_msg_iter = bt_self_message_iterator_get_data(it); |
| 2117 | BT_ASSERT(debug_info_msg_iter); |
| 2118 | |
| 2119 | debug_info_msg_iter_destroy(debug_info_msg_iter); |
| 2120 | } |