From 13388755930c20f4c3785153b8952cf30c23183a Mon Sep 17 00:00:00 2001 From: Gabriel Corona Date: Fri, 17 Jul 2015 12:29:07 +0200 Subject: [PATCH] [mc] OOPify/C++ify ObjectInformation --- src/mc/mc_checkpoint.cpp | 2 +- src/mc/mc_diff.cpp | 21 ----------- src/mc/mc_dwarf.cpp | 49 ++++++++++++++++++-------- src/mc/mc_dwarf_expression.cpp | 6 ++-- src/mc/mc_forward.h | 6 +++- src/mc/mc_object_info.cpp | 18 ++++++---- src/mc/mc_object_info.h | 64 +++++++++++++--------------------- src/mc/mc_process.cpp | 19 +++++----- teshsuite/mc/dwarf/dwarf.cpp | 2 +- 9 files changed, 89 insertions(+), 98 deletions(-) diff --git a/src/mc/mc_checkpoint.cpp b/src/mc/mc_checkpoint.cpp index 24149db42e..5b16ad1505 100644 --- a/src/mc/mc_checkpoint.cpp +++ b/src/mc/mc_checkpoint.cpp @@ -140,7 +140,7 @@ static void MC_snapshot_add_region(int index, mc_snapshot_t snapshot, else if (type == simgrid::mc::RegionType::Heap) xbt_assert(!object_info, "Unexpected object info for heap region."); - const bool privatization_aware = MC_object_info_is_privatized(object_info); + const bool privatization_aware = object_info && object_info->privatized(); simgrid::mc::RegionSnapshot region; if (privatization_aware && MC_smpi_process_count()) diff --git a/src/mc/mc_diff.cpp b/src/mc/mc_diff.cpp index 06b11417e8..6ea1d0163f 100644 --- a/src/mc/mc_diff.cpp +++ b/src/mc/mc_diff.cpp @@ -1573,27 +1573,6 @@ static int get_pointed_area_size(void *area, int heap) } } -// Not used: -char *get_type_description(mc_object_info_t info, char *type_name) -{ - - xbt_dict_cursor_t dict_cursor; - char *type_origin; - dw_type_t type; - - xbt_dict_foreach(info->types, dict_cursor, type_origin, type) { - if (type->name && (strcmp(type->name, type_name) == 0) - && type->byte_size > 0) { - xbt_dict_cursor_free(&dict_cursor); - return type_origin; - } - } - - xbt_dict_cursor_free(&dict_cursor); - return NULL; -} - - #ifndef max #define max( a, b ) ( ((a) > (b)) ? (a) : (b) ) #endif diff --git a/src/mc/mc_dwarf.cpp b/src/mc/mc_dwarf.cpp index ab65cae573..faba98c0da 100644 --- a/src/mc/mc_dwarf.cpp +++ b/src/mc/mc_dwarf.cpp @@ -755,7 +755,7 @@ static dw_variable_t MC_die_to_variable(mc_object_info_t info, Dwarf_Die * die, if (len == 1 && expr[0].atom == DW_OP_addr) { variable->global = 1; uintptr_t offset = (uintptr_t) expr[0].number; - uintptr_t base = (uintptr_t) MC_object_base_address(info); + uintptr_t base = (uintptr_t) info->base_address(); variable->address = (void *) (base + offset); } else { mc_dwarf_location_list_init_from_expression(&variable->locations, len, @@ -863,7 +863,7 @@ static void MC_dwarf_handle_scope_die(mc_object_info_t info, Dwarf_Die * die, // This is the base address for DWARF addresses. // Relocated addresses are offset from this base address. // See DWARF4 spec 7.5 - void *base = MC_object_base_address(info); + void *base = info->base_address(); // Variables are filled in the (recursive) call of MC_dwarf_handle_children: frame->variables = @@ -1087,7 +1087,10 @@ void dw_variable_free_voidp(void *t) // ***** object_info -s_mc_object_info::s_mc_object_info() +namespace simgrid { +namespace mc { + +ObjectInformation::ObjectInformation() { this->flags = 0; this->file_name = nullptr; @@ -1107,7 +1110,7 @@ s_mc_object_info::s_mc_object_info() this->functions_index = nullptr; } -s_mc_object_info::~s_mc_object_info() +ObjectInformation::~ObjectInformation() { xbt_free(this->file_name); xbt_dict_free(&this->subprograms); @@ -1117,20 +1120,38 @@ s_mc_object_info::~s_mc_object_info() xbt_dynar_free(&this->functions_index); } -// ***** Helpers - -void *MC_object_base_address(mc_object_info_t info) +/** Find the DWARF offset for this ELF object + * + * An offset is applied to address found in DWARF: + * + *