X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=plugins%2Flttng-utils%2Fdebug-info.c;h=a455e47ce39978a1028af2e78070b7144ab6ddc8;hb=65300d60e4b4f167e5fc8f584677757ce09a3844;hp=2ac4002f910e998997efea8f2ef41fa71a2a3385;hpb=65db8b88c5e445815d7e76f27b987c3b0b533374;p=babeltrace.git diff --git a/plugins/lttng-utils/debug-info.c b/plugins/lttng-utils/debug-info.c index 2ac4002f..a455e47c 100644 --- a/plugins/lttng-utils/debug-info.c +++ b/plugins/lttng-utils/debug-info.c @@ -25,7 +25,10 @@ * SOFTWARE. */ -#include +#define BT_LOG_TAG "PLUGIN-CTF-LTTNG-UTILS-DEBUG-INFO-FLT" +#include "logging.h" + +#include #include #include "debug-info.h" #include "bin-info.h" @@ -119,7 +122,7 @@ struct debug_info_source *debug_info_source_create_from_bin(struct bin_info *bin if (!bin->is_elf_only || !debug_info_src->func) { /* Lookup source location */ ret = bin_info_lookup_source_location(bin, ip, &src_loc); - printf_verbose("Failed to lookup source location (err: %i)\n", ret); + BT_LOGD("Failed to lookup source location: ret=%d", ret); } if (src_loc) { @@ -370,25 +373,26 @@ end: static void handle_statedump_build_id_event(FILE *err, struct debug_info *debug_info, - struct bt_ctf_event *event) + struct bt_event *event) { struct proc_debug_info_sources *proc_dbg_info_src; struct bin_info *bin = NULL; int ret; int64_t vpid; uint64_t baddr; + uint64_t build_id_len; ret = get_stream_event_context_int_field_value(err, - event, "_vpid", &vpid); + event, VPID_FIELD_NAME, &vpid); if (ret) { goto end; } ret = get_payload_unsigned_int_field_value(err, - event, "_baddr", &baddr); + event, BADDR_FIELD_NAME, &baddr); if (ret) { - fprintf(err, "[error] %s in %s:%d\n", __func__, - __FILE__, __LINE__); + BT_LOGE_STR("Failed to get unsigned int value for " + VPID_FIELD_NAME " field."); goto end; } @@ -408,13 +412,16 @@ void handle_statedump_build_id_event(FILE *err, struct debug_info *debug_info, goto end; } - ret = get_payload_build_id_field_value(err, event, "_build_id", - &bin->build_id, &bin->build_id_len); + ret = get_payload_build_id_field_value(err, event, BUILD_ID_FIELD_NAME, + &bin->build_id, &build_id_len); if (ret) { - fprintf(err, "[error] %s in %s:%d\n", __func__, - __FILE__, __LINE__); + BT_LOGE_STR("Failed to get " BUILD_ID_FIELD_NAME + " field value."); goto end; } + if (build_id_len > SIZE_MAX) { + bin->build_id_len = (size_t) build_id_len; + } /* * Reset the is_elf_only flag in case it had been set @@ -432,7 +439,7 @@ end: static void handle_statedump_debug_link_event(FILE *err, struct debug_info *debug_info, - struct bt_ctf_event *event) + struct bt_event *event) { struct proc_debug_info_sources *proc_dbg_info_src; struct bin_info *bin = NULL; @@ -444,34 +451,35 @@ void handle_statedump_debug_link_event(FILE *err, struct debug_info *debug_info, int ret; ret = get_stream_event_context_int_field_value(err, event, - "_vpid", &vpid); + VPID_FIELD_NAME, &vpid); if (ret) { goto end; } ret = get_payload_unsigned_int_field_value(err, - event, "_baddr", &baddr); + event, BADDR_FIELD_NAME, &baddr); if (ret) { - fprintf(err, "[error] %s in %s:%d\n", __func__, - __FILE__, __LINE__); + BT_LOGE_STR("Failed to get unsigned int value for " + BADDR_FIELD_NAME " field."); ret = -1; goto end; } - ret = get_payload_unsigned_int_field_value(err, event, "_crc32", &tmp); + ret = get_payload_unsigned_int_field_value(err, event, CRC32_FIELD_NAME, + &tmp); if (ret) { - fprintf(err, "[error] %s in %s:%d\n", __func__, - __FILE__, __LINE__); + BT_LOGE_STR("Failed to get unsigned int value for " + CRC32_FIELD_NAME " field."); ret = -1; goto end; } crc32 = (uint32_t) tmp; ret = get_payload_string_field_value(err, - event, "_filename", &filename); + event, FILENAME_FIELD_NAME, &filename); if (ret) { - fprintf(err, "[error] %s in %s:%d\n", __func__, - __FILE__, __LINE__); + BT_LOGE_STR("Failed to get string value for " + FILENAME_FIELD_NAME " field."); ret = -1; goto end; } @@ -500,7 +508,7 @@ end: static void handle_bin_info_event(FILE *err, struct debug_info *debug_info, - struct bt_ctf_event *event, bool has_pic_field) + struct bt_event *event, bool has_pic_field) { struct proc_debug_info_sources *proc_dbg_info_src; struct bin_info *bin; @@ -512,18 +520,18 @@ void handle_bin_info_event(FILE *err, struct debug_info *debug_info, int ret; ret = get_payload_unsigned_int_field_value(err, - event, "_baddr", &baddr); + event, BADDR_FIELD_NAME, &baddr); if (ret) { - fprintf(err, "[error] %s in %s:%d\n", __func__, - __FILE__, __LINE__); + BT_LOGE_STR("Failed to get unsigned int value for " + BADDR_FIELD_NAME " field."); goto end; } ret = get_payload_unsigned_int_field_value(err, - event, "_memsz", &memsz); + event, MEMSZ_FIELD_NAME, &memsz); if (ret) { - fprintf(err, "[error] %s in %s:%d\n", __func__, - __FILE__, __LINE__); + BT_LOGE_STR("Failed to get unsigned int value for " + MEMSZ_FIELD_NAME " field."); goto end; } @@ -532,7 +540,7 @@ void handle_bin_info_event(FILE *err, struct debug_info *debug_info, * lttng-ust 2.9. */ ret = get_payload_string_field_value(err, - event, "_path", &path); + event, PATH_FIELD_NAME, &path); if (ret || !path) { goto end; } @@ -541,10 +549,10 @@ void handle_bin_info_event(FILE *err, struct debug_info *debug_info, uint64_t tmp; ret = get_payload_unsigned_int_field_value(err, - event, "_is_pic", &tmp); + event, IS_PIC_FIELD_NAME, &tmp); if (ret) { - fprintf(err, "[error] %s in %s:%d\n", __func__, - __FILE__, __LINE__); + BT_LOGE_STR("Failed to get unsigned int value for " + IS_PIC_FIELD_NAME " field."); ret = -1; goto end; } @@ -557,8 +565,8 @@ void handle_bin_info_event(FILE *err, struct debug_info *debug_info, is_pic = true; } - ret = get_stream_event_context_int_field_value(err, event, "_vpid", - &vpid); + ret = get_stream_event_context_int_field_value(err, event, + VPID_FIELD_NAME, &vpid); if (ret) { goto end; } @@ -606,21 +614,21 @@ end: static inline void handle_statedump_bin_info_event(FILE *err, struct debug_info *debug_info, - struct bt_ctf_event *event) + struct bt_event *event) { handle_bin_info_event(err, debug_info, event, true); } static inline void handle_lib_load_event(FILE *err, struct debug_info *debug_info, - struct bt_ctf_event *event) + struct bt_event *event) { handle_bin_info_event(err, debug_info, event, false); } static inline void handle_lib_unload_event(FILE *err, struct debug_info *debug_info, - struct bt_ctf_event *event) + struct bt_event *event) { struct proc_debug_info_sources *proc_dbg_info_src; uint64_t baddr; @@ -629,16 +637,16 @@ void handle_lib_unload_event(FILE *err, struct debug_info *debug_info, int ret; ret = get_payload_unsigned_int_field_value(err, - event, "_baddr", &baddr); + event, BADDR_FIELD_NAME, &baddr); if (ret) { - fprintf(err, "[error] %s in %s:%d\n", __func__, - __FILE__, __LINE__); + BT_LOGE_STR("Failed to get unsigned int value for " + BADDR_FIELD_NAME " field."); ret = -1; goto end; } - ret = get_stream_event_context_int_field_value(err, event, "_vpid", - &vpid); + ret = get_stream_event_context_int_field_value(err, event, + VPID_FIELD_NAME, &vpid); if (ret) { goto end; } @@ -658,14 +666,14 @@ end: static void handle_statedump_start(FILE *err, struct debug_info *debug_info, - struct bt_ctf_event *event) + struct bt_event *event) { struct proc_debug_info_sources *proc_dbg_info_src; int64_t vpid; int ret; ret = get_stream_event_context_int_field_value(err, event, - "_vpid", &vpid); + VPID_FIELD_NAME, &vpid); if (ret) { goto end; } @@ -684,21 +692,21 @@ end: } BT_HIDDEN -void debug_info_handle_event(FILE *err, struct bt_ctf_event *event, +void debug_info_handle_event(FILE *err, struct bt_event *event, struct debug_info *debug_info) { - struct bt_ctf_event_class *event_class; + struct bt_event_class *event_class; const char *event_name; GQuark q_event_name; if (!debug_info || !event) { goto end; } - event_class = bt_ctf_event_get_class(event); + event_class = bt_event_get_class(event); if (!event_class) { goto end; } - event_name = bt_ctf_event_class_get_name(event_class); + event_name = bt_event_class_get_name(event_class); if (!event_name) { goto end_put_class; } @@ -733,7 +741,7 @@ void debug_info_handle_event(FILE *err, struct bt_ctf_event *event, } end_put_class: - bt_put(event_class); + bt_object_put_ref(event_class); end: return; }