flt.lttng-utils.debug-info: use BT_COMP_LOG*() instead of BT_LOG*()
authorPhilippe Proulx <eeppeliteloop@gmail.com>
Mon, 17 Jun 2019 17:18:11 +0000 (13:18 -0400)
committerPhilippe Proulx <eeppeliteloop@gmail.com>
Thu, 20 Jun 2019 18:01:16 +0000 (14:01 -0400)
Note that the API of `bin-info.h` is tested in
`tests/plugins/flt.lttng-utils.debug-info/test_bin_info.c`, and since
the BT_COMP_LOG*() macros can call bt_component_get_name(), which is
defined in the Babeltrace library, `test_bin_info` needs to be linked
with the Babeltrace library now.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: Ibb29ece3936478f0e82f28d7f889a067d771a703
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1480
Tested-by: jenkins <jenkins@lttng.org>
12 files changed:
src/plugins/lttng-utils/debug-info/bin-info.c
src/plugins/lttng-utils/debug-info/bin-info.h
src/plugins/lttng-utils/debug-info/debug-info.c
src/plugins/lttng-utils/debug-info/trace-ir-data-copy.c
src/plugins/lttng-utils/debug-info/trace-ir-data-copy.h
src/plugins/lttng-utils/debug-info/trace-ir-mapping.c
src/plugins/lttng-utils/debug-info/trace-ir-mapping.h
src/plugins/lttng-utils/debug-info/trace-ir-metadata-copy.c
src/plugins/lttng-utils/debug-info/trace-ir-metadata-copy.h
src/plugins/lttng-utils/debug-info/trace-ir-metadata-field-class-copy.c
tests/plugins/flt.lttng-utils.debug-info/Makefile.am
tests/plugins/flt.lttng-utils.debug-info/test_bin_info.c

index 20ed40a799506c70f7ed8a962279cb51a1b8d8cb..3d46a54f2ee9afd205ddea386e0ff55347d43640 100644 (file)
  * SOFTWARE.
  */
 
+#define BT_COMP_LOG_SELF_COMP (bin->self_comp)
 #define BT_LOG_OUTPUT_LEVEL (bin->log_level)
 #define BT_LOG_TAG "PLUGIN/FLT.LTTNG-UTILS.DEBUG-INFO/BIN-INFO"
-#include "logging/log.h"
+#include "plugins/comp-logging.h"
 
 #include <babeltrace2/logging.h>
 #include <dwarf.h>
 #define BUILD_ID_NOTE_NAME "GNU"
 
 BT_HIDDEN
-int bin_info_init(bt_logging_level log_level)
+int bin_info_init(bt_logging_level log_level, bt_self_component *self_comp)
 {
        int ret = 0;
 
        if (elf_version(EV_CURRENT) == EV_NONE) {
-               BT_LOG_WRITE_CUR_LVL(BT_LOG_INFO, log_level, BT_LOG_TAG,
+               BT_COMP_LOG_CUR_LVL(BT_LOG_INFO, log_level, self_comp,
                        "ELF library initialization failed: %s.",
                        elf_errmsg(-1));
                ret = -1;
@@ -78,7 +79,7 @@ BT_HIDDEN
 struct bin_info *bin_info_create(struct bt_fd_cache *fdc, const char *path,
                uint64_t low_addr, uint64_t memsz, bool is_pic,
                const char *debug_info_dir, const char *target_prefix,
-               bt_logging_level log_level)
+               bt_logging_level log_level, bt_self_component *self_comp)
 {
        struct bin_info *bin = NULL;
 
@@ -94,6 +95,7 @@ struct bin_info *bin_info_create(struct bt_fd_cache *fdc, const char *path,
        }
 
        bin->log_level = log_level;
+       bin->self_comp = self_comp;
        if (target_prefix) {
                bin->elf_path = g_build_filename(target_prefix, path, NULL);
        } else {
@@ -168,7 +170,7 @@ int bin_info_set_elf_file(struct bin_info *bin)
 
        elf_handle = bt_fd_cache_get_handle(bin->fd_cache, bin->elf_path);
        if (!elf_handle) {
-               BT_LOGI("Failed to open %s", bin->elf_path);
+               BT_COMP_LOGI("Failed to open %s", bin->elf_path);
                goto error;
        }
        bin->elf_handle = elf_handle;
@@ -176,14 +178,14 @@ int bin_info_set_elf_file(struct bin_info *bin)
        elf_file = elf_begin(bt_fd_cache_handle_get_fd(bin->elf_handle),
                ELF_C_READ, NULL);
        if (!elf_file) {
-               BT_LOGE("elf_begin failed: %s", elf_errmsg(-1));
+               BT_COMP_LOGE("elf_begin failed: %s", elf_errmsg(-1));
                goto error;
        }
 
        bin->elf_file = elf_file;
 
        if (elf_kind(elf_file) != ELF_K_ELF) {
-               BT_LOGE("Error: %s is not an ELF object", bin->elf_path);
+               BT_COMP_LOGE("Error: %s is not an ELF object", bin->elf_path);
                goto error;
        }
 
@@ -383,7 +385,7 @@ int bin_info_set_build_id(struct bin_info *bin, uint8_t *build_id,
         */
        bin->file_build_id_matches = is_build_id_matching(bin);
        if (!bin->file_build_id_matches) {
-               BT_LOGI_STR("Supplied Build ID does not match Build ID of the "
+               BT_COMP_LOGI_STR("Supplied Build ID does not match Build ID of the "
                                "binary or library found on the file system.");
                goto error;
        }
@@ -1120,7 +1122,7 @@ int bin_info_lookup_function_name(struct bin_info *bin,
        if (!bin->dwarf_info && !bin->is_elf_only) {
                ret = bin_info_set_dwarf_info(bin);
                if (ret) {
-                       BT_LOGI_STR("Failed to set bin dwarf info, falling "
+                       BT_COMP_LOGI_STR("Failed to set bin dwarf info, falling "
                                        "back to ELF lookup.");
                        /* Failed to set DWARF info, fallback to ELF. */
                        bin->is_elf_only = true;
@@ -1143,14 +1145,14 @@ int bin_info_lookup_function_name(struct bin_info *bin,
                ret = bin_info_lookup_elf_function_name(bin, addr,
                                &_func_name);
                if (ret) {
-                       BT_LOGI("Failed to lookup function name (ELF): "
+                       BT_COMP_LOGI("Failed to lookup function name (ELF): "
                                "ret=%d", ret);
                }
        } else {
                ret = bin_info_lookup_dwarf_function_name(bin, addr,
                                &_func_name);
                if (ret) {
-                       BT_LOGI("Failed to lookup function name (DWARF): "
+                       BT_COMP_LOGI("Failed to lookup function name (DWARF): "
                                "ret=%d", ret);
                }
        }
index 98d7fd1f48eed58fca6573e10a57cc4d86754ad2..1d05c495db2b679284d7064c39be5b2be459c248 100644 (file)
@@ -27,7 +27,7 @@
  * SOFTWARE.
  */
 
-#include <babeltrace2/logging.h>
+#include <babeltrace2/babeltrace.h>
 #include <stdint.h>
 #include <stdbool.h>
 #include <gelf.h>
@@ -44,6 +44,9 @@
 struct bin_info {
        bt_logging_level log_level;
 
+       /* Used for logging; can be `NULL` */
+       bt_self_component *self_comp;
+
        /* Base virtual memory address. */
        uint64_t low_addr;
        /* Upper bound of exec address space. */
@@ -93,7 +96,8 @@ struct source_location {
  * @returns            0 on success, -1 on failure
  */
 BT_HIDDEN
-int bin_info_init(bt_logging_level log_level);
+int bin_info_init(bt_logging_level log_level,
+               bt_self_component *self_comp);
 
 /**
  * Instantiate a structure representing an ELF executable, possibly
@@ -114,7 +118,7 @@ BT_HIDDEN
 struct bin_info *bin_info_create(struct bt_fd_cache *fdc, const char *path,
                uint64_t low_addr, uint64_t memsz, bool is_pic,
                const char *debug_info_dir, const char *target_prefix,
-               bt_logging_level log_level);
+               bt_logging_level log_level, bt_self_component *self_comp);
 
 /**
  * Destroy the given bin_info instance
index 583f779f5a8a4c0fdbee29839efaf9ae24b21aa5..06c8a9b1edbc77cc2e9c1c9aa59c54632ac35a92 100644 (file)
  * SOFTWARE.
  */
 
+#define BT_COMP_LOG_SELF_COMP self_comp
 #define BT_LOG_OUTPUT_LEVEL log_level
 #define BT_LOG_TAG "PLUGIN/FLT.LTTNG-UTILS.DEBUG-INFO"
-#include "logging/log.h"
+#include "plugins/comp-logging.h"
 
 #include <glib.h>
 
@@ -57,6 +58,7 @@
 
 struct debug_info_component {
        bt_logging_level log_level;
+       bt_self_component *self_comp;
        gchar *arg_debug_dir;
        gchar *arg_debug_info_field_name;
        gchar *arg_target_prefix;
@@ -114,6 +116,7 @@ struct proc_debug_info_sources {
 
 struct debug_info {
        bt_logging_level log_level;
+       bt_self_component *self_comp;
        struct debug_info_component *comp;
        const bt_trace *input_trace;
        uint64_t destruction_listener_id;
@@ -148,7 +151,7 @@ int debug_info_init(struct debug_info *info)
        info->q_lib_load = g_quark_from_string("lttng_ust_lib:load");
        info->q_lib_unload = g_quark_from_string("lttng_ust_lib:unload");
 
-       return bin_info_init(info->log_level);
+       return bin_info_init(info->log_level, info->self_comp);
 }
 
 static
@@ -168,7 +171,8 @@ void debug_info_source_destroy(struct debug_info_source *debug_info_src)
 
 static
 struct debug_info_source *debug_info_source_create_from_bin(
-               struct bin_info *bin, uint64_t ip)
+               struct bin_info *bin, uint64_t ip,
+               bt_self_component *self_comp)
 {
        int ret;
        struct debug_info_source *debug_info_src = NULL;
@@ -192,7 +196,7 @@ struct debug_info_source *debug_info_source_create_from_bin(
                /* Lookup source location */
                ret = bin_info_lookup_source_location(bin, ip, &src_loc);
                if (ret) {
-                       BT_LOGI("Failed to lookup source location: ret=%d", ret);
+                       BT_COMP_LOGI("Failed to lookup source location: ret=%d", ret);
                }
        }
 
@@ -200,7 +204,7 @@ struct debug_info_source *debug_info_source_create_from_bin(
                debug_info_src->line_no =
                        g_strdup_printf("%"PRId64, src_loc->line_no);
                if (!debug_info_src->line_no) {
-                       BT_LOGE("Error occured when setting line_no field.");
+                       BT_COMP_LOGE("Error occured when setting line_no field.");
                        goto error;
                }
 
@@ -484,7 +488,8 @@ struct debug_info_source *proc_debug_info_sources_get_entry(
                 * a caching policy), and entries should be prunned when
                 * libraries are unmapped.
                 */
-               debug_info_src = debug_info_source_create_from_bin(bin, ip);
+               debug_info_src = debug_info_source_create_from_bin(bin, ip,
+                       debug_info->self_comp);
                if (debug_info_src) {
                        g_hash_table_insert(
                                        proc_dbg_info_src->ip_to_debug_info_src,
@@ -537,6 +542,7 @@ struct debug_info *debug_info_create(struct debug_info_component *comp,
        }
 
        debug_info->log_level = comp->log_level;
+       debug_info->self_comp = comp->self_comp;
        debug_info->vpid_to_proc_dbg_info_src = g_hash_table_new_full(
                        g_int64_hash, g_int64_equal, (GDestroyNotify) g_free,
                        (GDestroyNotify) proc_debug_info_sources_destroy);
@@ -564,12 +570,14 @@ static
 void debug_info_destroy(struct debug_info *debug_info)
 {
        bt_logging_level log_level;
+       bt_self_component *self_comp;
        bt_trace_status status;
        if (!debug_info) {
                goto end;
        }
 
        log_level = debug_info->log_level;
+       self_comp = debug_info->self_comp;
 
        if (debug_info->vpid_to_proc_dbg_info_src) {
                g_hash_table_destroy(debug_info->vpid_to_proc_dbg_info_src);
@@ -578,7 +586,7 @@ void debug_info_destroy(struct debug_info *debug_info)
        status = bt_trace_remove_destruction_listener(debug_info->input_trace,
                        debug_info->destruction_listener_id);
        if (status != BT_TRACE_STATUS_OK) {
-               BT_LOGE("Trace destruction listener removal failed.");
+               BT_COMP_LOGE("Trace destruction listener removal failed.");
        }
 
        g_free(debug_info);
@@ -765,7 +773,7 @@ void handle_bin_info_event(struct debug_info *debug_info,
        bin = bin_info_create(debug_info->fd_cache, path, baddr, memsz, is_pic,
                debug_info->comp->arg_debug_dir,
                debug_info->comp->arg_target_prefix,
-               debug_info->log_level);
+               debug_info->log_level, debug_info->self_comp);
        if (!bin) {
                goto end;
        }
@@ -939,7 +947,7 @@ void destroy_debug_info_comp(struct debug_info_component *debug_info)
 static
 void fill_debug_info_bin_field(struct debug_info_source *dbg_info_src,
                bool full_path, bt_field *curr_field,
-               bt_logging_level log_level)
+               bt_logging_level log_level, bt_self_component *self_comp)
 {
        bt_field_status status;
 
@@ -955,21 +963,21 @@ void fill_debug_info_bin_field(struct debug_info_source *dbg_info_src,
                                        dbg_info_src->short_bin_path);
                }
                if (status != BT_FIELD_STATUS_OK) {
-                       BT_LOGE("Cannot set path component of \"bin\" "
+                       BT_COMP_LOGE("Cannot set path component of \"bin\" "
                                "curr_field field's value: str-fc-addr=%p",
                                curr_field);
                }
 
                status = bt_field_string_append(curr_field, dbg_info_src->bin_loc);
                if (status != BT_FIELD_STATUS_OK) {
-                       BT_LOGE("Cannot set bin location component of \"bin\" "
+                       BT_COMP_LOGE("Cannot set bin location component of \"bin\" "
                                "curr_field field's value: str-fc-addr=%p",
                                curr_field);
                }
        } else {
                status = bt_field_string_set_value(curr_field, "");
                if (status != BT_FIELD_STATUS_OK) {
-                       BT_LOGE("Cannot set \"bin\" curr_field field's value: "
+                       BT_COMP_LOGE("Cannot set \"bin\" curr_field field's value: "
                                "str-fc-addr=%p", curr_field);
                }
        }
@@ -977,7 +985,8 @@ void fill_debug_info_bin_field(struct debug_info_source *dbg_info_src,
 
 static
 void fill_debug_info_func_field(struct debug_info_source *dbg_info_src,
-               bt_field *curr_field, bt_logging_level log_level)
+               bt_field *curr_field, bt_logging_level log_level,
+               bt_self_component *self_comp)
 {
        bt_field_status status;
 
@@ -990,7 +999,7 @@ void fill_debug_info_func_field(struct debug_info_source *dbg_info_src,
                status = bt_field_string_set_value(curr_field, "");
        }
        if (status != BT_FIELD_STATUS_OK) {
-               BT_LOGE("Cannot set \"func\" curr_field field's value: "
+               BT_COMP_LOGE("Cannot set \"func\" curr_field field's value: "
                        "str-fc-addr=%p", curr_field);
        }
 }
@@ -998,7 +1007,8 @@ void fill_debug_info_func_field(struct debug_info_source *dbg_info_src,
 static
 void fill_debug_info_src_field(struct debug_info_source *dbg_info_src,
                bool full_path, bt_field *curr_field,
-               bt_logging_level log_level)
+               bt_logging_level log_level,
+               bt_self_component *self_comp)
 {
        bt_field_status status;
 
@@ -1014,28 +1024,28 @@ void fill_debug_info_src_field(struct debug_info_source *dbg_info_src,
                                        dbg_info_src->short_src_path);
                }
                if (status != BT_FIELD_STATUS_OK) {
-                       BT_LOGE("Cannot set path component of \"src\" "
+                       BT_COMP_LOGE("Cannot set path component of \"src\" "
                                "curr_field field's value: str-fc-addr=%p",
                                curr_field);
                }
 
                status = bt_field_string_append(curr_field, ":");
                if (status != BT_FIELD_STATUS_OK) {
-                       BT_LOGE("Cannot set colon component of \"src\" "
+                       BT_COMP_LOGE("Cannot set colon component of \"src\" "
                                "curr_field field's value: str-fc-addr=%p",
                                curr_field);
                }
 
                status = bt_field_string_append(curr_field, dbg_info_src->line_no);
                if (status != BT_FIELD_STATUS_OK) {
-                       BT_LOGE("Cannot set line number component of \"src\" "
+                       BT_COMP_LOGE("Cannot set line number component of \"src\" "
                                "curr_field field's value: str-fc-addr=%p",
                                curr_field);
                }
        } else {
                status = bt_field_string_set_value(curr_field, "");
                if (status != BT_FIELD_STATUS_OK) {
-                       BT_LOGE("Cannot set \"src\" curr_field field's value: "
+                       BT_COMP_LOGE("Cannot set \"src\" curr_field field's value: "
                                "str-fc-addr=%p", curr_field);
                }
        }
@@ -1043,7 +1053,7 @@ void fill_debug_info_src_field(struct debug_info_source *dbg_info_src,
 
 static
 void fill_debug_info_field_empty(bt_field *debug_info_field,
-               bt_logging_level log_level)
+       bt_logging_level log_level, bt_self_component *self_comp)
 {
        bt_field_status status;
        bt_field *bin_field, *func_field, *src_field;
@@ -1067,19 +1077,19 @@ void fill_debug_info_field_empty(bt_field *debug_info_field,
 
        status = bt_field_string_set_value(bin_field, "");
        if (status != BT_FIELD_STATUS_OK) {
-               BT_LOGE("Cannot set \"bin\" bin_field field's value: "
+               BT_COMP_LOGE("Cannot set \"bin\" bin_field field's value: "
                        "str-fc-addr=%p", bin_field);
        }
 
        status = bt_field_string_set_value(func_field, "");
        if (status != BT_FIELD_STATUS_OK) {
-               BT_LOGE("Cannot set \"func\" func_field field's value: "
+               BT_COMP_LOGE("Cannot set \"func\" func_field field's value: "
                        "str-fc-addr=%p", func_field);
        }
 
        status = bt_field_string_set_value(src_field, "");
        if (status != BT_FIELD_STATUS_OK) {
-               BT_LOGE("Cannot set \"src\" src_field field's value: "
+               BT_COMP_LOGE("Cannot set \"src\" src_field field's value: "
                        "str-fc-addr=%p", src_field);
        }
 }
@@ -1103,16 +1113,16 @@ void fill_debug_info_field(struct debug_info *debug_info, int64_t vpid,
                debug_info->comp->arg_full_path,
                bt_field_structure_borrow_member_field_by_name(
                        debug_info_field, "bin"),
-               debug_info->log_level);
+               debug_info->log_level, debug_info->self_comp);
        fill_debug_info_func_field(dbg_info_src,
                bt_field_structure_borrow_member_field_by_name(
                        debug_info_field, "func"),
-               debug_info->log_level);
+               debug_info->log_level, debug_info->self_comp);
        fill_debug_info_src_field(dbg_info_src,
                debug_info->comp->arg_full_path,
                bt_field_structure_borrow_member_field_by_name(
                        debug_info_field, "src"),
-               debug_info->log_level);
+               debug_info->log_level, debug_info->self_comp);
 }
 
 static
@@ -1128,6 +1138,7 @@ void fill_debug_info_event_if_needed(struct debug_info_msg_iter *debug_it,
        gchar *debug_info_field_name =
                debug_it->debug_info_component->arg_debug_info_field_name;
        bt_logging_level log_level = debug_it->log_level;
+       bt_self_component *self_comp = debug_it->self_comp;
 
        in_common_ctx_field = bt_event_borrow_common_context_field_const(
                        in_event);
@@ -1181,9 +1192,10 @@ void fill_debug_info_event_if_needed(struct debug_info_msg_iter *debug_it,
                 */
                fill_debug_info_field(debug_info, vpid, ip, out_debug_info_field);
        } else {
-               BT_LOGD("No debug information for this trace. Setting debug "
+               BT_COMP_LOGD("No debug information for this trace. Setting debug "
                        "info fields to empty strings.");
-               fill_debug_info_field_empty(out_debug_info_field, log_level);
+               fill_debug_info_field_empty(out_debug_info_field,
+                       log_level, self_comp);
        }
 end:
        return;
@@ -1232,6 +1244,7 @@ bt_message *handle_event_message(struct debug_info_msg_iter *debug_it,
        bt_packet *out_packet;
        bt_event *out_event;
        bt_logging_level log_level = debug_it->log_level;
+       bt_self_component *self_comp = debug_it->self_comp;
 
        bt_message *out_message = NULL;
 
@@ -1274,14 +1287,14 @@ bt_message *handle_event_message(struct debug_info_msg_iter *debug_it,
        }
 
        if (!out_message) {
-               BT_LOGE("Error creating output event message.");
+               BT_COMP_LOGE("Error creating output event message.");
                goto error;
        }
 
        out_event = bt_message_event_borrow_event(out_message);
 
        /* Copy the original fields to the output event. */
-       copy_event_content(in_event, out_event, log_level);
+       copy_event_content(in_event, out_event, log_level, self_comp);
 
        /*
         * Try to set the debug-info fields based on debug information that is
@@ -1301,6 +1314,7 @@ bt_message *handle_stream_begin_message(struct debug_info_msg_iter *debug_it,
        bt_message *out_message;
        bt_stream *out_stream;
        bt_logging_level log_level = debug_it->log_level;
+       bt_self_component *self_comp = debug_it->self_comp;
 
        in_stream = bt_message_stream_beginning_borrow_stream_const(in_message);
        BT_ASSERT(in_stream);
@@ -1317,7 +1331,7 @@ bt_message *handle_stream_begin_message(struct debug_info_msg_iter *debug_it,
        out_message = bt_message_stream_beginning_create(
                        debug_it->input_iterator, out_stream);
        if (!out_message) {
-               BT_LOGE("Error creating output stream beginning message: "
+               BT_COMP_LOGE("Error creating output stream beginning message: "
                        "out-s-addr=%p", out_stream);
        }
 error:
@@ -1332,6 +1346,7 @@ bt_message *handle_stream_end_message(struct debug_info_msg_iter *debug_it,
        bt_message *out_message = NULL;
        bt_stream *out_stream;
        bt_logging_level log_level = debug_it->log_level;
+       bt_self_component *self_comp = debug_it->self_comp;
 
        in_stream = bt_message_stream_end_borrow_stream_const(in_message);
        BT_ASSERT(in_stream);
@@ -1344,7 +1359,7 @@ bt_message *handle_stream_end_message(struct debug_info_msg_iter *debug_it,
        out_message = bt_message_stream_end_create(debug_it->input_iterator,
                        out_stream);
        if (!out_message) {
-               BT_LOGE("Error creating output stream end message: out-s-addr=%p",
+               BT_COMP_LOGE("Error creating output stream end message: out-s-addr=%p",
                                out_stream);
        }
 
@@ -1363,6 +1378,7 @@ bt_message *handle_packet_begin_message(struct debug_info_msg_iter *debug_it,
        bt_message *out_message = NULL;
        bt_packet *out_packet;
        bt_logging_level log_level = debug_it->log_level;
+       bt_self_component *self_comp = debug_it->self_comp;
 
        const bt_packet *in_packet =
                bt_message_packet_beginning_borrow_packet_const(in_message);
@@ -1395,7 +1411,7 @@ bt_message *handle_packet_begin_message(struct debug_info_msg_iter *debug_it,
                                debug_it->input_iterator, out_packet);
        }
        if (!out_message) {
-               BT_LOGE("Error creating output packet beginning message: "
+               BT_COMP_LOGE("Error creating output packet beginning message: "
                        "out-p-addr=%p", out_packet);
        }
 
@@ -1412,6 +1428,7 @@ bt_message *handle_packet_end_message(struct debug_info_msg_iter *debug_it,
        bt_message *out_message = NULL;
        bt_packet *out_packet;
        bt_logging_level log_level = debug_it->log_level;
+       bt_self_component *self_comp = debug_it->self_comp;
 
        in_packet = bt_message_packet_end_borrow_packet_const(in_message);
        BT_ASSERT(in_packet);
@@ -1438,7 +1455,7 @@ bt_message *handle_packet_end_message(struct debug_info_msg_iter *debug_it,
        }
 
        if (!out_message) {
-               BT_LOGE("Error creating output packet end message: "
+               BT_COMP_LOGE("Error creating output packet end message: "
                        "out-p-addr=%p", out_packet);
        }
 
@@ -1471,6 +1488,7 @@ bt_message *handle_stream_act_begin_message(struct debug_info_msg_iter *debug_it
        uint64_t cs_value;
        bt_message_stream_activity_clock_snapshot_state cs_state;
        bt_logging_level log_level = debug_it->log_level;
+       bt_self_component *self_comp = debug_it->self_comp;
 
        const bt_stream *in_stream =
                bt_message_stream_activity_beginning_borrow_stream_const(
@@ -1484,7 +1502,7 @@ bt_message *handle_stream_act_begin_message(struct debug_info_msg_iter *debug_it
        out_message = bt_message_stream_activity_beginning_create(
                        debug_it->input_iterator, out_stream);
        if (!out_message) {
-               BT_LOGE("Error creating output stream activity beginning "
+               BT_COMP_LOGE("Error creating output stream activity beginning "
                        "message: out-s-addr=%p", out_stream);
                goto error;
        }
@@ -1523,6 +1541,7 @@ bt_message *handle_stream_act_end_message(struct debug_info_msg_iter *debug_it,
        uint64_t cs_value;
        bt_message_stream_activity_clock_snapshot_state cs_state;
        bt_logging_level log_level = debug_it->log_level;
+       bt_self_component *self_comp = debug_it->self_comp;
 
        in_stream = bt_message_stream_activity_end_borrow_stream_const(
                        in_message);
@@ -1535,7 +1554,7 @@ bt_message *handle_stream_act_end_message(struct debug_info_msg_iter *debug_it,
        out_message = bt_message_stream_activity_end_create(
                        debug_it->input_iterator, out_stream);
        if (!out_message) {
-               BT_LOGE("Error creating output stream activity end message: "
+               BT_COMP_LOGE("Error creating output stream activity end message: "
                        "out-s-addr=%p", out_stream);
                goto error;
        }
@@ -1574,6 +1593,7 @@ bt_message *handle_discarded_events_message(struct debug_info_msg_iter *debug_it
        bt_message *out_message = NULL;
        bt_stream *out_stream;
        bt_logging_level log_level = debug_it->log_level;
+       bt_self_component *self_comp = debug_it->self_comp;
 
        in_stream = bt_message_discarded_events_borrow_stream_const(
                        in_message);
@@ -1606,7 +1626,7 @@ bt_message *handle_discarded_events_message(struct debug_info_msg_iter *debug_it
                                debug_it->input_iterator, out_stream);
        }
        if (!out_message) {
-               BT_LOGE("Error creating output discarded events message: "
+               BT_COMP_LOGE("Error creating output discarded events message: "
                        "out-s-addr=%p", out_stream);
                goto error;
        }
@@ -1635,6 +1655,7 @@ bt_message *handle_discarded_packets_message(struct debug_info_msg_iter *debug_i
        bt_message *out_message = NULL;
        bt_stream *out_stream;
        bt_logging_level log_level = debug_it->log_level;
+       bt_self_component *self_comp = debug_it->self_comp;
 
        in_stream = bt_message_discarded_packets_borrow_stream_const(
                        in_message);
@@ -1667,7 +1688,7 @@ bt_message *handle_discarded_packets_message(struct debug_info_msg_iter *debug_i
                                debug_it->input_iterator, out_stream);
        }
        if (!out_message) {
-               BT_LOGE("Error creating output discarded packet message: "
+               BT_COMP_LOGE("Error creating output discarded packet message: "
                        "out-s-addr=%p", out_stream);
                goto error;
        }
@@ -1786,37 +1807,38 @@ int init_from_params(struct debug_info_component *debug_info_component,
 
 BT_HIDDEN
 bt_self_component_status debug_info_comp_init(
-               bt_self_component_filter *self_comp,
+               bt_self_component_filter *self_comp_flt,
                const bt_value *params, __attribute__((unused)) void *init_method_data)
 {
        int ret;
        struct debug_info_component *debug_info_comp;
        bt_self_component_status status = BT_SELF_COMPONENT_STATUS_OK;
+       bt_self_component *self_comp =
+               bt_self_component_filter_as_self_component(self_comp_flt);
        bt_logging_level log_level = bt_component_get_logging_level(
-               bt_self_component_as_component(
-                       bt_self_component_filter_as_self_component(self_comp)));
+               bt_self_component_as_component(self_comp));
 
-       BT_LOGI("Initializing debug_info component: "
+
+       BT_COMP_LOGI("Initializing debug_info component: "
                "comp-addr=%p, params-addr=%p", self_comp, params);
 
        debug_info_comp = g_new0(struct debug_info_component, 1);
        if (!debug_info_comp) {
-               BT_LOGE_STR("Failed to allocate one debug_info component.");
+               BT_COMP_LOGE_STR("Failed to allocate one debug_info component.");
                goto error;
        }
 
        debug_info_comp->log_level = log_level;
-       bt_self_component_set_data(
-               bt_self_component_filter_as_self_component(self_comp),
-               debug_info_comp);
+       debug_info_comp->self_comp = self_comp;
+       bt_self_component_set_data(self_comp, debug_info_comp);
 
-       status = bt_self_component_filter_add_input_port(self_comp, "in",
+       status = bt_self_component_filter_add_input_port(self_comp_flt, "in",
                        NULL, NULL);
        if (status != BT_SELF_COMPONENT_STATUS_OK) {
                goto error;
        }
 
-       status = bt_self_component_filter_add_output_port(self_comp, "out",
+       status = bt_self_component_filter_add_output_port(self_comp_flt, "out",
                        NULL, NULL);
        if (status != BT_SELF_COMPONENT_STATUS_OK) {
                goto error;
@@ -1824,7 +1846,7 @@ bt_self_component_status debug_info_comp_init(
 
        ret = init_from_params(debug_info_comp, params);
        if (ret) {
-               BT_LOGE("Cannot configure debug_info component: "
+               BT_COMP_LOGE("Cannot configure debug_info component: "
                        "debug_info-comp-addr=%p, params-addr=%p",
                        debug_info_comp, params);
                goto error;
@@ -1834,9 +1856,7 @@ bt_self_component_status debug_info_comp_init(
 
 error:
        destroy_debug_info_comp(debug_info_comp);
-       bt_self_component_set_data(
-               bt_self_component_filter_as_self_component(self_comp),
-               NULL);
+       bt_self_component_set_data(self_comp, NULL);
 
        if (status == BT_SELF_COMPONENT_STATUS_OK) {
                status = BT_SELF_COMPONENT_STATUS_ERROR;
@@ -1846,15 +1866,16 @@ end:
 }
 
 BT_HIDDEN
-void debug_info_comp_finalize(bt_self_component_filter *self_comp)
+void debug_info_comp_finalize(bt_self_component_filter *self_comp_flt)
 {
        struct debug_info_component *debug_info =
                bt_self_component_get_data(
                                bt_self_component_filter_as_self_component(
-                                       self_comp));
+                                       self_comp_flt));
        bt_logging_level log_level = debug_info->log_level;
+       bt_self_component *self_comp = debug_info->self_comp;
 
-       BT_LOGI("Finalizing debug_info self_component: comp-addr=%p",
+       BT_COMP_LOGI("Finalizing debug_info self_component: comp-addr=%p",
                self_comp);
 
        destroy_debug_info_comp(debug_info);
@@ -1970,7 +1991,7 @@ end:
 BT_HIDDEN
 bt_self_message_iterator_status debug_info_msg_iter_init(
                bt_self_message_iterator *self_msg_iter,
-               bt_self_component_filter *self_comp,
+               bt_self_component_filter *self_comp_flt,
                bt_self_component_port_output *self_port)
 {
        bt_self_message_iterator_status status = BT_SELF_MESSAGE_ITERATOR_STATUS_OK;
@@ -1979,13 +2000,14 @@ bt_self_message_iterator_status debug_info_msg_iter_init(
        struct debug_info_msg_iter *debug_info_msg_iter = NULL;
        gchar *debug_info_field_name;
        int ret;
+       bt_self_component *self_comp =
+               bt_self_component_filter_as_self_component(self_comp_flt);
        bt_logging_level log_level = bt_component_get_logging_level(
-               bt_self_component_as_component(
-                       bt_self_component_filter_as_self_component(self_comp)));
+               bt_self_component_as_component(self_comp));
 
        /* Borrow the upstream input port. */
        input_port = bt_self_component_filter_borrow_input_port_by_name(
-               self_comp, "in");
+               self_comp_flt, "in");
        if (!input_port) {
                status = BT_SELF_MESSAGE_ITERATOR_STATUS_ERROR;
                goto error;
@@ -1998,6 +2020,7 @@ bt_self_message_iterator_status debug_info_msg_iter_init(
        }
 
        debug_info_msg_iter->log_level = log_level;
+       debug_info_msg_iter->self_comp = self_comp;
 
        /* Create an iterator on the upstream component. */
        upstream_iterator = bt_self_component_port_input_message_iterator_create(
@@ -2019,18 +2042,13 @@ bt_self_message_iterator_status debug_info_msg_iter_init(
                goto error;
        }
 
-       debug_info_msg_iter->self_comp =
-               bt_self_component_filter_as_self_component(self_comp);
-
-       debug_info_msg_iter->debug_info_component = bt_self_component_get_data(
-               bt_self_component_filter_as_self_component(
-                       self_comp));
+       debug_info_msg_iter->debug_info_component =
+               bt_self_component_get_data(self_comp);
 
        debug_info_field_name =
                debug_info_msg_iter->debug_info_component->arg_debug_info_field_name;
 
-       debug_info_msg_iter->ir_maps = trace_ir_maps_create(
-               bt_self_component_filter_as_self_component(self_comp),
+       debug_info_msg_iter->ir_maps = trace_ir_maps_create(self_comp,
                debug_info_field_name, log_level);
        if (!debug_info_msg_iter->ir_maps) {
                status = BT_SELF_MESSAGE_ITERATOR_STATUS_NOMEM;
index fb0d0c128ed022f71db65736f1eb01d177390dc7..6def0b7283c5303a33358f6938cb7bdb063b0a30 100644 (file)
  * SOFTWARE.
  */
 
+#define BT_COMP_LOG_SELF_COMP self_comp
 #define BT_LOG_OUTPUT_LEVEL log_level
 #define BT_LOG_TAG "PLUGIN/FLT.LTTNG-UTILS.DEBUG-INFO/TRACE-IR-DATA-COPY"
-#include "logging/log.h"
+#include "plugins/comp-logging.h"
 
 #include <inttypes.h>
 #include <stdint.h>
 
 BT_HIDDEN
 void copy_trace_content(const bt_trace *in_trace, bt_trace *out_trace,
-               bt_logging_level log_level)
+               bt_logging_level log_level, bt_self_component *self_comp)
 {
        bt_trace_status status;
        const char *trace_name;
 
-       BT_LOGD("Copying content of trace: in-t-addr=%p, out-t-addr=%p",
+       BT_COMP_LOGD("Copying content of trace: in-t-addr=%p, out-t-addr=%p",
                        in_trace, out_trace);
 
        trace_name = bt_trace_get_name(in_trace);
@@ -49,13 +50,13 @@ void copy_trace_content(const bt_trace *in_trace, bt_trace *out_trace,
        if (trace_name) {
                status = bt_trace_set_name(out_trace, trace_name);
                if (status != BT_TRACE_STATUS_OK) {
-                       BT_LOGE("Cannot set trace's name: trace-addr=%p, name=\"%s\"",
+                       BT_COMP_LOGE("Cannot set trace's name: trace-addr=%p, name=\"%s\"",
                                        out_trace, trace_name);
                        goto end;
                }
        }
 
-       BT_LOGD("Copied content of trace: in-t-addr=%p, out-t-addr=%p",
+       BT_COMP_LOGD("Copied content of trace: in-t-addr=%p, out-t-addr=%p",
                        in_trace, out_trace);
 end:
        return;
@@ -63,25 +64,25 @@ end:
 
 BT_HIDDEN
 void copy_stream_content(const bt_stream *in_stream, bt_stream *out_stream,
-               bt_logging_level log_level)
+               bt_logging_level log_level, bt_self_component *self_comp)
 {
        const char *stream_name;
        bt_stream_status status;
 
-       BT_LOGD("Copying content of stream: in-s-addr=%p, out-s-addr=%p",
+       BT_COMP_LOGD("Copying content of stream: in-s-addr=%p, out-s-addr=%p",
                        in_stream, out_stream);
 
        stream_name = bt_stream_get_name(in_stream);
        if (stream_name) {
                status = bt_stream_set_name(out_stream, stream_name);
                if (status != BT_STREAM_STATUS_OK) {
-                       BT_LOGE("Cannot set stream's name: stream-addr=%p, "
+                       BT_COMP_LOGE("Cannot set stream's name: stream-addr=%p, "
                                "name=%s", out_stream, stream_name);
                        goto end;
                }
        }
 
-       BT_LOGD("Copied content of stream: in-s-addr=%p, out-s-addr=%p",
+       BT_COMP_LOGD("Copied content of stream: in-s-addr=%p, out-s-addr=%p",
                        in_stream, out_stream);
 end:
        return;
@@ -89,12 +90,12 @@ end:
 
 BT_HIDDEN
 void copy_packet_content(const bt_packet *in_packet, bt_packet *out_packet,
-               bt_logging_level log_level)
+               bt_logging_level log_level, bt_self_component *self_comp)
 {
        const bt_field *in_context_field;
        bt_field *out_context_field;
 
-       BT_LOGD("Copying content of packet: in-p-addr=%p, out-p-addr=%p",
+       BT_COMP_LOGD("Copying content of packet: in-p-addr=%p, out-p-addr=%p",
                        in_packet, out_packet);
 
        /* Copy context field. */
@@ -103,24 +104,24 @@ void copy_packet_content(const bt_packet *in_packet, bt_packet *out_packet,
                out_context_field = bt_packet_borrow_context_field(out_packet);
                BT_ASSERT(out_context_field);
                copy_field_content(in_context_field, out_context_field,
-                       log_level);
+                       log_level, self_comp);
        }
 
-       BT_LOGD("Copied content of packet: in-p-addr=%p, out-p-addr=%p",
+       BT_COMP_LOGD("Copied content of packet: in-p-addr=%p, out-p-addr=%p",
                        in_packet, out_packet);
        return;
 }
 
 BT_HIDDEN
 void copy_event_content(const bt_event *in_event, bt_event *out_event,
-               bt_logging_level log_level)
+               bt_logging_level log_level, bt_self_component *self_comp)
 {
        const bt_field *in_common_ctx_field, *in_specific_ctx_field,
              *in_payload_field;
        bt_field *out_common_ctx_field, *out_specific_ctx_field,
                 *out_payload_field;
 
-       BT_LOGD("Copying content of event: in-e-addr=%p, out-e-addr=%p",
+       BT_COMP_LOGD("Copying content of event: in-e-addr=%p, out-e-addr=%p",
                        in_event, out_event);
        in_common_ctx_field =
                bt_event_borrow_common_context_field_const(in_event);
@@ -129,7 +130,7 @@ void copy_event_content(const bt_event *in_event, bt_event *out_event,
                        bt_event_borrow_common_context_field(out_event);
                BT_ASSERT(out_common_ctx_field);
                copy_field_content(in_common_ctx_field,
-                               out_common_ctx_field, log_level);
+                       out_common_ctx_field, log_level, self_comp);
        }
 
        in_specific_ctx_field =
@@ -139,7 +140,7 @@ void copy_event_content(const bt_event *in_event, bt_event *out_event,
                        bt_event_borrow_specific_context_field(out_event);
                BT_ASSERT(out_specific_ctx_field);
                copy_field_content(in_specific_ctx_field,
-                               out_specific_ctx_field, log_level);
+                       out_specific_ctx_field, log_level, self_comp);
        }
 
        in_payload_field = bt_event_borrow_payload_field_const(in_event);
@@ -147,16 +148,16 @@ void copy_event_content(const bt_event *in_event, bt_event *out_event,
                out_payload_field = bt_event_borrow_payload_field(out_event);
                BT_ASSERT(out_payload_field);
                copy_field_content(in_payload_field,
-                               out_payload_field, log_level);
+                       out_payload_field, log_level, self_comp);
        }
 
-       BT_LOGD("Copied content of event: in-e-addr=%p, out-e-addr=%p",
+       BT_COMP_LOGD("Copied content of event: in-e-addr=%p, out-e-addr=%p",
                        in_event, out_event);
 }
 
 BT_HIDDEN
 void copy_field_content(const bt_field *in_field, bt_field *out_field,
-               bt_logging_level log_level)
+               bt_logging_level log_level, bt_self_component *self_comp)
 {
        bt_field_class_type in_fc_type, out_fc_type;
 
@@ -164,7 +165,7 @@ void copy_field_content(const bt_field *in_field, bt_field *out_field,
        out_fc_type = bt_field_get_class_type(out_field);
        BT_ASSERT(in_fc_type == out_fc_type);
 
-       BT_LOGV("Copying content of field: in-f-addr=%p, out-f-addr=%p",
+       BT_COMP_LOGV("Copying content of field: in-f-addr=%p, out-f-addr=%p",
                        in_field, out_field);
        switch (in_fc_type) {
        case BT_FIELD_CLASS_TYPE_UNSIGNED_INTEGER:
@@ -186,7 +187,7 @@ void copy_field_content(const bt_field *in_field, bt_field *out_field,
                const char *str = bt_field_string_get_value(in_field);
                bt_field_status status = bt_field_string_set_value(out_field, str);
                if (status != BT_FIELD_STATUS_OK) {
-                       BT_LOGE("Cannot set string field's value: "
+                       BT_COMP_LOGE("Cannot set string field's value: "
                                "str-field-addr=%p, str=%s" PRId64,
                                out_field, str);
                }
@@ -225,7 +226,7 @@ void copy_field_content(const bt_field *in_field, bt_field *out_field,
                                                out_field, in_member_name);
 
                        copy_field_content(in_member_field,
-                                       out_member_field, log_level);
+                               out_member_field, log_level, self_comp);
                }
                break;
        }
@@ -244,7 +245,7 @@ void copy_field_content(const bt_field *in_field, bt_field *out_field,
                        status = bt_field_dynamic_array_set_length(out_field,
                                        array_len);
                        if (status != BT_FIELD_STATUS_OK) {
-                               BT_LOGE("Cannot set dynamic array field's "
+                               BT_COMP_LOGE("Cannot set dynamic array field's "
                                        "length field: field-addr=%p, "
                                        "length=%" PRIu64, out_field, array_len);
                        }
@@ -258,7 +259,7 @@ void copy_field_content(const bt_field *in_field, bt_field *out_field,
                                bt_field_array_borrow_element_field_by_index(
                                                out_field, i);
                        copy_field_content(in_element_field, out_element_field,
-                               log_level);
+                               log_level, self_comp);
                }
                break;
        }
@@ -275,7 +276,7 @@ void copy_field_content(const bt_field *in_field, bt_field *out_field,
                status = bt_field_variant_select_option_field(out_field,
                                in_selected_option_idx);
                if (status != BT_FIELD_STATUS_OK) {
-                       BT_LOGE("Cannot select variant field's option field: "
+                       BT_COMP_LOGE("Cannot select variant field's option field: "
                                "var-field-addr=%p, opt-index=%" PRId64,
                                out_field, in_selected_option_idx);
                }
@@ -284,13 +285,13 @@ void copy_field_content(const bt_field *in_field, bt_field *out_field,
                out_option_field = bt_field_variant_borrow_selected_option_field(out_field);
 
                copy_field_content(in_option_field, out_option_field,
-                       log_level);
+                       log_level, self_comp);
 
                break;
        }
        default:
                abort();
        }
-       BT_LOGV("Copied content of field: in-f-addr=%p, out-f-addr=%p",
+       BT_COMP_LOGV("Copied content of field: in-f-addr=%p, out-f-addr=%p",
                        in_field, out_field);
 }
index cc941945b7a8ff89f6564c39276d65d568046209..baa286891e94d1260221a1e2ebee27b5363a5d19 100644 (file)
 
 BT_HIDDEN
 void copy_trace_content(const bt_trace *in_trace, bt_trace *out_trace,
-               bt_logging_level log_level);
+               bt_logging_level log_level, bt_self_component *self_comp);
 BT_HIDDEN
 void copy_stream_content(const bt_stream *in_stream, bt_stream *out_stream,
-               bt_logging_level log_level);
+               bt_logging_level log_level, bt_self_component *self_comp);
 BT_HIDDEN
 void copy_packet_content(const bt_packet *in_packet, bt_packet *out_packet,
-               bt_logging_level log_level);
+               bt_logging_level log_level, bt_self_component *self_comp);
 BT_HIDDEN
 void copy_event_content(const bt_event *in_event, bt_event *out_event,
-               bt_logging_level log_level);
+               bt_logging_level log_level, bt_self_component *self_comp);
 BT_HIDDEN
 void copy_field_content(const bt_field *in_field, bt_field *out_field,
-               bt_logging_level log_level);
+               bt_logging_level log_level, bt_self_component *self_comp);
 
 #endif /* BABELTRACE_PLUGIN_DEBUG_INFO_TRACE_DATA_COPY_H */
index cb73727bf2669ab674c07b4c7ae3e207e8c20fdb..408bab510a27574e2f3ec0d1bf8b00ee6f2d37fd 100644 (file)
  * SOFTWARE.
  */
 
+#define BT_COMP_LOG_SELF_COMP (ir_maps->self_comp)
 #define BT_LOG_OUTPUT_LEVEL (ir_maps->log_level)
 #define BT_LOG_TAG "PLUGIN/FLT.LTTNG-UTILS.DEBUG-INFO/TRACE-IR-MAPPING"
-#include "logging/log.h"
+#include "plugins/comp-logging.h"
 
 #include <stdbool.h>
 
@@ -48,7 +49,7 @@ bt_trace_class *create_new_mapped_trace_class(struct trace_ir_maps *ir_maps,
        int ret;
        bt_trace_class *out_trace_class;
 
-       BT_LOGD("Creating new mapped trace class: in-tc-addr=%p", in_trace_class);
+       BT_COMP_LOGD("Creating new mapped trace class: in-tc-addr=%p", in_trace_class);
 
        BT_ASSERT(ir_maps);
        BT_ASSERT(in_trace_class);
@@ -56,20 +57,20 @@ bt_trace_class *create_new_mapped_trace_class(struct trace_ir_maps *ir_maps,
        /* Create the ouput trace class. */
        out_trace_class = bt_trace_class_create(ir_maps->self_comp);
        if (!out_trace_class) {
-               BT_LOGE_STR("Error create output trace class");
+               BT_COMP_LOGE_STR("Error create output trace class");
                goto end;
        }
 
        /* If not, create a new one and add it to the mapping. */
        ret = copy_trace_class_content(in_trace_class, out_trace_class,
-               ir_maps->log_level);
+               ir_maps->log_level, ir_maps->self_comp);
        if (ret) {
-               BT_LOGE_STR("Error copy content to output trace class");
+               BT_COMP_LOGE_STR("Error copy content to output trace class");
                out_trace_class = NULL;
                goto end;
        }
 
-       BT_LOGD("Created new mapped trace class: in-tc-addr=%p, out-tc-addr=%p",
+       BT_COMP_LOGD("Created new mapped trace class: in-tc-addr=%p, out-tc-addr=%p",
                        in_trace_class, out_trace_class);
 
 end:
@@ -84,7 +85,7 @@ bt_trace *create_new_mapped_trace(struct trace_ir_maps *ir_maps,
        const bt_trace_class *in_trace_class;
        struct trace_ir_metadata_maps *metadata_maps;
 
-       BT_LOGD("Creating new mapped trace: in-t-addr=%p", in_trace);
+       BT_COMP_LOGD("Creating new mapped trace: in-t-addr=%p", in_trace);
        BT_ASSERT(ir_maps);
        BT_ASSERT(in_trace);
 
@@ -103,14 +104,15 @@ bt_trace *create_new_mapped_trace(struct trace_ir_maps *ir_maps,
 
        out_trace = bt_trace_create(metadata_maps->output_trace_class);
        if (!out_trace) {
-               BT_LOGE_STR("Error create output trace");
+               BT_COMP_LOGE_STR("Error create output trace");
                goto end;
        }
 
        /* If not, create a new one and add it to the mapping. */
-       copy_trace_content(in_trace, out_trace, ir_maps->log_level);
+       copy_trace_content(in_trace, out_trace, ir_maps->log_level,
+               ir_maps->self_comp);
 
-       BT_LOGD("Created new mapped trace: in-t-addr=%p, out-t-addr=%p",
+       BT_COMP_LOGD("Created new mapped trace: in-t-addr=%p, out-t-addr=%p",
                        in_trace, out_trace);
 end:
        return out_trace;
@@ -135,7 +137,7 @@ bt_stream_class *create_new_mapped_stream_class(struct trace_ir_maps *ir_maps,
        bt_stream_class *out_stream_class;
        struct trace_ir_metadata_maps *md_maps;
 
-       BT_LOGD("Creating new mapped stream class: in-sc-addr=%p",
+       BT_COMP_LOGD("Creating new mapped stream class: in-sc-addr=%p",
                        in_stream_class);
 
        md_maps = borrow_metadata_maps_from_input_stream_class(ir_maps,
@@ -150,7 +152,7 @@ bt_stream_class *create_new_mapped_stream_class(struct trace_ir_maps *ir_maps,
                        md_maps->output_trace_class,
                        bt_stream_class_get_id(in_stream_class));
        if (!out_stream_class) {
-               BT_LOGE_STR("Error create output stream class");
+               BT_COMP_LOGE_STR("Error create output stream class");
                goto end;
        }
 
@@ -158,7 +160,7 @@ bt_stream_class *create_new_mapped_stream_class(struct trace_ir_maps *ir_maps,
        ret = copy_stream_class_content(ir_maps, in_stream_class,
                        out_stream_class);
        if (ret) {
-               BT_LOGE_STR("Error copy content to output stream class");
+               BT_COMP_LOGE_STR("Error copy content to output stream class");
                out_stream_class = NULL;
                goto end;
        }
@@ -166,7 +168,7 @@ bt_stream_class *create_new_mapped_stream_class(struct trace_ir_maps *ir_maps,
        g_hash_table_insert(md_maps->stream_class_map,
                        (gpointer) in_stream_class, out_stream_class);
 
-       BT_LOGD("Created new mapped stream class: in-sc-addr=%p, out-sc-addr=%p",
+       BT_COMP_LOGD("Created new mapped stream class: in-sc-addr=%p, out-sc-addr=%p",
                        in_stream_class, out_stream_class);
 
 end:
@@ -197,7 +199,7 @@ bt_stream *trace_ir_mapping_create_new_mapped_stream(
 
        BT_ASSERT(ir_maps);
        BT_ASSERT(in_stream);
-       BT_LOGD("Creating new mapped stream: in-s-addr=%p", in_stream);
+       BT_COMP_LOGD("Creating new mapped stream: in-s-addr=%p", in_stream);
 
        in_trace = bt_stream_borrow_trace_const(in_stream);
 
@@ -227,7 +229,7 @@ bt_stream *trace_ir_mapping_create_new_mapped_stream(
        out_stream = bt_stream_create_with_id(out_stream_class,
                        d_maps->output_trace, bt_stream_get_id(in_stream));
        if (!out_stream) {
-               BT_LOGE_STR("Error creating output stream");
+               BT_COMP_LOGE_STR("Error creating output stream");
                goto end;
        }
        /*
@@ -235,12 +237,13 @@ bt_stream *trace_ir_mapping_create_new_mapped_stream(
         * time of the stream objects.
         */
 
-       copy_stream_content(in_stream, out_stream, ir_maps->log_level);
+       copy_stream_content(in_stream, out_stream, ir_maps->log_level,
+               ir_maps->self_comp);
 
        g_hash_table_insert(d_maps->stream_map, (gpointer) in_stream,
                        out_stream);
 
-       BT_LOGD("Created new mapped stream: in-s-addr=%p, out-s-addr=%p",
+       BT_COMP_LOGD("Created new mapped stream: in-s-addr=%p, out-s-addr=%p",
                        in_stream, out_stream);
 
 end:
@@ -282,7 +285,7 @@ bt_event_class *trace_ir_mapping_create_new_mapped_event_class(
 
        BT_ASSERT(ir_maps);
        BT_ASSERT(in_event_class);
-       BT_LOGD("Creating new mapped event class: in-ec-addr=%p",
+       BT_COMP_LOGD("Creating new mapped event class: in-ec-addr=%p",
                        in_event_class);
 
        in_trace_class = bt_stream_class_borrow_trace_class_const(
@@ -305,7 +308,7 @@ bt_event_class *trace_ir_mapping_create_new_mapped_event_class(
        out_event_class = bt_event_class_create_with_id(out_stream_class,
                        bt_event_class_get_id(in_event_class));
        if (!out_event_class) {
-               BT_LOGE_STR("Error creating output event class");
+               BT_COMP_LOGE_STR("Error creating output event class");
                goto end;
        }
 
@@ -313,7 +316,7 @@ bt_event_class *trace_ir_mapping_create_new_mapped_event_class(
        ret = copy_event_class_content(ir_maps, in_event_class,
                        out_event_class);
        if (ret) {
-               BT_LOGE_STR("Error copy content to output event class");
+               BT_COMP_LOGE_STR("Error copy content to output event class");
                out_event_class = NULL;
                goto end;
        }
@@ -321,7 +324,7 @@ bt_event_class *trace_ir_mapping_create_new_mapped_event_class(
        g_hash_table_insert(md_maps->event_class_map,
                        (gpointer) in_event_class, out_event_class);
 
-       BT_LOGD("Created new mapped event class: in-ec-addr=%p, out-ec-addr=%p",
+       BT_COMP_LOGD("Created new mapped event class: in-ec-addr=%p, out-ec-addr=%p",
                        in_event_class, out_event_class);
 
 end:
@@ -366,7 +369,7 @@ bt_packet *trace_ir_mapping_create_new_mapped_packet(
        bt_packet *out_packet;
        bt_stream *out_stream;
 
-       BT_LOGD("Creating new mapped packet: in-p-addr=%p", in_packet);
+       BT_COMP_LOGD("Creating new mapped packet: in-p-addr=%p", in_packet);
 
        in_stream = bt_packet_borrow_stream_const(in_packet);
        in_trace = bt_stream_borrow_trace_const(in_stream);
@@ -384,7 +387,7 @@ bt_packet *trace_ir_mapping_create_new_mapped_packet(
        /* Create the output packet. */
        out_packet = bt_packet_create(out_stream);
        if (!out_packet) {
-               BT_LOGE_STR("Error create output packet");
+               BT_COMP_LOGE_STR("Error create output packet");
                goto end;
        }
 
@@ -392,12 +395,13 @@ bt_packet *trace_ir_mapping_create_new_mapped_packet(
         * Release our ref since the stream object will be managing the life
         * time of the packet objects.
         */
-       copy_packet_content(in_packet, out_packet, ir_maps->log_level);
+       copy_packet_content(in_packet, out_packet, ir_maps->log_level,
+               ir_maps->self_comp);
 
        g_hash_table_insert(d_maps->packet_map,
                        (gpointer) in_packet, out_packet);
 
-       BT_LOGD("Created new mapped packet: in-p-addr=%p, out-p-addr=%p",
+       BT_COMP_LOGD("Created new mapped packet: in-p-addr=%p, out-p-addr=%p",
                        in_packet, out_packet);
 
 end:
@@ -481,11 +485,12 @@ struct trace_ir_data_maps *trace_ir_data_maps_create(struct trace_ir_maps *ir_ma
        struct trace_ir_data_maps *d_maps =
                g_new0(struct trace_ir_data_maps, 1);
        if (!d_maps) {
-               BT_LOGE_STR("Error allocating trace_ir_maps");
+               BT_COMP_LOGE_STR("Error allocating trace_ir_maps");
                goto error;
        }
 
        d_maps->log_level = ir_maps->log_level;
+       d_maps->self_comp = ir_maps->self_comp;
        d_maps->input_trace = in_trace;
 
        /* Create the hashtables used to map data objects. */
@@ -507,11 +512,12 @@ struct trace_ir_metadata_maps *trace_ir_metadata_maps_create(
        struct trace_ir_metadata_maps *md_maps =
                g_new0(struct trace_ir_metadata_maps, 1);
        if (!md_maps) {
-               BT_LOGE_STR("Error allocating trace_ir_maps");
+               BT_COMP_LOGE_STR("Error allocating trace_ir_maps");
                goto error;
        }
 
        md_maps->log_level = ir_maps->log_level;
+       md_maps->self_comp = ir_maps->self_comp;
        md_maps->input_trace_class = in_trace_class;
        /*
         * Create the field class resolving context. This is needed to keep
@@ -521,7 +527,7 @@ struct trace_ir_metadata_maps *trace_ir_metadata_maps_create(
        md_maps->fc_resolving_ctx =
                g_new0(struct field_class_resolving_context, 1);
        if (!md_maps->fc_resolving_ctx) {
-               BT_LOGE_STR("Error allocating field_class_resolving_context");
+               BT_COMP_LOGE_STR("Error allocating field_class_resolving_context");
                goto error;
        }
 
@@ -565,8 +571,8 @@ void trace_ir_data_maps_destroy(struct trace_ir_data_maps *maps)
        status = bt_trace_remove_destruction_listener(maps->input_trace,
                        maps->destruction_listener_id);
        if (status != BT_TRACE_STATUS_OK) {
-               BT_LOG_WRITE_CUR_LVL(BT_LOG_DEBUG, maps->log_level,
-                       BT_LOG_TAG,
+               BT_COMP_LOG_CUR_LVL(BT_LOG_DEBUG, maps->log_level,
+                       maps->self_comp,
                        "Trace destruction listener removal failed.");
        }
 
@@ -608,7 +614,8 @@ void trace_ir_metadata_maps_destroy(struct trace_ir_metadata_maps *maps)
        status = bt_trace_class_remove_destruction_listener(maps->input_trace_class,
                        maps->destruction_listener_id);
        if (status != BT_TRACE_CLASS_STATUS_OK) {
-               BT_LOG_WRITE_CUR_LVL(BT_LOG_DEBUG, maps->log_level, BT_LOG_TAG,
+               BT_COMP_LOG_CUR_LVL(BT_LOG_DEBUG, maps->log_level,
+                       maps->self_comp,
                        "Trace destruction listener removal failed.");
        }
 
@@ -657,18 +664,19 @@ struct trace_ir_maps *trace_ir_maps_create(bt_self_component *self_comp,
        struct trace_ir_maps *ir_maps =
                g_new0(struct trace_ir_maps, 1);
        if (!ir_maps) {
-               BT_LOG_WRITE_CUR_LVL(BT_LOG_ERROR, log_level, BT_LOG_TAG,
+               BT_COMP_LOG_CUR_LVL(BT_LOG_ERROR, log_level, self_comp,
                        "Error allocating trace_ir_maps");
                goto error;
        }
 
        ir_maps->log_level = log_level;
+       ir_maps->self_comp = self_comp;
 
        /* Copy debug info field name received from the user. */
        ir_maps->debug_info_field_class_name =
                g_strdup(debug_info_field_name);
        if (!ir_maps->debug_info_field_class_name) {
-               BT_LOGE_STR("Cannot copy debug info field name");
+               BT_COMP_LOGE_STR("Cannot copy debug info field name");
                goto error;
        }
 
index 514cc2d6231c218fa734f986072cb2b43a33077f..e09cf7634693490b3630afab339eadc36cf7d546 100644 (file)
@@ -44,6 +44,7 @@ struct field_class_resolving_context {
 
 struct trace_ir_metadata_maps {
        bt_logging_level log_level;
+       bt_self_component *self_comp;
        const bt_trace_class *input_trace_class;
        bt_trace_class *output_trace_class;
 
@@ -87,6 +88,7 @@ struct trace_ir_metadata_maps {
 
 struct trace_ir_data_maps {
        bt_logging_level log_level;
+       bt_self_component *self_comp;
        const bt_trace *input_trace;
        bt_trace *output_trace;
 
index 924c4e66cd528ff4b7ebae2a9d3b3e608c32bb5d..698d47b9a6812eebb03454646c3acca693605cf3 100644 (file)
  * SOFTWARE.
  */
 
+#define BT_COMP_LOG_SELF_COMP self_comp
 #define BT_LOG_OUTPUT_LEVEL log_level
 #define BT_LOG_TAG "PLUGIN/FLT.LTTNG-UTILS.DEBUG-INFO/TRACE-IR-META-COPY"
-#include "logging/log.h"
+#include "plugins/comp-logging.h"
 
 #include <inttypes.h>
 #include <stdint.h>
 
 BT_HIDDEN
 int copy_trace_class_content(const bt_trace_class *in_trace_class,
-               bt_trace_class *out_trace_class, bt_logging_level log_level)
+               bt_trace_class *out_trace_class, bt_logging_level log_level,
+               bt_self_component *self_comp)
 {
        int ret = 0;
        uint64_t i, env_field_count;
        const char *in_trace_class_name;
 
-       BT_LOGD("Copying content of trace class: in-tc-addr=%p, out-tc-addr=%p",
+       BT_COMP_LOGD("Copying content of trace class: in-tc-addr=%p, out-tc-addr=%p",
                        in_trace_class, out_trace_class);
 
        /* Use the same stream class ids as in the origin trace class. */
@@ -75,7 +77,7 @@ int copy_trace_class_content(const bt_trace_class *in_trace_class,
                bt_trace_class_borrow_environment_entry_by_index_const(
                        in_trace_class, i, &value_name, &value);
 
-               BT_LOGD("Copying trace class environnement entry: "
+               BT_COMP_LOGD("Copying trace class environnement entry: "
                        "index=%" PRId64 ", value-addr=%p, value-name=%s",
                        i, value, value_name);
 
@@ -103,7 +105,7 @@ int copy_trace_class_content(const bt_trace_class *in_trace_class,
                }
        }
 
-       BT_LOGD("Copied content of trace class: in-tc-addr=%p, out-tc-addr=%p",
+       BT_COMP_LOGD("Copied content of trace class: in-tc-addr=%p, out-tc-addr=%p",
                        in_trace_class, out_trace_class);
 error:
        return ret;
@@ -111,7 +113,8 @@ error:
 
 static
 int copy_clock_class_content(const bt_clock_class *in_clock_class,
-               bt_clock_class *out_clock_class, bt_logging_level log_level)
+               bt_clock_class *out_clock_class, bt_logging_level log_level,
+               bt_self_component *self_comp)
 {
        bt_clock_class_status status;
        const char *clock_class_name, *clock_class_description;
@@ -120,7 +123,7 @@ int copy_clock_class_content(const bt_clock_class *in_clock_class,
        bt_uuid in_uuid;
        int ret = 0;
 
-       BT_LOGD("Copying content of clock class: in-cc-addr=%p, out-cc-addr=%p",
+       BT_COMP_LOGD("Copying content of clock class: in-cc-addr=%p, out-cc-addr=%p",
                        in_clock_class, out_clock_class);
 
        clock_class_name = bt_clock_class_get_name(in_clock_class);
@@ -128,7 +131,7 @@ int copy_clock_class_content(const bt_clock_class *in_clock_class,
        if (clock_class_name) {
                status = bt_clock_class_set_name(out_clock_class, clock_class_name);
                if (status != BT_CLOCK_CLASS_STATUS_OK) {
-                       BT_LOGE("Error setting clock class' name cc-addr=%p, name=%p",
+                       BT_COMP_LOGE("Error setting clock class' name cc-addr=%p, name=%p",
                                out_clock_class, clock_class_name);
                        out_clock_class = NULL;
                        ret = -1;
@@ -142,7 +145,7 @@ int copy_clock_class_content(const bt_clock_class *in_clock_class,
                status = bt_clock_class_set_description(out_clock_class,
                                clock_class_description);
                if (status != BT_CLOCK_CLASS_STATUS_OK) {
-                       BT_LOGE("Error setting clock class' description cc-addr=%p, "
+                       BT_COMP_LOGE("Error setting clock class' description cc-addr=%p, "
                                "name=%p", out_clock_class, clock_class_description);
                        out_clock_class = NULL;
                        ret = -1;
@@ -164,7 +167,7 @@ int copy_clock_class_content(const bt_clock_class *in_clock_class,
        bt_clock_class_set_origin_is_unix_epoch(out_clock_class,
                        bt_clock_class_origin_is_unix_epoch(in_clock_class));
 
-       BT_LOGD("Copied content of clock class: in-cc-addr=%p, out-cc-addr=%p",
+       BT_COMP_LOGD("Copied content of clock class: in-cc-addr=%p, out-cc-addr=%p",
                        in_clock_class, out_clock_class);
 
 error:
@@ -193,7 +196,7 @@ bt_clock_class *create_new_mapped_clock_class(
        int ret;
        bt_logging_level log_level = md_maps->log_level;
 
-       BT_LOGD("Creating new mapped clock class: in-cc-addr=%p",
+       BT_COMP_LOGD("Creating new mapped clock class: in-cc-addr=%p",
                        in_clock_class);
 
        BT_ASSERT(md_maps);
@@ -203,21 +206,21 @@ bt_clock_class *create_new_mapped_clock_class(
 
        out_clock_class = bt_clock_class_create(self_comp);
        if (!out_clock_class) {
-               BT_LOGE_STR("Cannot create clock class");
+               BT_COMP_LOGE_STR("Cannot create clock class");
                goto end;
        }
        /* If not, create a new one and add it to the mapping. */
        ret = copy_clock_class_content(in_clock_class, out_clock_class,
-               log_level);
+               log_level, self_comp);
        if (ret) {
-               BT_LOGE_STR("Cannot copy clock class");
+               BT_COMP_LOGE_STR("Cannot copy clock class");
                goto end;
        }
 
        g_hash_table_insert(md_maps->clock_class_map,
                        (gpointer) in_clock_class, out_clock_class);
 
-       BT_LOGD("Created new mapped clock class: in-cc-addr=%p, out-cc-addr=%p",
+       BT_COMP_LOGD("Created new mapped clock class: in-cc-addr=%p, out-cc-addr=%p",
                        in_clock_class, out_clock_class);
 end:
        return out_clock_class;
@@ -237,8 +240,9 @@ int copy_stream_class_content(struct trace_ir_maps *ir_maps,
        const char *in_name;
        int ret = 0;
        bt_logging_level log_level = ir_maps->log_level;
+       bt_self_component *self_comp = ir_maps->self_comp;
 
-       BT_LOGD("Copying content of stream class: in-sc-addr=%p, out-sc-addr=%p",
+       BT_COMP_LOGD("Copying content of stream class: in-sc-addr=%p, out-sc-addr=%p",
                        in_stream_class, out_stream_class);
 
        md_maps = borrow_metadata_maps_from_input_stream_class(ir_maps, in_stream_class);
@@ -282,7 +286,7 @@ int copy_stream_class_content(struct trace_ir_maps *ir_maps,
        if (in_name) {
                status = bt_stream_class_set_name(out_stream_class, in_name);
                if (status != BT_STREAM_CLASS_STATUS_OK) {
-                       BT_LOGE("Error set stream class name: out-sc-addr=%p, "
+                       BT_COMP_LOGE("Error set stream class name: out-sc-addr=%p, "
                                "name=%s", out_stream_class, in_name);
                        ret = -1;
                        goto error;
@@ -319,7 +323,7 @@ int copy_stream_class_content(struct trace_ir_maps *ir_maps,
                status = bt_stream_class_set_packet_context_field_class(
                                out_stream_class, out_packet_context_fc);
                if (status !=  BT_STREAM_CLASS_STATUS_OK) {
-                       BT_LOGE("Error setting stream class' packet context "
+                       BT_COMP_LOGE("Error setting stream class' packet context "
                                "field class: sc-addr=%p, packet-fc-addr=%p",
                                out_stream_class, out_packet_context_fc);
                        ret = -1;
@@ -355,7 +359,7 @@ int copy_stream_class_content(struct trace_ir_maps *ir_maps,
                status = bt_stream_class_set_event_common_context_field_class(
                                out_stream_class, out_common_context_fc);
                if (status !=  BT_STREAM_CLASS_STATUS_OK) {
-                       BT_LOGE("Error setting stream class' packet context "
+                       BT_COMP_LOGE("Error setting stream class' packet context "
                                "field class: sc-addr=%p, packet-fc-addr=%p",
                                out_stream_class, out_common_context_fc);
                        ret = -1;
@@ -364,7 +368,7 @@ int copy_stream_class_content(struct trace_ir_maps *ir_maps,
        }
 
        /* Set packet snapshot boolean fields. */
-       BT_LOGD("Copied content of stream class: in-sc-addr=%p, out-sc-addr=%p",
+       BT_COMP_LOGD("Copied content of stream class: in-sc-addr=%p, out-sc-addr=%p",
                        in_stream_class, out_stream_class);
 error:
        return ret;
@@ -384,8 +388,9 @@ int copy_event_class_content(struct trace_ir_maps *ir_maps,
        const bt_field_class *in_event_specific_context, *in_event_payload;
        int ret = 0;
        bt_logging_level log_level = ir_maps->log_level;
+       bt_self_component *self_comp = ir_maps->self_comp;
 
-       BT_LOGD("Copying content of event class: in-ec-addr=%p, out-ec-addr=%p",
+       BT_COMP_LOGD("Copying content of event class: in-ec-addr=%p, out-ec-addr=%p",
                        in_event_class, out_event_class);
 
        /* Copy event class name. */
@@ -393,7 +398,7 @@ int copy_event_class_content(struct trace_ir_maps *ir_maps,
        if (in_event_class_name) {
                status = bt_event_class_set_name(out_event_class, in_event_class_name);
                if (status != BT_EVENT_CLASS_STATUS_OK) {
-                       BT_LOGE("Error setting event class' name: ec-addr=%p, "
+                       BT_COMP_LOGE("Error setting event class' name: ec-addr=%p, "
                                "name=%s", out_event_class, in_event_class_name);
                        ret = -1;
                        goto error;
@@ -413,7 +418,7 @@ int copy_event_class_content(struct trace_ir_maps *ir_maps,
        if (in_emf_uri) {
                status = bt_event_class_set_emf_uri(out_event_class, in_emf_uri);
                if (status != BT_EVENT_CLASS_STATUS_OK) {
-                       BT_LOGE("Error setting event class' emf uri: ec-addr=%p, "
+                       BT_COMP_LOGE("Error setting event class' emf uri: ec-addr=%p, "
                                "emf uri=%s", out_event_class, in_emf_uri);
                        ret = -1;
                        goto error;
@@ -449,7 +454,7 @@ int copy_event_class_content(struct trace_ir_maps *ir_maps,
                status = bt_event_class_set_specific_context_field_class(
                                out_event_class, out_specific_context_fc);
                if (status != BT_EVENT_CLASS_STATUS_OK) {
-                       BT_LOGE("Error setting event class' specific context "
+                       BT_COMP_LOGE("Error setting event class' specific context "
                                "field class: ec-addr=%p, ctx-fc-addr=%p",
                                out_event_class, out_specific_context_fc);
                        ret = -1;
@@ -480,7 +485,7 @@ int copy_event_class_content(struct trace_ir_maps *ir_maps,
                status = bt_event_class_set_payload_field_class(
                                out_event_class, out_payload_fc);
                if (status != BT_EVENT_CLASS_STATUS_OK) {
-                       BT_LOGE("Error setting event class' payload "
+                       BT_COMP_LOGE("Error setting event class' payload "
                                "field class: ec-addr=%p, payload-fc-addr=%p",
                                out_event_class, out_payload_fc);
                        ret = -1;
@@ -488,7 +493,7 @@ int copy_event_class_content(struct trace_ir_maps *ir_maps,
                }
        }
 
-       BT_LOGD("Copied content of event class: in-ec-addr=%p, out-ec-addr=%p",
+       BT_COMP_LOGD("Copied content of event class: in-ec-addr=%p, out-ec-addr=%p",
                        in_event_class, out_event_class);
 error:
        return ret;
@@ -506,8 +511,9 @@ int copy_event_common_context_field_class_content(
                       *func_field_class = NULL, *src_field_class = NULL;
        int ret = 0;
        bt_logging_level log_level = md_maps->log_level;
+       bt_self_component *self_comp = md_maps->self_comp;
 
-       BT_LOGD("Copying content of event common context field class: "
+       BT_COMP_LOGD("Copying content of event common context field class: "
                "in-fc-addr=%p, out-fc-addr=%p", in_field_class, out_field_class);
 
        /* Copy the content of the input common context. */
@@ -532,7 +538,7 @@ int copy_event_common_context_field_class_content(
                debug_field_class = bt_field_class_structure_create(
                                md_maps->output_trace_class);
                if (!debug_field_class) {
-                       BT_LOGE_STR("Failed to create debug_info structure.");
+                       BT_COMP_LOGE_STR("Failed to create debug_info structure.");
                        ret = -1;
                        goto error;
                }
@@ -540,7 +546,7 @@ int copy_event_common_context_field_class_content(
                bin_field_class = bt_field_class_string_create(
                                md_maps->output_trace_class);
                if (!bin_field_class) {
-                       BT_LOGE_STR("Failed to create string for field=bin.");
+                       BT_COMP_LOGE_STR("Failed to create string for field=bin.");
                        ret = -1;
                        goto error;
                }
@@ -548,7 +554,7 @@ int copy_event_common_context_field_class_content(
                func_field_class = bt_field_class_string_create(
                                md_maps->output_trace_class);
                if (!func_field_class) {
-                       BT_LOGE_STR("Failed to create string for field=func.");
+                       BT_COMP_LOGE_STR("Failed to create string for field=func.");
                        ret = -1;
                        goto error;
                }
@@ -556,7 +562,7 @@ int copy_event_common_context_field_class_content(
                src_field_class = bt_field_class_string_create(
                                md_maps->output_trace_class);
                if (!src_field_class) {
-                       BT_LOGE_STR("Failed to create string for field=src.");
+                       BT_COMP_LOGE_STR("Failed to create string for field=src.");
                        ret = -1;
                        goto error;
                }
@@ -564,7 +570,7 @@ int copy_event_common_context_field_class_content(
                status = bt_field_class_structure_append_member(
                                debug_field_class, "bin", bin_field_class);
                if (status != BT_FIELD_CLASS_STATUS_OK) {
-                       BT_LOGE_STR("Failed to add a field to debug_info "
+                       BT_COMP_LOGE_STR("Failed to add a field to debug_info "
                                        "struct: field=bin.");
                        ret = -1;
                        goto error;
@@ -574,7 +580,7 @@ int copy_event_common_context_field_class_content(
                status = bt_field_class_structure_append_member(
                                debug_field_class, "func", func_field_class);
                if (status != BT_FIELD_CLASS_STATUS_OK) {
-                       BT_LOGE_STR("Failed to add a field to debug_info "
+                       BT_COMP_LOGE_STR("Failed to add a field to debug_info "
                                        "struct: field=func.");
                        ret = -1;
                        goto error;
@@ -584,7 +590,7 @@ int copy_event_common_context_field_class_content(
                status = bt_field_class_structure_append_member(
                                debug_field_class, "src", src_field_class);
                if (status != BT_FIELD_CLASS_STATUS_OK) {
-                       BT_LOGE_STR("Failed to add a field to debug_info "
+                       BT_COMP_LOGE_STR("Failed to add a field to debug_info "
                                        "struct: field=src.");
                        ret = -1;
                        goto error;
@@ -596,14 +602,14 @@ int copy_event_common_context_field_class_content(
                                debug_info_fc_name,
                                debug_field_class);
                if (status != BT_FIELD_CLASS_STATUS_OK) {
-                       BT_LOGE_STR("Failed to add debug_info field to "
+                       BT_COMP_LOGE_STR("Failed to add debug_info field to "
                                        "event common context.");
                        ret = -1;
                        goto error;
                }
                BT_FIELD_CLASS_PUT_REF_AND_RESET(debug_field_class);
        }
-       BT_LOGD("Copied content of event common context field class: "
+       BT_COMP_LOGD("Copied content of event common context field class: "
                "in-fc-addr=%p, out-fc-addr=%p", in_field_class, out_field_class);
        goto end;
 
index 3904e3829ce99883f4e6cf83f23a5874b774932c..f08d071910e0f2284e6a129a0d53c83f3cde4aa1 100644 (file)
@@ -34,7 +34,8 @@
 BT_HIDDEN
 int copy_trace_class_content(const bt_trace_class *in_trace_class,
                bt_trace_class *out_trace_class,
-               bt_logging_level log_level);
+               bt_logging_level log_level,
+               bt_self_component *self_comp);
 
 BT_HIDDEN
 int copy_stream_class_content(struct trace_ir_maps *trace_ir_maps,
index 8d87f98193ddc56b5be28248630bafa98bfa5255..e1a1378874a02cabc5c9b8d75696272d31bb6533 100644 (file)
  * SOFTWARE.
  */
 
+#define BT_COMP_LOG_SELF_COMP (md_maps->self_comp)
 #define BT_LOG_OUTPUT_LEVEL (md_maps->log_level)
 #define BT_LOG_TAG "PLUGIN/FLT.LTTNG-UTILS.DEBUG-INFO/TRACE-IR-META-FC-COPY"
-#include "logging/log.h"
+#include "plugins/comp-logging.h"
 
 #include "common/assert.h"
 #include "common/common.h"
@@ -49,7 +50,7 @@ const bt_field_class *walk_field_path(struct trace_ir_metadata_maps *md_maps,
        const bt_field_class *curr_fc;
 
        BT_ASSERT(bt_field_class_get_type(fc) == BT_FIELD_CLASS_TYPE_STRUCTURE);
-       BT_LOGD("Walking field path on field class: fp-addr=%p, fc-addr=%p",
+       BT_COMP_LOGD("Walking field path on field class: fp-addr=%p, fc-addr=%p",
                        fp, fc);
 
        fp_item_count = bt_field_path_get_item_count(fp);
@@ -111,7 +112,7 @@ const bt_field_class *resolve_field_path_to_field_class(const bt_field_path *fp,
        const bt_field_class *fc;
        bt_scope fp_scope;
 
-       BT_LOGD("Resolving field path: fp-addr=%p", fp);
+       BT_COMP_LOGD("Resolving field path: fp-addr=%p", fp);
 
        fc_resolving_ctx = md_maps->fc_resolving_ctx;
        fp_scope = bt_field_path_get_root_scope(fp);
@@ -156,13 +157,13 @@ int field_class_unsigned_integer_copy(
                const bt_field_class *in_field_class,
                bt_field_class *out_field_class)
 {
-       BT_LOGD("Copying content of unsigned integer field class: "
+       BT_COMP_LOGD("Copying content of unsigned integer field class: "
                        "in-fc-addr=%p, out-fc-addr=%p",
                        in_field_class, out_field_class);
 
        field_class_integer_set_props(in_field_class, out_field_class);
 
-       BT_LOGD("Copied content of unsigned integer field class: "
+       BT_COMP_LOGD("Copied content of unsigned integer field class: "
                        "in-fc-addr=%p, out-fc-addr=%p",
                        in_field_class, out_field_class);
        return 0;
@@ -174,13 +175,13 @@ int field_class_signed_integer_copy(
                const bt_field_class *in_field_class,
                bt_field_class *out_field_class)
 {
-       BT_LOGD("Copying content of signed integer field class: "
+       BT_COMP_LOGD("Copying content of signed integer field class: "
                        "in-fc-addr=%p, out-fc-addr=%p",
                        in_field_class, out_field_class);
 
        field_class_integer_set_props(in_field_class, out_field_class);
 
-       BT_LOGD("Copied content of signed integer field class: "
+       BT_COMP_LOGD("Copied content of signed integer field class: "
                        "in-fc-addr=%p, out-fc-addr=%p",
                        in_field_class, out_field_class);
        return 0;
@@ -195,7 +196,7 @@ int field_class_unsigned_enumeration_copy(
        uint64_t i, enum_mapping_count;
        int ret = 0;
 
-       BT_LOGD("Copying content of unsigned enumeration field class: "
+       BT_COMP_LOGD("Copying content of unsigned enumeration field class: "
                        "in-fc-addr=%p, out-fc-addr=%p",
                        in_field_class, out_field_class);
 
@@ -231,7 +232,7 @@ int field_class_unsigned_enumeration_copy(
                        bt_field_class_unsigned_enumeration_mapping_get_range_by_index(
                                        u_mapping, range_index, &lower, &upper);
 
-                       BT_LOGD("Copying range in enumeration field class: "
+                       BT_COMP_LOGD("Copying range in enumeration field class: "
                                        "label=%s, lower=%"PRId64", upper=%"PRId64,
                                        label, lower, upper);
 
@@ -240,7 +241,7 @@ int field_class_unsigned_enumeration_copy(
                                        out_field_class, label, lower, upper);
 
                        if (status != BT_FIELD_CLASS_STATUS_OK) {
-                               BT_LOGE_STR("Failed to add range to unsigned "
+                               BT_COMP_LOGE_STR("Failed to add range to unsigned "
                                                "enumeration.");
                                BT_FIELD_CLASS_PUT_REF_AND_RESET(out_field_class);
                                ret = -1;
@@ -249,7 +250,7 @@ int field_class_unsigned_enumeration_copy(
                }
        }
 
-       BT_LOGD("Copied content of unsigned enumeration field class: "
+       BT_COMP_LOGD("Copied content of unsigned enumeration field class: "
                        "in-fc-addr=%p, out-fc-addr=%p",
                        in_field_class, out_field_class);
 
@@ -266,7 +267,7 @@ int field_class_signed_enumeration_copy(
        uint64_t i, enum_mapping_count;
        int ret = 0;
 
-       BT_LOGD("Copying content of signed enumeration field class: "
+       BT_COMP_LOGD("Copying content of signed enumeration field class: "
                        "in-fc-addr=%p, out-fc-addr=%p",
                        in_field_class, out_field_class);
 
@@ -303,7 +304,7 @@ int field_class_signed_enumeration_copy(
                        bt_field_class_signed_enumeration_mapping_get_range_by_index(
                                        i_mapping, range_index, &lower, &upper);
 
-                       BT_LOGD("Copying range in enumeration field class: "
+                       BT_COMP_LOGD("Copying range in enumeration field class: "
                                        "label=%s, lower=%"PRId64", upper=%"PRId64,
                                        label, lower, upper);
 
@@ -311,7 +312,7 @@ int field_class_signed_enumeration_copy(
                        status = bt_field_class_signed_enumeration_map_range(
                                        out_field_class, label, lower, upper);
                        if (status != BT_FIELD_CLASS_STATUS_OK) {
-                               BT_LOGE_STR("Failed to add range to signed "
+                               BT_COMP_LOGE_STR("Failed to add range to signed "
                                                "enumeration.");
                                BT_FIELD_CLASS_PUT_REF_AND_RESET(out_field_class);
                                ret = -1;
@@ -320,7 +321,7 @@ int field_class_signed_enumeration_copy(
                }
        }
 
-       BT_LOGD("Copied content of signed enumeration field class: "
+       BT_COMP_LOGD("Copied content of signed enumeration field class: "
                        "in-fc-addr=%p, out-fc-addr=%p",
                        in_field_class, out_field_class);
 
@@ -334,14 +335,14 @@ int field_class_real_copy(
                const bt_field_class *in_field_class,
                bt_field_class *out_field_class)
 {
-       BT_LOGD("Copying content of real field class: "
+       BT_COMP_LOGD("Copying content of real field class: "
                        "in-fc-addr=%p, out-fc-addr=%p",
                        in_field_class, out_field_class);
 
        bt_field_class_real_set_is_single_precision(out_field_class,
                        bt_field_class_real_is_single_precision(in_field_class));
 
-       BT_LOGD("Copied content real field class: in-fc-addr=%p, "
+       BT_COMP_LOGD("Copied content real field class: in-fc-addr=%p, "
                        "out-fc-addr=%p", in_field_class, out_field_class);
 
        return 0;
@@ -357,7 +358,7 @@ int field_class_structure_copy(
        bt_field_class_status status;
        int ret = 0;
 
-       BT_LOGD("Copying content of structure field class: "
+       BT_COMP_LOGD("Copying content of structure field class: "
                        "in-fc-addr=%p, out-fc-addr=%p",
                        in_field_class, out_field_class);
        /* Get the number of member in that struct. */
@@ -376,7 +377,7 @@ int field_class_structure_copy(
                member_fc = bt_field_class_structure_member_borrow_field_class_const(
                        member);
                member_name = bt_field_class_structure_member_get_name(member);
-               BT_LOGD("Copying structure field class's field: "
+               BT_COMP_LOGD("Copying structure field class's field: "
                        "index=%" PRId64 ", "
                        "member-fc-addr=%p, field-name=\"%s\"",
                        i, member_fc, member_name);
@@ -384,7 +385,7 @@ int field_class_structure_copy(
                out_member_field_class = create_field_class_copy(md_maps,
                                member_fc);
                if (!out_member_field_class) {
-                       BT_LOGE("Cannot copy structure field class's field: "
+                       BT_COMP_LOGE("Cannot copy structure field class's field: "
                                "index=%" PRId64 ", "
                                "field-fc-addr=%p, field-name=\"%s\"",
                                i, member_fc, member_name);
@@ -400,7 +401,7 @@ int field_class_structure_copy(
                status = bt_field_class_structure_append_member(out_field_class,
                                member_name, out_member_field_class);
                if (status != BT_FIELD_CLASS_STATUS_OK) {
-                       BT_LOGE("Cannot append structure field class's field: "
+                       BT_COMP_LOGE("Cannot append structure field class's field: "
                                "index=%" PRId64 ", "
                                "field-fc-addr=%p, field-name=\"%s\"",
                                i, member_fc, member_name);
@@ -410,7 +411,7 @@ int field_class_structure_copy(
                }
        }
 
-       BT_LOGD("Copied structure field class: original-fc-addr=%p, copy-fc-addr=%p",
+       BT_COMP_LOGD("Copied structure field class: original-fc-addr=%p, copy-fc-addr=%p",
                in_field_class, out_field_class);
 
 error:
@@ -429,7 +430,7 @@ int field_class_variant_copy(
        const bt_field_class *tag_fc;
        int ret = 0;
 
-       BT_LOGD("Copying content of variant field class: "
+       BT_COMP_LOGD("Copying content of variant field class: "
                        "in-fc-addr=%p, out-fc-addr=%p",
                        in_field_class, out_field_class);
 
@@ -442,7 +443,7 @@ int field_class_variant_copy(
                out_tag_field_class = g_hash_table_lookup(
                                md_maps->field_class_map, tag_fc);
                if (!out_tag_field_class) {
-                       BT_LOGE_STR("Cannot find the tag field class.");
+                       BT_COMP_LOGE_STR("Cannot find the tag field class.");
                        ret = -1;
                        goto error;
                }
@@ -467,14 +468,14 @@ int field_class_variant_copy(
                out_option_field_class = create_field_class_copy_internal(
                                md_maps, option_fc);
                if (!out_option_field_class) {
-                       BT_LOGE_STR("Cannot copy field class.");
+                       BT_COMP_LOGE_STR("Cannot copy field class.");
                        ret = -1;
                        goto error;
                }
                ret = copy_field_class_content_internal(md_maps, option_fc,
                                out_option_field_class);
                if (ret) {
-                       BT_LOGE_STR("Error copying content of option variant "
+                       BT_COMP_LOGE_STR("Error copying content of option variant "
                                        "field class'");
                        goto error;
                }
@@ -483,14 +484,14 @@ int field_class_variant_copy(
                                out_field_class, option_name,
                                out_option_field_class);
                if (status != BT_FIELD_CLASS_STATUS_OK) {
-                       BT_LOGE_STR("Cannot append option to variant field class'");
+                       BT_COMP_LOGE_STR("Cannot append option to variant field class'");
                        BT_FIELD_CLASS_PUT_REF_AND_RESET(out_tag_field_class);
                        ret = -1;
                        goto error;
                }
        }
 
-       BT_LOGD("Copied content of variant field class: in-fc-addr=%p, "
+       BT_COMP_LOGD("Copied content of variant field class: in-fc-addr=%p, "
                "out-fc-addr=%p", in_field_class, out_field_class);
 
 error:
@@ -503,13 +504,13 @@ int field_class_static_array_copy(
                const bt_field_class *in_field_class,
                bt_field_class *out_field_class)
 {
-       BT_LOGD("Copying content of static array field class: in-fc-addr=%p, "
+       BT_COMP_LOGD("Copying content of static array field class: in-fc-addr=%p, "
                        "out-fc-addr=%p", in_field_class, out_field_class);
        /*
         * There is no content to copy. Keep this function call anyway for
         * logging purposes.
         */
-       BT_LOGD("Copied content of static array field class: in-fc-addr=%p, "
+       BT_COMP_LOGD("Copied content of static array field class: in-fc-addr=%p, "
                        "out-fc-addr=%p", in_field_class, out_field_class);
 
        return 0;
@@ -527,7 +528,7 @@ int field_class_dynamic_array_copy(
        bt_field_class *out_len_field_class;
        int ret = 0;
 
-       BT_LOGD("Copying content of dynamic array field class: "
+       BT_COMP_LOGD("Copying content of dynamic array field class: "
                        "in-fc-addr=%p, out-fc-addr=%p",
                        in_field_class, out_field_class);
 
@@ -535,14 +536,14 @@ int field_class_dynamic_array_copy(
                        in_field_class);
 
        if (len_fp) {
-               BT_LOGD("Copying dynamic array length field class using "
+               BT_COMP_LOGD("Copying dynamic array length field class using "
                                "field path: in-len-fp=%p", len_fp);
                len_fc = resolve_field_path_to_field_class(
                                len_fp, md_maps);
                out_len_field_class = g_hash_table_lookup(
                                md_maps->field_class_map, len_fc);
                if (!out_len_field_class) {
-                       BT_LOGE_STR("Cannot find the output matching length"
+                       BT_COMP_LOGE_STR("Cannot find the output matching length"
                                        "field class.");
                        ret = -1;
                        goto error;
@@ -551,7 +552,7 @@ int field_class_dynamic_array_copy(
                status = bt_field_class_dynamic_array_set_length_field_class(
                                out_field_class, out_len_field_class);
                if (status != BT_FIELD_CLASS_STATUS_OK) {
-                       BT_LOGE_STR("Cannot set dynamic array field class' "
+                       BT_COMP_LOGE_STR("Cannot set dynamic array field class' "
                                        "length field class.");
                        BT_FIELD_CLASS_PUT_REF_AND_RESET(out_len_field_class);
                        ret = -1;
@@ -559,7 +560,7 @@ int field_class_dynamic_array_copy(
                }
        }
 
-       BT_LOGD("Copied dynamic array field class: in-fc-addr=%p, "
+       BT_COMP_LOGD("Copied dynamic array field class: in-fc-addr=%p, "
                        "out-fc-addr=%p", in_field_class, out_field_class);
 
 error:
@@ -571,13 +572,13 @@ int field_class_string_copy(struct trace_ir_metadata_maps *md_maps,
                const bt_field_class *in_field_class,
                bt_field_class *out_field_class)
 {
-       BT_LOGD("Copying content of string field class: in-fc-addr=%p, "
+       BT_COMP_LOGD("Copying content of string field class: in-fc-addr=%p, "
                        "out-fc-addr=%p", in_field_class, out_field_class);
        /*
         * There is no content to copy. Keep this function call anyway for
         * logging purposes.
         */
-       BT_LOGD("Copied content of string field class: in-fc-addr=%p, "
+       BT_COMP_LOGD("Copied content of string field class: in-fc-addr=%p, "
                        "out-fc-addr=%p", in_field_class, out_field_class);
 
        return 0;
@@ -591,7 +592,7 @@ bt_field_class *copy_field_class_array_element(struct trace_ir_metadata_maps *md
        bt_field_class *out_elem_fc =
                create_field_class_copy_internal(md_maps, in_elem_fc);
        if (!out_elem_fc) {
-               BT_LOGE("Error creating output elem field class "
+               BT_COMP_LOGE("Error creating output elem field class "
                                "from input elem field class for static array: "
                                "in-fc-addr=%p", in_elem_fc);
                goto error;
@@ -599,7 +600,7 @@ bt_field_class *copy_field_class_array_element(struct trace_ir_metadata_maps *md
 
        ret = copy_field_class_content_internal(md_maps, in_elem_fc, out_elem_fc);
        if (ret) {
-               BT_LOGE("Error creating output elem field class "
+               BT_COMP_LOGE("Error creating output elem field class "
                                "from input elem field class for static array: "
                                "in-fc-addr=%p", in_elem_fc);
                BT_FIELD_CLASS_PUT_REF_AND_RESET(out_elem_fc);
@@ -616,7 +617,7 @@ bt_field_class *create_field_class_copy_internal(struct trace_ir_metadata_maps *
 {
        bt_field_class *out_field_class = NULL;
 
-       BT_LOGD("Creating bare field class based on field class: in-fc-addr=%p",
+       BT_COMP_LOGD("Creating bare field class based on field class: in-fc-addr=%p",
                        in_field_class);
 
        switch(bt_field_class_get_type(in_field_class)) {
@@ -704,10 +705,10 @@ bt_field_class *create_field_class_copy_internal(struct trace_ir_metadata_maps *
 
 error:
        if(out_field_class){
-               BT_LOGD("Created bare field class based on field class: in-fc-addr=%p, "
+               BT_COMP_LOGD("Created bare field class based on field class: in-fc-addr=%p, "
                                "out-fc-addr=%p", in_field_class, out_field_class);
        } else {
-               BT_LOGE("Error creating output field class from input field "
+               BT_COMP_LOGE("Error creating output field class from input field "
                        "class: in-fc-addr=%p", in_field_class);
        }
 
index 4c2fdb09271fd237dfabd5d270438d3da7d69b43..86287494dad5bf4ed1d43a36063e13971896da82 100644 (file)
@@ -28,6 +28,7 @@ test_bin_info_LDADD = \
        $(top_builddir)/src/fd-cache/libbabeltrace2-fd-cache.la \
        $(top_builddir)/src/logging/libbabeltrace2-logging.la \
        $(top_builddir)/src/common/libbabeltrace2-common.la \
+       $(top_builddir)/src/lib/libbabeltrace2.la \
        $(ELFUTILS_LIBS) \
        $(LIBTAP)
 test_bin_info_SOURCES = test_bin_info.c
index 990fc6b7483ccfb99584bacafbd0ab2f0805bf5d..36bfd7f04292cd113f6f111b3a2505c2fd2d9e5e 100644 (file)
@@ -234,7 +234,7 @@ void test_bin_info_build_id(const char *bin_info_dir)
        }
 
        bin = bin_info_create(&fdc, bin_path, SO_LOW_ADDR, SO_MEMSZ, true,
-                             data_dir, NULL, BT_LOG_OUTPUT_LEVEL);
+                             data_dir, NULL, BT_LOG_OUTPUT_LEVEL, NULL);
        ok(bin != NULL, "bin_info_create successful (%s)", bin_path);
 
        /* Test setting invalid build_id */
@@ -288,7 +288,7 @@ void test_bin_info_debug_link(const char *bin_info_dir)
        }
 
        bin = bin_info_create(&fdc, bin_path, SO_LOW_ADDR, SO_MEMSZ, true,
-                             data_dir, NULL, BT_LOG_OUTPUT_LEVEL);
+               data_dir, NULL, BT_LOG_OUTPUT_LEVEL, NULL);
        ok(bin != NULL, "bin_info_create successful (%s)", bin_path);
 
        /* Test setting debug link */
@@ -338,7 +338,7 @@ void test_bin_info_elf(const char *bin_info_dir)
        }
 
        bin = bin_info_create(&fdc, bin_path, SO_LOW_ADDR, SO_MEMSZ, true,
-                             data_dir, NULL, BT_LOG_OUTPUT_LEVEL);
+               data_dir, NULL, BT_LOG_OUTPUT_LEVEL, NULL);
        ok(bin != NULL, "bin_info_create successful (%s)", bin_path);
 
        /* Test bin_info_has_address */
@@ -386,7 +386,7 @@ void test_bin_info_bundled(const char *bin_info_dir)
        }
 
        bin = bin_info_create(&fdc, bin_path, SO_LOW_ADDR, SO_MEMSZ, true,
-                             data_dir, NULL, BT_LOG_OUTPUT_LEVEL);
+               data_dir, NULL, BT_LOG_OUTPUT_LEVEL, NULL);
        ok(bin != NULL, "bin_info_create successful (%s)", bin_path);
 
        /* Test bin_info_has_address */
@@ -439,7 +439,7 @@ int main(int argc, char **argv)
 
        plan_tests(NR_TESTS);
 
-       ret = bin_info_init(BT_LOG_OUTPUT_LEVEL);
+       ret = bin_info_init(BT_LOG_OUTPUT_LEVEL, NULL);
        ok(ret == 0, "bin_info_init successful");
 
        test_bin_info_elf(opt_debug_info_dir);
This page took 0.067708 seconds and 4 git commands to generate.