From: Philippe Proulx Date: Mon, 17 Jun 2019 05:45:14 +0000 (-0400) Subject: flt.lttng-utils.debug-info: honor component's initial log level X-Git-Url: http://git.efficios.com/?p=babeltrace.git;a=commitdiff_plain;h=3a3d15f3fa1eb1fc6d7224a65996163805e602d9 flt.lttng-utils.debug-info: honor component's initial log level Signed-off-by: Philippe Proulx Change-Id: I49d4f5ecbdcc546c511e2469581db4f0e785a54a Reviewed-on: https://review.lttng.org/c/babeltrace/+/1479 Tested-by: jenkins Reviewed-by: Francis Deslauriers --- diff --git a/src/cli/babeltrace2.c b/src/cli/babeltrace2.c index 0a3cb5b9..db2ed837 100644 --- a/src/cli/babeltrace2.c +++ b/src/cli/babeltrace2.c @@ -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", diff --git a/src/plugins/lttng-utils/debug-info/Makefile.am b/src/plugins/lttng-utils/debug-info/Makefile.am index a231785b..f9c353ca 100644 --- a/src/plugins/lttng-utils/debug-info/Makefile.am +++ b/src/plugins/lttng-utils/debug-info/Makefile.am @@ -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 \ diff --git a/src/plugins/lttng-utils/debug-info/bin-info.c b/src/plugins/lttng-utils/debug-info/bin-info.c index cbf9310a..20ed40a7 100644 --- a/src/plugins/lttng-utils/debug-info/bin-info.c +++ b/src/plugins/lttng-utils/debug-info/bin-info.c @@ -26,9 +26,11 @@ * 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 #include #include #include @@ -58,12 +60,13 @@ #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 { diff --git a/src/plugins/lttng-utils/debug-info/bin-info.h b/src/plugins/lttng-utils/debug-info/bin-info.h index 00a6e4e0..98d7fd1f 100644 --- a/src/plugins/lttng-utils/debug-info/bin-info.h +++ b/src/plugins/lttng-utils/debug-info/bin-info.h @@ -27,6 +27,7 @@ * SOFTWARE. */ +#include #include #include #include @@ -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 diff --git a/src/plugins/lttng-utils/debug-info/debug-info.c b/src/plugins/lttng-utils/debug-info/debug-info.c index 9f6f0968..583f779f 100644 --- a/src/plugins/lttng-utils/debug-info/debug-info.c +++ b/src/plugins/lttng-utils/debug-info/debug-info.c @@ -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 @@ -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 index a872d571..00000000 --- a/src/plugins/lttng-utils/debug-info/logging.c +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2017 Philippe Proulx - * - * 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 index fa298d54..00000000 --- a/src/plugins/lttng-utils/debug-info/logging.h +++ /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 - * - * 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 */ diff --git a/src/plugins/lttng-utils/debug-info/trace-ir-data-copy.c b/src/plugins/lttng-utils/debug-info/trace-ir-data-copy.c index 880a942a..fb0d0c12 100644 --- a/src/plugins/lttng-utils/debug-info/trace-ir-data-copy.c +++ b/src/plugins/lttng-utils/debug-info/trace-ir-data-copy.c @@ -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 #include @@ -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; } diff --git a/src/plugins/lttng-utils/debug-info/trace-ir-data-copy.h b/src/plugins/lttng-utils/debug-info/trace-ir-data-copy.h index ddb1b89d..cc941945 100644 --- a/src/plugins/lttng-utils/debug-info/trace-ir-data-copy.h +++ b/src/plugins/lttng-utils/debug-info/trace-ir-data-copy.h @@ -32,14 +32,19 @@ #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 */ diff --git a/src/plugins/lttng-utils/debug-info/trace-ir-mapping.c b/src/plugins/lttng-utils/debug-info/trace-ir-mapping.c index 19a03f27..cb73727b 100644 --- a/src/plugins/lttng-utils/debug-info/trace-ir-mapping.c +++ b/src/plugins/lttng-utils/debug-info/trace-ir-mapping.c @@ -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 @@ -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; } diff --git a/src/plugins/lttng-utils/debug-info/trace-ir-mapping.h b/src/plugins/lttng-utils/debug-info/trace-ir-mapping.h index fda6a729..514cc2d6 100644 --- a/src/plugins/lttng-utils/debug-info/trace-ir-mapping.h +++ b/src/plugins/lttng-utils/debug-info/trace-ir-mapping.h @@ -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); diff --git a/src/plugins/lttng-utils/debug-info/trace-ir-metadata-copy.c b/src/plugins/lttng-utils/debug-info/trace-ir-metadata-copy.c index 2471e96f..924c4e66 100644 --- a/src/plugins/lttng-utils/debug-info/trace-ir-metadata-copy.c +++ b/src/plugins/lttng-utils/debug-info/trace-ir-metadata-copy.c @@ -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 #include @@ -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); diff --git a/src/plugins/lttng-utils/debug-info/trace-ir-metadata-copy.h b/src/plugins/lttng-utils/debug-info/trace-ir-metadata-copy.h index f9f80644..3904e382 100644 --- a/src/plugins/lttng-utils/debug-info/trace-ir-metadata-copy.h +++ b/src/plugins/lttng-utils/debug-info/trace-ir-metadata-copy.h @@ -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, diff --git a/src/plugins/lttng-utils/debug-info/trace-ir-metadata-field-class-copy.c b/src/plugins/lttng-utils/debug-info/trace-ir-metadata-field-class-copy.c index f7cab92f..8d87f981 100644 --- a/src/plugins/lttng-utils/debug-info/trace-ir-metadata-field-class-copy.c +++ b/src/plugins/lttng-utils/debug-info/trace-ir-metadata-field-class-copy.c @@ -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(); diff --git a/tests/plugins/flt.lttng-utils.debug-info/test_bin_info.c b/tests/plugins/flt.lttng-utils.debug-info/test_bin_info.c index c55201c1..990fc6b7 100644 --- a/tests/plugins/flt.lttng-utils.debug-info/test_bin_info.c +++ b/tests/plugins/flt.lttng-utils.debug-info/test_bin_info.c @@ -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);