MC_dwarf_handle_children(info, die, unit, &frame, ns);
// Register it:
- if (klass == mc_tag_subprogram) {
- char *key = bprintf("%" PRIx64, (uint64_t) frame.id);
-
- xbt_dict_set(info->subprograms, key,
- new simgrid::mc::Frame(std::move(frame)), NULL);
- xbt_free(key);
- } else if (klass == mc_tag_scope)
+ if (klass == mc_tag_subprogram)
+ info->subprograms[frame.id] = frame;
+ else if (klass == mc_tag_scope)
parent_frame->scopes.push_back(std::move(frame));
}
{
xbt_dynar_t index = xbt_dynar_new(sizeof(s_mc_function_index_item_t), NULL);
- // Populate the array:
- mc_frame_t frame = NULL;
- xbt_dict_cursor_t cursor;
- char *key;
- xbt_dict_foreach(info->subprograms, cursor, key, frame) {
- if (frame->low_pc == NULL)
+ for (auto& e : info->subprograms) {
+ if (e.second.low_pc == nullptr)
continue;
s_mc_function_index_item_t entry;
- entry.low_pc = frame->low_pc;
- entry.high_pc = frame->high_pc;
- entry.function = frame;
+ entry.low_pc = e.second.low_pc;
+ entry.high_pc = e.second.high_pc;
+ entry.function = &e.second;
xbt_dynar_push(index, &entry);
}
{
if (scope->tag == DW_TAG_inlined_subroutine) {
-
// Attach correct namespaced name in inlined subroutine:
- char *key = bprintf("%" PRIx64, (uint64_t) scope->abstract_origin_id);
- mc_frame_t abstract_origin = (mc_frame_t) xbt_dict_get_or_null(info->subprograms, key);
- xbt_assert(abstract_origin, "Could not lookup abstract origin %s", key);
- xbt_free(key);
- scope->name = abstract_origin->name;
+ auto i = info->subprograms.find(scope->abstract_origin_id);
+ xbt_assert(i != info->subprograms.end(),
+ "Could not lookup abstract origin %" PRIx64,
+ (uint64_t) scope->abstract_origin_id);
+ scope->name = i->second.name;
}
// Direct:
static void MC_post_process_functions(mc_object_info_t info)
{
- xbt_dict_cursor_t cursor;
- char *key;
- mc_frame_t subprogram = NULL;
- xbt_dict_foreach(info->subprograms, cursor, key, subprogram) {
- mc_post_process_scope(info, subprogram);
- }
+ for (auto& entry : info->subprograms)
+ mc_post_process_scope(info, &entry.second);
}
namespace simgrid {
namespace mc {
+class Variable {
+public:
+ Variable();
+
+ Dwarf_Off dwarf_offset; /* Global offset of the field. */
+ int global;
+ std::string name;
+ std::uint64_t type_id;
+ mc_type_t type;
+
+ // Use either of:
+ simgrid::mc::LocationList location_list;
+ void* address;
+
+ size_t start_scope;
+ mc_object_info_t object_info;
+
+};
+
+class Frame {
+public:
+ Frame();
+
+ int tag;
+ std::string name;
+ void *low_pc;
+ void *high_pc;
+ simgrid::mc::LocationList frame_base;
+ std::vector<Variable> variables;
+ unsigned long int id; /* DWARF offset of the subprogram */
+ std::vector<Frame> scopes;
+ Dwarf_Off abstract_origin_id;
+ mc_object_info_t object_info;
+};
+
class ObjectInformation {
public:
ObjectInformation();
char *end_rw; // Read-write segment
char *start_ro;
char *end_ro; // read-only segment
- xbt_dict_t subprograms; // xbt_dict_t<origin as hexadecimal string, mc_frame_t>
+ std::unordered_map<std::uint64_t, simgrid::mc::Frame> subprograms;
// TODO, remove the mutable (to remove it we'll have to add a lot of const everywhere)
mutable std::vector<simgrid::mc::Variable> global_variables;
std::unordered_map<std::uint64_t, simgrid::mc::Type> types;
};
-class Variable {
-public:
- Variable();
-
- Dwarf_Off dwarf_offset; /* Global offset of the field. */
- int global;
- std::string name;
- std::uint64_t type_id;
- mc_type_t type;
-
- // Use either of:
- simgrid::mc::LocationList location_list;
- void* address;
-
- size_t start_scope;
- mc_object_info_t object_info;
-
-};
-
-class Frame {
-public:
- Frame();
-
- int tag;
- std::string name;
- void *low_pc;
- void *high_pc;
- simgrid::mc::LocationList frame_base;
- std::vector<Variable> variables;
- unsigned long int id; /* DWARF offset of the subprogram */
- std::vector<Frame> scopes;
- Dwarf_Off abstract_origin_id;
- mc_object_info_t object_info;
-};
-
}
}
const char *subprogram_name,
mc_object_info_t info)
{
- xbt_dict_cursor_t cursor2;
- mc_frame_t frame;
- char *key;
- xbt_dict_foreach(info->subprograms, cursor2, key, frame) {
- mc_ignore_local_variable_in_scope(var_name, subprogram_name, frame, frame);
- }
+ for (auto& entry : info->subprograms)
+ mc_ignore_local_variable_in_scope(
+ var_name, subprogram_name, &entry.second, &entry.second);
}
/** \brief Ignore a local variable in a scope