* 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;
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;
}
bin->log_level = log_level;
+ bin->self_comp = self_comp;
if (target_prefix) {
bin->elf_path = g_build_filename(target_prefix, path, NULL);
} else {
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;
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;
}
*/
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;
}
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;
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);
}
}
* SOFTWARE.
*/
-#include <babeltrace2/logging.h>
+#include <babeltrace2/babeltrace.h>
#include <stdint.h>
#include <stdbool.h>
#include <gelf.h>
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. */
* @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
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
* 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>
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;
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;
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
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;
/* 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);
}
}
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;
}
* 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,
}
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);
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);
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);
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;
}
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;
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);
}
}
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;
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);
}
}
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;
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);
}
}
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;
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);
}
}
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
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);
*/
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;
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;
}
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
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);
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:
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);
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);
}
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);
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);
}
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);
}
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);
}
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(
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;
}
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);
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;
}
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);
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;
}
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);
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;
}
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;
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;
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;
}
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);
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;
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;
}
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(
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;
* 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);
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;
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;
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. */
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);
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 =
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);
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;
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:
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);
}
out_field, in_member_name);
copy_field_content(in_member_field,
- out_member_field, log_level);
+ out_member_field, log_level, self_comp);
}
break;
}
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);
}
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;
}
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);
}
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);
}
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 */
* 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>
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);
/* 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:
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);
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;
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,
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;
}
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;
}
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:
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);
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;
}
/*
* 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:
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(
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;
}
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;
}
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:
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);
/* 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;
}
* 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:
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. */
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
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;
}
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.");
}
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.");
}
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;
}
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;
struct trace_ir_data_maps {
bt_logging_level log_level;
+ bt_self_component *self_comp;
const bt_trace *input_trace;
bt_trace *output_trace;
* 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. */
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);
}
}
- 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;
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;
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);
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;
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;
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:
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);
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;
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);
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;
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;
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;
}
/* 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;
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. */
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;
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;
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;
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;
}
}
- 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;
*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. */
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;
}
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;
}
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;
}
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;
}
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;
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;
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;
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;
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,
* 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"
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);
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);
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;
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;
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);
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);
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;
}
}
- 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);
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);
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);
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;
}
}
- 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);
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;
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. */
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);
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);
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);
}
}
- 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:
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);
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;
}
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;
}
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:
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;
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);
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;
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;
}
}
- 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:
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;
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;
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);
{
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)) {
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);
}
$(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
}
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 */
}
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 */
}
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 */
}
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 */
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);