#include <babeltrace/assert-internal.h>
#include <babeltrace/common-internal.h>
+#include <babeltrace/fd-cache-internal.h>
#include "bin-info.h"
#include "debug-info.h"
struct trace_ir_maps *ir_maps;
/* in_trace -> debug_info_mapping. */
GHashTable *debug_info_map;
+
+ struct bt_fd_cache fd_cache;
};
struct debug_info_source {
GQuark q_dl_open;
GQuark q_lib_load;
GQuark q_lib_unload;
+ struct bt_fd_cache *fd_cache; /* Weak ref. Owned by the iterator. */
};
static
return debug_info_src;
}
-BT_HIDDEN
+static
struct debug_info_source *debug_info_query(struct debug_info *debug_info,
int64_t vpid, uint64_t ip)
{
return dbg_info_src;
}
-BT_HIDDEN
+static
struct debug_info *debug_info_create(struct debug_info_component *comp,
- const bt_trace *trace)
+ const bt_trace *trace, struct bt_fd_cache *fdc)
{
int ret;
struct debug_info *debug_info;
+ BT_ASSERT(comp);
+ BT_ASSERT(trace);
+ BT_ASSERT(fdc);
+
debug_info = g_new0(struct debug_info, 1);
if (!debug_info) {
goto end;
}
debug_info->input_trace = trace;
+ debug_info->fd_cache = fdc;
end:
return debug_info;
return NULL;
}
-BT_HIDDEN
+static
void debug_info_destroy(struct debug_info *debug_info)
{
bt_trace_status status;
uint64_t is_pic_field_value;
event_get_payload_unsigned_integer_field_value(event,
- IS_PIC_FIELD_NAME, &is_pic_field_value);
+ IS_PIC_FIELD_NAME, &is_pic_field_value);
is_pic = is_pic_field_value == 1;
} else {
/*
VPID_FIELD_NAME, &vpid);
proc_dbg_info_src = proc_debug_info_sources_ht_get_entry(
- debug_info->vpid_to_proc_dbg_info_src, vpid);
+ debug_info->vpid_to_proc_dbg_info_src, vpid);
if (!proc_dbg_info_src) {
goto end;
}
*((uint64_t *) key) = baddr;
- bin = g_hash_table_lookup(proc_dbg_info_src->baddr_to_bin_info,
- key);
+ bin = g_hash_table_lookup(proc_dbg_info_src->baddr_to_bin_info, key);
if (bin) {
goto end;
}
- bin = bin_info_create(path, baddr, memsz, is_pic,
+ 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);
if (!bin) {
goto end;
}
- g_hash_table_insert(proc_dbg_info_src->baddr_to_bin_info,
- key, bin);
+ g_hash_table_insert(proc_dbg_info_src->baddr_to_bin_info, key, bin);
/* Ownership passed to ht. */
key = NULL;
debug_info = g_hash_table_lookup(debug_it->debug_info_map, trace);
if (!debug_info) {
debug_info = debug_info_create(debug_it->debug_info_component,
- trace);
+ trace, &debug_it->fd_cache);
g_hash_table_insert(debug_it->debug_info_map, (gpointer) trace,
debug_info);
bt_trace_add_destruction_listener(trace,
bt_self_component_port_input_message_iterator *upstream_iterator;
struct debug_info_msg_iter *debug_info_msg_iter;
gchar *debug_info_field_name;
+ int ret;
/* Borrow the upstream input port. */
input_port = bt_self_component_filter_borrow_input_port_by_name(
goto end;
}
+ ret = bt_fd_cache_init(&debug_info_msg_iter->fd_cache);
+ if (ret) {
+ trace_ir_maps_destroy(debug_info_msg_iter->ir_maps);
+ g_hash_table_destroy(debug_info_msg_iter->debug_info_map);
+ g_free(debug_info_msg_iter);
+ status = BT_SELF_MESSAGE_ITERATOR_STATUS_NOMEM;
+ goto end;
+ }
+
+
bt_self_message_iterator_set_data(self_msg_iter, debug_info_msg_iter);
debug_info_msg_iter->input_iterator = self_msg_iter;
trace_ir_maps_destroy(debug_info_msg_iter->ir_maps);
g_hash_table_destroy(debug_info_msg_iter->debug_info_map);
+ bt_fd_cache_fini(&debug_info_msg_iter->fd_cache);
+
g_free(debug_info_msg_iter);
}