flt.lttng-utils.debug-info: honor component's initial log level
authorPhilippe Proulx <eeppeliteloop@gmail.com>
Mon, 17 Jun 2019 05:45:14 +0000 (01:45 -0400)
committerPhilippe Proulx <eeppeliteloop@gmail.com>
Thu, 20 Jun 2019 18:01:16 +0000 (14:01 -0400)
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I49d4f5ecbdcc546c511e2469581db4f0e785a54a
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1479
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Francis Deslauriers <francis.deslauriers@efficios.com>
15 files changed:
src/cli/babeltrace2.c
src/plugins/lttng-utils/debug-info/Makefile.am
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/logging.c [deleted file]
src/plugins/lttng-utils/debug-info/logging.h [deleted file]
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/test_bin_info.c

index 0a3cb5b9f0a0240e0ed3e40f3aa15b7c7d185496..db2ed837ca893c83ae5ab87ba5f9ee3d5f054dbd 100644 (file)
@@ -49,7 +49,6 @@
  * modules.
  */
 static const char* log_level_env_var_names[] = {
-       "BABELTRACE_FLT_LTTNG_UTILS_DEBUG_INFO_LOG_LEVEL",
        "BABELTRACE_PLUGIN_CTF_BFCR_LOG_LEVEL",
        "BABELTRACE_PLUGIN_CTF_METADATA_LOG_LEVEL",
        "BABELTRACE_PLUGIN_CTF_MSG_ITER_LOG_LEVEL",
index a231785bfa86434ed69be44daa76b1957de9ff63..f9c353cadfbbb5c79880a910de6ad2328d9fa6d6 100644 (file)
@@ -12,8 +12,6 @@ libdebug_info_la_SOURCES = \
        debug-info.h \
        dwarf.c \
        dwarf.h \
-       logging.c \
-       logging.h \
        trace-ir-data-copy.c \
        trace-ir-data-copy.h \
        trace-ir-mapping.c \
index cbf9310a079a10d1fd11e5fea522c687cd4a301a..20ed40a799506c70f7ed8a962279cb51a1b8d8cb 100644 (file)
  * SOFTWARE.
  */
 
+#define BT_LOG_OUTPUT_LEVEL (bin->log_level)
 #define BT_LOG_TAG "PLUGIN/FLT.LTTNG-UTILS.DEBUG-INFO/BIN-INFO"
-#include "logging.h"
+#include "logging/log.h"
 
+#include <babeltrace2/logging.h>
 #include <dwarf.h>
 #include <errno.h>
 #include <fcntl.h>
 #define BUILD_ID_NOTE_NAME "GNU"
 
 BT_HIDDEN
-int bin_info_init(void)
+int bin_info_init(bt_logging_level log_level)
 {
        int ret = 0;
 
        if (elf_version(EV_CURRENT) == EV_NONE) {
-               BT_LOGI("ELF library initialization failed: %s.",
+               BT_LOG_WRITE_CUR_LVL(BT_LOG_INFO, log_level, BT_LOG_TAG,
+                       "ELF library initialization failed: %s.",
                        elf_errmsg(-1));
                ret = -1;
        }
@@ -74,7 +77,8 @@ int bin_info_init(void)
 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)
+               const char *debug_info_dir, const char *target_prefix,
+               bt_logging_level log_level)
 {
        struct bin_info *bin = NULL;
 
@@ -89,6 +93,7 @@ struct bin_info *bin_info_create(struct bt_fd_cache *fdc, const char *path,
                goto error;
        }
 
+       bin->log_level = log_level;
        if (target_prefix) {
                bin->elf_path = g_build_filename(target_prefix, path, NULL);
        } else {
index 00a6e4e0182a1155fed08a48dad64d8db62f2dce..98d7fd1f48eed58fca6573e10a57cc4d86754ad2 100644 (file)
@@ -27,6 +27,7 @@
  * SOFTWARE.
  */
 
+#include <babeltrace2/logging.h>
 #include <stdint.h>
 #include <stdbool.h>
 #include <gelf.h>
@@ -41,6 +42,8 @@
 #define BUILD_ID_PREFIX_DIR_LEN 2
 
 struct bin_info {
+       bt_logging_level log_level;
+
        /* Base virtual memory address. */
        uint64_t low_addr;
        /* Upper bound of exec address space. */
@@ -90,7 +93,7 @@ struct source_location {
  * @returns            0 on success, -1 on failure
  */
 BT_HIDDEN
-int bin_info_init(void);
+int bin_info_init(bt_logging_level log_level);
 
 /**
  * Instantiate a structure representing an ELF executable, possibly
@@ -110,7 +113,8 @@ int bin_info_init(void);
 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);
+               const char *debug_info_dir, const char *target_prefix,
+               bt_logging_level log_level);
 
 /**
  * Destroy the given bin_info instance
index 9f6f0968953e7eb815d90012e6379b24b0eada27..583f779f5a8a4c0fdbee29839efaf9ae24b21aa5 100644 (file)
@@ -26,8 +26,9 @@
  * SOFTWARE.
  */
 
+#define BT_LOG_OUTPUT_LEVEL log_level
 #define BT_LOG_TAG "PLUGIN/FLT.LTTNG-UTILS.DEBUG-INFO"
-#include "logging.h"
+#include "logging/log.h"
 
 #include <glib.h>
 
@@ -55,6 +56,7 @@
 #define PATH_FIELD_NAME                        "path"
 
 struct debug_info_component {
+       bt_logging_level log_level;
        gchar *arg_debug_dir;
        gchar *arg_debug_info_field_name;
        gchar *arg_target_prefix;
@@ -62,6 +64,7 @@ struct debug_info_component {
 };
 
 struct debug_info_msg_iter {
+       bt_logging_level log_level;
        struct debug_info_component *debug_info_component;
        bt_self_message_iterator *input_iterator;
        bt_self_component *self_comp;
@@ -110,6 +113,7 @@ struct proc_debug_info_sources {
 };
 
 struct debug_info {
+       bt_logging_level log_level;
        struct debug_info_component *comp;
        const bt_trace *input_trace;
        uint64_t destruction_listener_id;
@@ -144,7 +148,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();
+       return bin_info_init(info->log_level);
 }
 
 static
@@ -169,6 +173,7 @@ struct debug_info_source *debug_info_source_create_from_bin(
        int ret;
        struct debug_info_source *debug_info_src = NULL;
        struct source_location *src_loc = NULL;
+       bt_logging_level log_level = bin->log_level;
 
        debug_info_src = g_new0(struct debug_info_source, 1);
 
@@ -439,6 +444,7 @@ bool event_has_payload_field(const bt_event *event,
 
 static
 struct debug_info_source *proc_debug_info_sources_get_entry(
+               struct debug_info *debug_info,
                struct proc_debug_info_sources *proc_dbg_info_src, uint64_t ip)
 {
        struct debug_info_source *debug_info_src = NULL;
@@ -507,7 +513,8 @@ struct debug_info_source *debug_info_query(struct debug_info *debug_info,
                goto end;
        }
 
-       dbg_info_src = proc_debug_info_sources_get_entry(proc_dbg_info_src, ip);
+       dbg_info_src = proc_debug_info_sources_get_entry(debug_info,
+               proc_dbg_info_src, ip);
 
 end:
        return dbg_info_src;
@@ -529,6 +536,7 @@ struct debug_info *debug_info_create(struct debug_info_component *comp,
                goto end;
        }
 
+       debug_info->log_level = comp->log_level;
        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);
@@ -555,11 +563,14 @@ error:
 static
 void debug_info_destroy(struct debug_info *debug_info)
 {
+       bt_logging_level log_level;
        bt_trace_status status;
        if (!debug_info) {
                goto end;
        }
 
+       log_level = debug_info->log_level;
+
        if (debug_info->vpid_to_proc_dbg_info_src) {
                g_hash_table_destroy(debug_info->vpid_to_proc_dbg_info_src);
        }
@@ -753,7 +764,8 @@ 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->comp->arg_target_prefix,
+               debug_info->log_level);
        if (!bin) {
                goto end;
        }
@@ -926,7 +938,8 @@ 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)
+               bool full_path, bt_field *curr_field,
+               bt_logging_level log_level)
 {
        bt_field_status status;
 
@@ -964,7 +977,7 @@ 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_field *curr_field, bt_logging_level log_level)
 {
        bt_field_status status;
 
@@ -984,7 +997,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)
+               bool full_path, bt_field *curr_field,
+               bt_logging_level log_level)
 {
        bt_field_status status;
 
@@ -1027,7 +1041,9 @@ void fill_debug_info_src_field(struct debug_info_source *dbg_info_src,
        }
 }
 
-void fill_debug_info_field_empty(bt_field *debug_info_field)
+static
+void fill_debug_info_field_empty(bt_field *debug_info_field,
+               bt_logging_level log_level)
 {
        bt_field_status status;
        bt_field *bin_field, *func_field, *src_field;
@@ -1083,15 +1099,20 @@ void fill_debug_info_field(struct debug_info *debug_info, int64_t vpid,
 
        dbg_info_src = debug_info_query(debug_info, vpid, ip);
 
-       fill_debug_info_bin_field(dbg_info_src, debug_info->comp->arg_full_path,
-                       bt_field_structure_borrow_member_field_by_name(
-                               debug_info_field, "bin"));
+       fill_debug_info_bin_field(dbg_info_src,
+               debug_info->comp->arg_full_path,
+               bt_field_structure_borrow_member_field_by_name(
+                       debug_info_field, "bin"),
+               debug_info->log_level);
        fill_debug_info_func_field(dbg_info_src,
-                       bt_field_structure_borrow_member_field_by_name(
-                               debug_info_field, "func"));
-       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"));
+               bt_field_structure_borrow_member_field_by_name(
+                       debug_info_field, "func"),
+               debug_info->log_level);
+       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);
 }
 
 static
@@ -1106,6 +1127,7 @@ void fill_debug_info_event_if_needed(struct debug_info_msg_iter *debug_it,
        int64_t ip;
        gchar *debug_info_field_name =
                debug_it->debug_info_component->arg_debug_info_field_name;
+       bt_logging_level log_level = debug_it->log_level;
 
        in_common_ctx_field = bt_event_borrow_common_context_field_const(
                        in_event);
@@ -1161,7 +1183,7 @@ void fill_debug_info_event_if_needed(struct debug_info_msg_iter *debug_it,
        } else {
                BT_LOGD("No debug information for this trace. Setting debug "
                        "info fields to empty strings.");
-               fill_debug_info_field_empty(out_debug_info_field);
+               fill_debug_info_field_empty(out_debug_info_field, log_level);
        }
 end:
        return;
@@ -1209,6 +1231,7 @@ bt_message *handle_event_message(struct debug_info_msg_iter *debug_it,
        bt_event_class *out_event_class;
        bt_packet *out_packet;
        bt_event *out_event;
+       bt_logging_level log_level = debug_it->log_level;
 
        bt_message *out_message = NULL;
 
@@ -1258,7 +1281,7 @@ bt_message *handle_event_message(struct debug_info_msg_iter *debug_it,
        out_event = bt_message_event_borrow_event(out_message);
 
        /* Copy the original fields to the output event. */
-       copy_event_content(in_event, out_event);
+       copy_event_content(in_event, out_event, log_level);
 
        /*
         * Try to set the debug-info fields based on debug information that is
@@ -1277,6 +1300,7 @@ bt_message *handle_stream_begin_message(struct debug_info_msg_iter *debug_it,
        const bt_stream *in_stream;
        bt_message *out_message;
        bt_stream *out_stream;
+       bt_logging_level log_level = debug_it->log_level;
 
        in_stream = bt_message_stream_beginning_borrow_stream_const(in_message);
        BT_ASSERT(in_stream);
@@ -1307,6 +1331,7 @@ bt_message *handle_stream_end_message(struct debug_info_msg_iter *debug_it,
        const bt_stream *in_stream;
        bt_message *out_message = NULL;
        bt_stream *out_stream;
+       bt_logging_level log_level = debug_it->log_level;
 
        in_stream = bt_message_stream_end_borrow_stream_const(in_message);
        BT_ASSERT(in_stream);
@@ -1337,6 +1362,7 @@ bt_message *handle_packet_begin_message(struct debug_info_msg_iter *debug_it,
        const bt_clock_snapshot *cs;
        bt_message *out_message = NULL;
        bt_packet *out_packet;
+       bt_logging_level log_level = debug_it->log_level;
 
        const bt_packet *in_packet =
                bt_message_packet_beginning_borrow_packet_const(in_message);
@@ -1385,6 +1411,7 @@ bt_message *handle_packet_end_message(struct debug_info_msg_iter *debug_it,
        const bt_packet *in_packet;
        bt_message *out_message = NULL;
        bt_packet *out_packet;
+       bt_logging_level log_level = debug_it->log_level;
 
        in_packet = bt_message_packet_end_borrow_packet_const(in_message);
        BT_ASSERT(in_packet);
@@ -1443,6 +1470,7 @@ bt_message *handle_stream_act_begin_message(struct debug_info_msg_iter *debug_it
        bt_stream *out_stream;
        uint64_t cs_value;
        bt_message_stream_activity_clock_snapshot_state cs_state;
+       bt_logging_level log_level = debug_it->log_level;
 
        const bt_stream *in_stream =
                bt_message_stream_activity_beginning_borrow_stream_const(
@@ -1494,6 +1522,7 @@ bt_message *handle_stream_act_end_message(struct debug_info_msg_iter *debug_it,
        bt_stream *out_stream;
        uint64_t cs_value;
        bt_message_stream_activity_clock_snapshot_state cs_state;
+       bt_logging_level log_level = debug_it->log_level;
 
        in_stream = bt_message_stream_activity_end_borrow_stream_const(
                        in_message);
@@ -1544,6 +1573,7 @@ bt_message *handle_discarded_events_message(struct debug_info_msg_iter *debug_it
        bt_property_availability prop_avail;
        bt_message *out_message = NULL;
        bt_stream *out_stream;
+       bt_logging_level log_level = debug_it->log_level;
 
        in_stream = bt_message_discarded_events_borrow_stream_const(
                        in_message);
@@ -1604,6 +1634,7 @@ bt_message *handle_discarded_packets_message(struct debug_info_msg_iter *debug_i
        bt_property_availability prop_avail;
        bt_message *out_message = NULL;
        bt_stream *out_stream;
+       bt_logging_level log_level = debug_it->log_level;
 
        in_stream = bt_message_discarded_packets_borrow_stream_const(
                        in_message);
@@ -1761,6 +1792,9 @@ bt_self_component_status debug_info_comp_init(
        int ret;
        struct debug_info_component *debug_info_comp;
        bt_self_component_status status = BT_SELF_COMPONENT_STATUS_OK;
+       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_LOGI("Initializing debug_info component: "
                "comp-addr=%p, params-addr=%p", self_comp, params);
@@ -1771,9 +1805,10 @@ bt_self_component_status debug_info_comp_init(
                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);
+               bt_self_component_filter_as_self_component(self_comp),
+               debug_info_comp);
 
        status = bt_self_component_filter_add_input_port(self_comp, "in",
                        NULL, NULL);
@@ -1817,6 +1852,8 @@ void debug_info_comp_finalize(bt_self_component_filter *self_comp)
                bt_self_component_get_data(
                                bt_self_component_filter_as_self_component(
                                        self_comp));
+       bt_logging_level log_level = debug_info->log_level;
+
        BT_LOGI("Finalizing debug_info self_component: comp-addr=%p",
                self_comp);
 
@@ -1942,6 +1979,9 @@ 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_logging_level log_level = bt_component_get_logging_level(
+               bt_self_component_as_component(
+                       bt_self_component_filter_as_self_component(self_comp)));
 
        /* Borrow the upstream input port. */
        input_port = bt_self_component_filter_borrow_input_port_by_name(
@@ -1957,6 +1997,8 @@ bt_self_message_iterator_status debug_info_msg_iter_init(
                goto error;
        }
 
+       debug_info_msg_iter->log_level = log_level;
+
        /* Create an iterator on the upstream component. */
        upstream_iterator = bt_self_component_port_input_message_iterator_create(
                input_port);
@@ -1989,14 +2031,13 @@ bt_self_message_iterator_status debug_info_msg_iter_init(
 
        debug_info_msg_iter->ir_maps = trace_ir_maps_create(
                bt_self_component_filter_as_self_component(self_comp),
-               debug_info_field_name);
+               debug_info_field_name, log_level);
        if (!debug_info_msg_iter->ir_maps) {
                status = BT_SELF_MESSAGE_ITERATOR_STATUS_NOMEM;
                goto error;
        }
 
-       ret = bt_fd_cache_init(&debug_info_msg_iter->fd_cache,
-               BT_LOG_OUTPUT_LEVEL);
+       ret = bt_fd_cache_init(&debug_info_msg_iter->fd_cache, log_level);
        if (ret) {
                status = BT_SELF_MESSAGE_ITERATOR_STATUS_NOMEM;
                goto error;
diff --git a/src/plugins/lttng-utils/debug-info/logging.c b/src/plugins/lttng-utils/debug-info/logging.c
deleted file mode 100644 (file)
index a872d57..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Copyright (c) 2017 Philippe Proulx <pproulx@efficios.com>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#define BT_LOG_OUTPUT_LEVEL bt_plugin_lttng_utils_debug_info_log_level
-#include "logging/log.h"
-
-BT_LOG_INIT_LOG_LEVEL(bt_plugin_lttng_utils_debug_info_log_level,
-       "BABELTRACE_FLT_LTTNG_UTILS_DEBUG_INFO_LOG_LEVEL");
diff --git a/src/plugins/lttng-utils/debug-info/logging.h b/src/plugins/lttng-utils/debug-info/logging.h
deleted file mode 100644 (file)
index fa298d5..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-#ifndef PLUGINS_LTTNG_UTILS_DEBUG_INFO_LOGGING_H
-#define PLUGINS_LTTNG_UTILS_DEBUG_INFO_LOGGING_H
-
-/*
- * Copyright (c) 2017 Philippe Proulx <pproulx@efficios.com>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#define BT_LOG_OUTPUT_LEVEL bt_plugin_lttng_utils_debug_info_log_level
-#include "logging/log.h"
-
-BT_LOG_LEVEL_EXTERN_SYMBOL(bt_plugin_lttng_utils_debug_info_log_level);
-
-#endif /* PLUGINS_LTTNG_UTILS_DEBUG_INFO_LOGGING_H */
index 880a942af03a672448f609f3e438d7dbe77d864c..fb0d0c128ed022f71db65736f1eb01d177390dc7 100644 (file)
@@ -23,8 +23,9 @@
  * SOFTWARE.
  */
 
+#define BT_LOG_OUTPUT_LEVEL log_level
 #define BT_LOG_TAG "PLUGIN/FLT.LTTNG-UTILS.DEBUG-INFO/TRACE-IR-DATA-COPY"
-#include "logging.h"
+#include "logging/log.h"
 
 #include <inttypes.h>
 #include <stdint.h>
@@ -34,7 +35,8 @@
 #include "trace-ir-data-copy.h"
 
 BT_HIDDEN
-void copy_trace_content(const bt_trace *in_trace, bt_trace *out_trace)
+void copy_trace_content(const bt_trace *in_trace, bt_trace *out_trace,
+               bt_logging_level log_level)
 {
        bt_trace_status status;
        const char *trace_name;
@@ -60,7 +62,8 @@ end:
 }
 
 BT_HIDDEN
-void copy_stream_content(const bt_stream *in_stream, bt_stream *out_stream)
+void copy_stream_content(const bt_stream *in_stream, bt_stream *out_stream,
+               bt_logging_level log_level)
 {
        const char *stream_name;
        bt_stream_status status;
@@ -85,7 +88,8 @@ end:
 }
 
 BT_HIDDEN
-void copy_packet_content(const bt_packet *in_packet, bt_packet *out_packet)
+void copy_packet_content(const bt_packet *in_packet, bt_packet *out_packet,
+               bt_logging_level log_level)
 {
        const bt_field *in_context_field;
        bt_field *out_context_field;
@@ -98,7 +102,8 @@ void copy_packet_content(const bt_packet *in_packet, bt_packet *out_packet)
        if (in_context_field) {
                out_context_field = bt_packet_borrow_context_field(out_packet);
                BT_ASSERT(out_context_field);
-               copy_field_content(in_context_field, out_context_field);
+               copy_field_content(in_context_field, out_context_field,
+                       log_level);
        }
 
        BT_LOGD("Copied content of packet: in-p-addr=%p, out-p-addr=%p",
@@ -107,7 +112,8 @@ void copy_packet_content(const bt_packet *in_packet, bt_packet *out_packet)
 }
 
 BT_HIDDEN
-void copy_event_content(const bt_event *in_event, bt_event *out_event)
+void copy_event_content(const bt_event *in_event, bt_event *out_event,
+               bt_logging_level log_level)
 {
        const bt_field *in_common_ctx_field, *in_specific_ctx_field,
              *in_payload_field;
@@ -123,7 +129,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);
+                               out_common_ctx_field, log_level);
        }
 
        in_specific_ctx_field =
@@ -133,7 +139,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);
+                               out_specific_ctx_field, log_level);
        }
 
        in_payload_field = bt_event_borrow_payload_field_const(in_event);
@@ -141,7 +147,7 @@ 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);
+                               out_payload_field, log_level);
        }
 
        BT_LOGD("Copied content of event: in-e-addr=%p, out-e-addr=%p",
@@ -149,7 +155,8 @@ void copy_event_content(const bt_event *in_event, bt_event *out_event)
 }
 
 BT_HIDDEN
-void copy_field_content(const bt_field *in_field, bt_field *out_field)
+void copy_field_content(const bt_field *in_field, bt_field *out_field,
+               bt_logging_level log_level)
 {
        bt_field_class_type in_fc_type, out_fc_type;
 
@@ -218,7 +225,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);
+                                       out_member_field, log_level);
                }
                break;
        }
@@ -250,7 +257,8 @@ void copy_field_content(const bt_field *in_field, bt_field *out_field)
                        out_element_field =
                                bt_field_array_borrow_element_field_by_index(
                                                out_field, i);
-                       copy_field_content(in_element_field, out_element_field);
+                       copy_field_content(in_element_field, out_element_field,
+                               log_level);
                }
                break;
        }
@@ -275,7 +283,8 @@ void copy_field_content(const bt_field *in_field, bt_field *out_field)
                in_option_field = bt_field_variant_borrow_selected_option_field_const(in_field);
                out_option_field = bt_field_variant_borrow_selected_option_field(out_field);
 
-               copy_field_content(in_option_field, out_option_field);
+               copy_field_content(in_option_field, out_option_field,
+                       log_level);
 
                break;
        }
index ddb1b89ddaccae8ed3ea6b4129603b26a8d479db..cc941945b7a8ff89f6564c39276d65d568046209 100644 (file)
 #include "trace-ir-mapping.h"
 
 BT_HIDDEN
-void copy_trace_content(const bt_trace *in_trace, bt_trace *out_trace);
+void copy_trace_content(const bt_trace *in_trace, bt_trace *out_trace,
+               bt_logging_level log_level);
 BT_HIDDEN
-void copy_stream_content(const bt_stream *in_stream, bt_stream *out_stream);
+void copy_stream_content(const bt_stream *in_stream, bt_stream *out_stream,
+               bt_logging_level log_level);
 BT_HIDDEN
-void copy_packet_content(const bt_packet *in_packet, bt_packet *out_packet);
+void copy_packet_content(const bt_packet *in_packet, bt_packet *out_packet,
+               bt_logging_level log_level);
 BT_HIDDEN
-void copy_event_content(const bt_event *in_event, bt_event *out_event);
+void copy_event_content(const bt_event *in_event, bt_event *out_event,
+               bt_logging_level log_level);
 BT_HIDDEN
-void copy_field_content(const bt_field *in_field, bt_field *out_field);
+void copy_field_content(const bt_field *in_field, bt_field *out_field,
+               bt_logging_level log_level);
 
 #endif /* BABELTRACE_PLUGIN_DEBUG_INFO_TRACE_DATA_COPY_H */
index 19a03f279b28f7439b4d9288fb542a388036910e..cb73727bf2669ab674c07b4c7ae3e207e8c20fdb 100644 (file)
@@ -25,8 +25,9 @@
  * SOFTWARE.
  */
 
+#define BT_LOG_OUTPUT_LEVEL (ir_maps->log_level)
 #define BT_LOG_TAG "PLUGIN/FLT.LTTNG-UTILS.DEBUG-INFO/TRACE-IR-MAPPING"
-#include "logging.h"
+#include "logging/log.h"
 
 #include <stdbool.h>
 
@@ -60,7 +61,8 @@ bt_trace_class *create_new_mapped_trace_class(struct trace_ir_maps *ir_maps,
        }
 
        /* If not, create a new one and add it to the mapping. */
-       ret = copy_trace_class_content(in_trace_class, out_trace_class);
+       ret = copy_trace_class_content(in_trace_class, out_trace_class,
+               ir_maps->log_level);
        if (ret) {
                BT_LOGE_STR("Error copy content to output trace class");
                out_trace_class = NULL;
@@ -106,7 +108,7 @@ bt_trace *create_new_mapped_trace(struct trace_ir_maps *ir_maps,
        }
 
        /* If not, create a new one and add it to the mapping. */
-       copy_trace_content(in_trace, out_trace);
+       copy_trace_content(in_trace, out_trace, ir_maps->log_level);
 
        BT_LOGD("Created new mapped trace: in-t-addr=%p, out-t-addr=%p",
                        in_trace, out_trace);
@@ -193,10 +195,9 @@ bt_stream *trace_ir_mapping_create_new_mapped_stream(
        bt_stream_class *out_stream_class;
        bt_stream *out_stream = NULL;
 
-       BT_LOGD("Creating new mapped stream: in-s-addr=%p", in_stream);
-
        BT_ASSERT(ir_maps);
        BT_ASSERT(in_stream);
+       BT_LOGD("Creating new mapped stream: in-s-addr=%p", in_stream);
 
        in_trace = bt_stream_borrow_trace_const(in_stream);
 
@@ -234,7 +235,7 @@ bt_stream *trace_ir_mapping_create_new_mapped_stream(
         * time of the stream objects.
         */
 
-       copy_stream_content(in_stream, out_stream);
+       copy_stream_content(in_stream, out_stream, ir_maps->log_level);
 
        g_hash_table_insert(d_maps->stream_map, (gpointer) in_stream,
                        out_stream);
@@ -279,11 +280,10 @@ bt_event_class *trace_ir_mapping_create_new_mapped_event_class(
        struct trace_ir_metadata_maps *md_maps;
        int ret;
 
-       BT_LOGD("Creating new mapped event class: in-ec-addr=%p",
-                       in_event_class);
-
        BT_ASSERT(ir_maps);
        BT_ASSERT(in_event_class);
+       BT_LOGD("Creating new mapped event class: in-ec-addr=%p",
+                       in_event_class);
 
        in_trace_class = bt_stream_class_borrow_trace_class_const(
                                bt_event_class_borrow_stream_class_const(
@@ -392,7 +392,7 @@ 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);
+       copy_packet_content(in_packet, out_packet, ir_maps->log_level);
 
        g_hash_table_insert(d_maps->packet_map,
                        (gpointer) in_packet, out_packet);
@@ -485,6 +485,7 @@ struct trace_ir_data_maps *trace_ir_data_maps_create(struct trace_ir_maps *ir_ma
                goto error;
        }
 
+       d_maps->log_level = ir_maps->log_level;
        d_maps->input_trace = in_trace;
 
        /* Create the hashtables used to map data objects. */
@@ -510,6 +511,7 @@ struct trace_ir_metadata_maps *trace_ir_metadata_maps_create(
                goto error;
        }
 
+       md_maps->log_level = ir_maps->log_level;
        md_maps->input_trace_class = in_trace_class;
        /*
         * Create the field class resolving context. This is needed to keep
@@ -563,7 +565,9 @@ 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_LOGD("Trace destruction listener removal failed.");
+               BT_LOG_WRITE_CUR_LVL(BT_LOG_DEBUG, maps->log_level,
+                       BT_LOG_TAG,
+                       "Trace destruction listener removal failed.");
        }
 
        g_free(maps);
@@ -604,7 +608,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_LOGD("Trace destruction listener removal failed.");
+               BT_LOG_WRITE_CUR_LVL(BT_LOG_DEBUG, maps->log_level, BT_LOG_TAG,
+                       "Trace destruction listener removal failed.");
        }
 
        g_free(maps);
@@ -647,37 +652,40 @@ void trace_ir_maps_destroy(struct trace_ir_maps *maps)
 
 BT_HIDDEN
 struct trace_ir_maps *trace_ir_maps_create(bt_self_component *self_comp,
-               const char *debug_info_field_name)
+               const char *debug_info_field_name, bt_logging_level log_level)
 {
-       struct trace_ir_maps *trace_ir_maps =
+       struct trace_ir_maps *ir_maps =
                g_new0(struct trace_ir_maps, 1);
-       if (!trace_ir_maps) {
-               BT_LOGE_STR("Error allocating trace_ir_maps");
+       if (!ir_maps) {
+               BT_LOG_WRITE_CUR_LVL(BT_LOG_ERROR, log_level, BT_LOG_TAG,
+                       "Error allocating trace_ir_maps");
                goto error;
        }
 
+       ir_maps->log_level = log_level;
+
        /* Copy debug info field name received from the user. */
-       trace_ir_maps->debug_info_field_class_name =
+       ir_maps->debug_info_field_class_name =
                g_strdup(debug_info_field_name);
-       if (!trace_ir_maps->debug_info_field_class_name) {
+       if (!ir_maps->debug_info_field_class_name) {
                BT_LOGE_STR("Cannot copy debug info field name");
                goto error;
        }
 
-       trace_ir_maps->self_comp = self_comp;
+       ir_maps->self_comp = self_comp;
 
-       trace_ir_maps->data_maps = g_hash_table_new_full(g_direct_hash,
+       ir_maps->data_maps = g_hash_table_new_full(g_direct_hash,
                        g_direct_equal, (GDestroyNotify) NULL,
                        (GDestroyNotify) trace_ir_data_maps_destroy);
 
-       trace_ir_maps->metadata_maps = g_hash_table_new_full(g_direct_hash,
+       ir_maps->metadata_maps = g_hash_table_new_full(g_direct_hash,
                        g_direct_equal, (GDestroyNotify) NULL,
                        (GDestroyNotify) trace_ir_metadata_maps_destroy);
 
        goto end;
 error:
-       trace_ir_maps_destroy(trace_ir_maps);
-       trace_ir_maps = NULL;
+       trace_ir_maps_destroy(ir_maps);
+       ir_maps = NULL;
 end:
-       return trace_ir_maps;
+       return ir_maps;
 }
index fda6a729ae20d50c06821ac8e09bbef6092bbce8..514cc2d6231c218fa734f986072cb2b43a33077f 100644 (file)
@@ -43,6 +43,7 @@ struct field_class_resolving_context {
 };
 
 struct trace_ir_metadata_maps {
+       bt_logging_level log_level;
        const bt_trace_class *input_trace_class;
        bt_trace_class *output_trace_class;
 
@@ -85,6 +86,7 @@ struct trace_ir_metadata_maps {
 };
 
 struct trace_ir_data_maps {
+       bt_logging_level log_level;
        const bt_trace *input_trace;
        bt_trace *output_trace;
 
@@ -106,6 +108,8 @@ struct trace_ir_data_maps {
 };
 
 struct trace_ir_maps {
+       bt_logging_level log_level;
+
        /*
         * input trace -> trace_ir_data_maps.
         * input trace: weak reference. Owned by an upstream component.
@@ -127,7 +131,7 @@ struct trace_ir_maps {
 
 BT_HIDDEN
 struct trace_ir_maps *trace_ir_maps_create(bt_self_component *self_comp,
-               const char *debug_info_field_name);
+               const char *debug_info_field_name, bt_logging_level log_level);
 
 BT_HIDDEN
 void trace_ir_maps_clear(struct trace_ir_maps *maps);
index 2471e96fc5b88e871d3a688bbd94afadb7706f81..924c4e66cd528ff4b7ebae2a9d3b3e608c32bb5d 100644 (file)
@@ -24,8 +24,9 @@
  * SOFTWARE.
  */
 
+#define BT_LOG_OUTPUT_LEVEL log_level
 #define BT_LOG_TAG "PLUGIN/FLT.LTTNG-UTILS.DEBUG-INFO/TRACE-IR-META-COPY"
-#include "logging.h"
+#include "logging/log.h"
 
 #include <inttypes.h>
 #include <stdint.h>
@@ -38,7 +39,7 @@
 
 BT_HIDDEN
 int copy_trace_class_content(const bt_trace_class *in_trace_class,
-               bt_trace_class *out_trace_class)
+               bt_trace_class *out_trace_class, bt_logging_level log_level)
 {
        int ret = 0;
        uint64_t i, env_field_count;
@@ -110,7 +111,7 @@ error:
 
 static
 int copy_clock_class_content(const bt_clock_class *in_clock_class,
-               bt_clock_class *out_clock_class)
+               bt_clock_class *out_clock_class, bt_logging_level log_level)
 {
        bt_clock_class_status status;
        const char *clock_class_name, *clock_class_description;
@@ -190,6 +191,7 @@ bt_clock_class *create_new_mapped_clock_class(
 {
        bt_clock_class *out_clock_class;
        int ret;
+       bt_logging_level log_level = md_maps->log_level;
 
        BT_LOGD("Creating new mapped clock class: in-cc-addr=%p",
                        in_clock_class);
@@ -205,7 +207,8 @@ bt_clock_class *create_new_mapped_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);
+       ret = copy_clock_class_content(in_clock_class, out_clock_class,
+               log_level);
        if (ret) {
                BT_LOGE_STR("Cannot copy clock class");
                goto end;
@@ -233,6 +236,7 @@ int copy_stream_class_content(struct trace_ir_maps *ir_maps,
        bt_stream_class_status status;
        const char *in_name;
        int ret = 0;
+       bt_logging_level log_level = ir_maps->log_level;
 
        BT_LOGD("Copying content of stream class: in-sc-addr=%p, out-sc-addr=%p",
                        in_stream_class, out_stream_class);
@@ -374,11 +378,12 @@ int copy_event_class_content(struct trace_ir_maps *ir_maps,
        struct trace_ir_metadata_maps *md_maps;
        const char *in_event_class_name, *in_emf_uri;
        bt_property_availability prop_avail;
-       bt_event_class_log_level log_level;
+       bt_event_class_log_level ec_log_level;
        bt_event_class_status status;
        bt_field_class *out_specific_context_fc, *out_payload_fc;
        const bt_field_class *in_event_specific_context, *in_event_payload;
        int ret = 0;
+       bt_logging_level log_level = ir_maps->log_level;
 
        BT_LOGD("Copying content of event class: in-ec-addr=%p, out-ec-addr=%p",
                        in_event_class, out_event_class);
@@ -396,10 +401,11 @@ int copy_event_class_content(struct trace_ir_maps *ir_maps,
        }
 
        /* Copy event class loglevel. */
-       prop_avail = bt_event_class_get_log_level(in_event_class, &log_level);
+       prop_avail = bt_event_class_get_log_level(in_event_class,
+               &ec_log_level);
        if (prop_avail == BT_PROPERTY_AVAILABILITY_AVAILABLE) {
                bt_event_class_set_log_level(out_event_class,
-                               log_level);
+                               ec_log_level);
        }
 
        /* Copy event class emf uri. */
@@ -499,6 +505,7 @@ int copy_event_common_context_field_class_content(
        bt_field_class *debug_field_class = NULL, *bin_field_class = NULL,
                       *func_field_class = NULL, *src_field_class = NULL;
        int ret = 0;
+       bt_logging_level log_level = md_maps->log_level;
 
        BT_LOGD("Copying content of event common context field class: "
                "in-fc-addr=%p, out-fc-addr=%p", in_field_class, out_field_class);
index f9f806441afd82ecfcedbb7f0081af6f6b55c130..3904e3829ce99883f4e6cf83f23a5874b774932c 100644 (file)
@@ -33,7 +33,8 @@
 
 BT_HIDDEN
 int copy_trace_class_content(const bt_trace_class *in_trace_class,
-               bt_trace_class *out_trace_class);
+               bt_trace_class *out_trace_class,
+               bt_logging_level log_level);
 
 BT_HIDDEN
 int copy_stream_class_content(struct trace_ir_maps *trace_ir_maps,
index f7cab92fe005249b6f1f5a75a3b72b22a34f7383..8d87f98193ddc56b5be28248630bafa98bfa5255 100644 (file)
@@ -24,8 +24,9 @@
  * SOFTWARE.
  */
 
+#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.h"
+#include "logging/log.h"
 
 #include "common/assert.h"
 #include "common/common.h"
@@ -41,8 +42,8 @@
  * structures ultimately leading to a field class.
  */
 static
-const bt_field_class *walk_field_path(const bt_field_path *fp,
-               const bt_field_class *fc)
+const bt_field_class *walk_field_path(struct trace_ir_metadata_maps *md_maps,
+               const bt_field_path *fp, const bt_field_class *fc)
 {
        uint64_t i, fp_item_count;
        const bt_field_class *curr_fc;
@@ -117,16 +118,20 @@ const bt_field_class *resolve_field_path_to_field_class(const bt_field_path *fp,
 
        switch (fp_scope) {
        case BT_SCOPE_PACKET_CONTEXT:
-               fc = walk_field_path(fp, fc_resolving_ctx->packet_context);
+               fc = walk_field_path(md_maps, fp,
+                       fc_resolving_ctx->packet_context);
                break;
        case BT_SCOPE_EVENT_COMMON_CONTEXT:
-               fc = walk_field_path(fp, fc_resolving_ctx->event_common_context);
+               fc = walk_field_path(md_maps, fp,
+                       fc_resolving_ctx->event_common_context);
                break;
        case BT_SCOPE_EVENT_SPECIFIC_CONTEXT:
-               fc = walk_field_path(fp, fc_resolving_ctx->event_specific_context);
+               fc = walk_field_path(md_maps, fp,
+                       fc_resolving_ctx->event_specific_context);
                break;
        case BT_SCOPE_EVENT_PAYLOAD:
-               fc = walk_field_path(fp, fc_resolving_ctx->event_payload);
+               fc = walk_field_path(md_maps, fp,
+                       fc_resolving_ctx->event_payload);
                break;
        default:
                abort();
index c55201c116f389841bef0fc0db32d53b4ea1f093..990fc6b7483ccfb99584bacafbd0ab2f0805bf5d 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);
+                             data_dir, NULL, BT_LOG_OUTPUT_LEVEL);
        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);
+                             data_dir, NULL, BT_LOG_OUTPUT_LEVEL);
        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);
+                             data_dir, NULL, BT_LOG_OUTPUT_LEVEL);
        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);
+                             data_dir, NULL, BT_LOG_OUTPUT_LEVEL);
        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();
+       ret = bin_info_init(BT_LOG_OUTPUT_LEVEL);
        ok(ret == 0, "bin_info_init successful");
 
        test_bin_info_elf(opt_debug_info_dir);
This page took 0.043126 seconds and 4 git commands to generate.