From: Gabriel Corona Date: Thu, 23 Jul 2015 11:05:18 +0000 (+0200) Subject: [mc] Remove a lot of typedefs and typedef usage X-Git-Tag: v3_12~438^2~14 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/f233a6d6c7d459205695d95e840063beba932147 [mc] Remove a lot of typedefs and typedef usage Do not hide the real type of things behind typedefs. Some typedefs are still there because they are used by C code. --- diff --git a/buildtools/Cmake/DefinePackages.cmake b/buildtools/Cmake/DefinePackages.cmake index c31683e0f3..94d3a08ac0 100644 --- a/buildtools/Cmake/DefinePackages.cmake +++ b/buildtools/Cmake/DefinePackages.cmake @@ -603,6 +603,7 @@ set(MC_SRC src/mc/AddressSpace.hpp src/mc/AddressSpace.cpp src/mc/mc_forward.h + src/mc/mc_forward.hpp src/mc/mc_process.h src/mc/mc_process.cpp src/mc/mc_unw.h diff --git a/src/mc/AddressSpace.hpp b/src/mc/AddressSpace.hpp index ea260c2274..fb1cddfbd2 100644 --- a/src/mc/AddressSpace.hpp +++ b/src/mc/AddressSpace.hpp @@ -14,7 +14,7 @@ #include -#include "mc_forward.h" +#include "mc_forward.hpp" namespace simgrid { namespace mc { diff --git a/src/mc/ModelChecker.hpp b/src/mc/ModelChecker.hpp index 8ef6f807b4..d397d8fcc9 100644 --- a/src/mc/ModelChecker.hpp +++ b/src/mc/ModelChecker.hpp @@ -12,7 +12,7 @@ #include #include -#include "mc_forward.h" +#include "mc_forward.hpp" #include "mc_process.h" #include "PageStore.hpp" #include "mc_protocol.h" diff --git a/src/mc/PageStore.hpp b/src/mc/PageStore.hpp index 9e72f1d27a..5dee482f77 100644 --- a/src/mc/PageStore.hpp +++ b/src/mc/PageStore.hpp @@ -14,7 +14,7 @@ #include #include "mc_mmu.h" -#include "mc_forward.h" +#include "mc_forward.hpp" namespace simgrid { namespace mc { diff --git a/src/mc/RegionSnapshot.cpp b/src/mc/RegionSnapshot.cpp index 23853c8341..4a6e63f573 100644 --- a/src/mc/RegionSnapshot.cpp +++ b/src/mc/RegionSnapshot.cpp @@ -56,7 +56,7 @@ RegionSnapshot region( RegionSnapshot sparse_region(RegionType region_type, void *start_addr, void* permanent_addr, size_t size) { - mc_process_t process = &mc_model_checker->process(); + simgrid::mc::Process* process = &mc_model_checker->process(); xbt_assert((((uintptr_t)start_addr) & (xbt_pagesize-1)) == 0, "Not at the beginning of a page"); diff --git a/src/mc/RegionSnapshot.hpp b/src/mc/RegionSnapshot.hpp index 5e09e62065..9915186a69 100644 --- a/src/mc/RegionSnapshot.hpp +++ b/src/mc/RegionSnapshot.hpp @@ -124,7 +124,7 @@ class RegionSnapshot { private: RegionType region_type_; StorageType storage_type_; - mc_object_info_t object_info_; + simgrid::mc::ObjectInformation* object_info_; /** @brief Virtual address of the region in the simulated process */ void *start_addr_; @@ -251,8 +251,8 @@ public: return privatized_regions_; } - mc_object_info_t object_info() const { return object_info_; } - void object_info(mc_object_info_t info) { object_info_ = info; } + simgrid::mc::ObjectInformation* object_info() const { return object_info_; } + void object_info(simgrid::mc::ObjectInformation* info) { object_info_ = info; } // Other getters diff --git a/src/mc/mc_checkpoint.cpp b/src/mc/mc_checkpoint.cpp index e521d5672b..54f04dfa22 100644 --- a/src/mc/mc_checkpoint.cpp +++ b/src/mc/mc_checkpoint.cpp @@ -116,7 +116,7 @@ extern "C" { static void MC_snapshot_add_region(int index, mc_snapshot_t snapshot, simgrid::mc::RegionType type, - mc_object_info_t object_info, + simgrid::mc::ObjectInformation* object_info, void *start_addr, void* permanent_addr, size_t size) { if (type == simgrid::mc::RegionType::Data) @@ -139,7 +139,7 @@ static void MC_snapshot_add_region(int index, mc_snapshot_t snapshot, return; } -static void MC_get_memory_regions(mc_process_t process, mc_snapshot_t snapshot) +static void MC_get_memory_regions(simgrid::mc::Process* process, mc_snapshot_t snapshot) { const size_t n = process->object_infos.size(); snapshot->snapshot_regions.resize(n + 1); @@ -181,7 +181,7 @@ static void MC_get_memory_regions(mc_process_t process, mc_snapshot_t snapshot) * `dl_iterate_phdr` would be more robust but would not work in cross-process. * */ void MC_find_object_address( - std::vector const& maps, mc_object_info_t result) + std::vector const& maps, simgrid::mc::ObjectInformation* result) { const char* file_name = xbt_strdup(result->file_name.c_str()); const char *name = basename(file_name); @@ -245,7 +245,7 @@ void MC_find_object_address( * \param ip Instruction pointer * \return true if the variable is valid * */ -static bool mc_valid_variable(mc_variable_t var, mc_frame_t scope, +static bool mc_valid_variable(simgrid::mc::Variable* var, simgrid::mc::Frame* scope, const void *ip) { // The variable is not yet valid: @@ -256,10 +256,10 @@ static bool mc_valid_variable(mc_variable_t var, mc_frame_t scope, } static void mc_fill_local_variables_values(mc_stack_frame_t stack_frame, - mc_frame_t scope, int process_index, + simgrid::mc::Frame* scope, int process_index, std::vector& result) { - mc_process_t process = &mc_model_checker->process(); + simgrid::mc::Process* process = &mc_model_checker->process(); void *ip = (void *) stack_frame->ip; if (ip < scope->low_pc || ip >= scope->high_pc) @@ -336,7 +336,7 @@ static void MC_stack_frame_free_voipd(void *s) static std::vector MC_unwind_stack_frames(mc_unw_context_t stack_context) { - mc_process_t process = &mc_model_checker->process(); + simgrid::mc::Process* process = &mc_model_checker->process(); std::vector result; unw_cursor_t c; @@ -363,7 +363,7 @@ static std::vector MC_unwind_stack_frames(mc_unw_context_t s // TODO, use real addresses in frame_t instead of fixing it here - mc_frame_t frame = process->find_function(remote(ip)); + simgrid::mc::Frame* frame = process->find_function(remote(ip)); stack_frame.frame = frame; if (frame) { @@ -569,7 +569,7 @@ mc_snapshot_t MC_take_snapshot(int num_state) { XBT_DEBUG("Taking snapshot %i", num_state); - mc_process_t mc_process = &mc_model_checker->process(); + simgrid::mc::Process* mc_process = &mc_model_checker->process(); mc_snapshot_t snapshot = new simgrid::mc::Snapshot(); diff --git a/src/mc/mc_compare.cpp b/src/mc/mc_compare.cpp index 0663ab8a3b..9802a17056 100644 --- a/src/mc/mc_compare.cpp +++ b/src/mc/mc_compare.cpp @@ -104,11 +104,12 @@ static int compare_areas_with_type(struct mc_compare_state& state, int process_index, void* real_area1, mc_snapshot_t snapshot1, mc_mem_region_t region1, void* real_area2, mc_snapshot_t snapshot2, mc_mem_region_t region2, - mc_type_t type, int pointer_level) + simgrid::mc::Type* type, int pointer_level) { - mc_process_t process = &mc_model_checker->process(); + simgrid::mc::Process* process = &mc_model_checker->process(); - mc_type_t subtype, subsubtype; + simgrid::mc::Type* subtype; + simgrid::mc::Type* subsubtype; int elm_size, i, res; top: @@ -258,7 +259,7 @@ static int compare_areas_with_type(struct mc_compare_state& state, return 0; } -static int compare_global_variables(mc_object_info_t object_info, +static int compare_global_variables(simgrid::mc::ObjectInformation* object_info, int process_index, mc_mem_region_t r1, mc_mem_region_t r2, mc_snapshot_t snapshot1, @@ -305,7 +306,7 @@ static int compare_global_variables(mc_object_info_t object_info, || (char *) current_var.address > (char *) object_info->end_rw) continue; - mc_type_t bvariable_type = current_var.type; + simgrid::mc::Type* bvariable_type = current_var.type; int res = compare_areas_with_type(state, process_index, (char *) current_var.address, snapshot1, r1, @@ -359,7 +360,7 @@ static int compare_local_variables(int process_index, } // TODO, fix current_varX->subprogram->name to include name if DW_TAG_inlined_subprogram - mc_type_t subtype = current_var1->type; + simgrid::mc::Type* subtype = current_var1->type; res = compare_areas_with_type(state, process_index, current_var1->address, snapshot1, mc_get_snapshot_region(current_var1->address, snapshot1, process_index), @@ -386,7 +387,7 @@ static int compare_local_variables(int process_index, int snapshot_compare(void *state1, void *state2) { - mc_process_t process = &mc_model_checker->process(); + simgrid::mc::Process* process = &mc_model_checker->process(); mc_snapshot_t s1, s2; int num1, num2; diff --git a/src/mc/mc_diff.cpp b/src/mc/mc_diff.cpp index d489ae5e2e..628bbb61b5 100644 --- a/src/mc/mc_diff.cpp +++ b/src/mc/mc_diff.cpp @@ -151,7 +151,8 @@ struct s_mc_diff { std::vector* to_ignore1; std::vector* to_ignore2; s_heap_area_t *equals_to1, *equals_to2; - mc_type_t *types1, *types2; + simgrid::mc::Type **types1; + simgrid::mc::Type **types2; size_t available; }; @@ -383,7 +384,7 @@ int init_heap_information(xbt_mheap_t heap1, xbt_mheap_t heap2, state->types1 = (simgrid::mc::Type**) realloc(state->types1, state->heaplimit * MAX_FRAGMENT_PER_BLOCK * - sizeof(type_name *)); + sizeof(simgrid::mc::Type*)); state->equals_to2 = (s_heap_area_t*) realloc(state->equals_to2, state->heaplimit * MAX_FRAGMENT_PER_BLOCK * @@ -391,7 +392,7 @@ int init_heap_information(xbt_mheap_t heap1, xbt_mheap_t heap2, state->types2 = (simgrid::mc::Type**) realloc(state->types2, state->heaplimit * MAX_FRAGMENT_PER_BLOCK * - sizeof(type_name *)); + sizeof(simgrid::mc::Type*)); state->available = state->heaplimit; } @@ -430,7 +431,7 @@ mc_mem_region_t MC_get_heap_region(mc_snapshot_t snapshot) int mmalloc_compare_heap(mc_snapshot_t snapshot1, mc_snapshot_t snapshot2) { - mc_process_t process = &mc_model_checker->process(); + simgrid::mc::Process* process = &mc_model_checker->process(); struct s_mc_diff *state = mc_diff_info; /* Start comparison */ @@ -787,7 +788,7 @@ static int compare_heap_area_without_type(struct s_mc_diff *state, int process_i xbt_dynar_t previous, int size, int check_ignore) { - mc_process_t process = &mc_model_checker->process(); + simgrid::mc::Process* process = &mc_model_checker->process(); int i = 0; const void *addr_pointed1, *addr_pointed2; @@ -875,7 +876,7 @@ static int compare_heap_area_with_type(struct s_mc_diff *state, int process_inde const void *real_area1, const void *real_area2, mc_snapshot_t snapshot1, mc_snapshot_t snapshot2, - xbt_dynar_t previous, mc_type_t type, + xbt_dynar_t previous, simgrid::mc::Type* type, int area_size, int check_ignore, int pointer_level) { @@ -893,7 +894,7 @@ top: return 0; } - mc_type_t subtype, subsubtype; + simgrid::mc::Type *subtype, *subsubtype; int res, elm_size; const void *addr_pointed1, *addr_pointed2; @@ -1043,9 +1044,9 @@ top: for(simgrid::mc::Type& member : type->members) { // TODO, optimize this? (for the offset case) void *real_member1 = - mc_member_resolve(real_area1, type, &member, (mc_address_space_t) snapshot1, process_index); + mc_member_resolve(real_area1, type, &member, (simgrid::mc::AddressSpace*) snapshot1, process_index); void *real_member2 = - mc_member_resolve(real_area2, type, &member, (mc_address_space_t) snapshot2, process_index); + mc_member_resolve(real_area2, type, &member, (simgrid::mc::AddressSpace*) snapshot2, process_index); res = compare_heap_area_with_type(state, process_index, real_member1, real_member2, snapshot1, snapshot2, @@ -1080,7 +1081,7 @@ top: * @param area_size * @return DWARF type ID for given offset */ -static mc_type_t get_offset_type(void *real_base_address, mc_type_t type, +static simgrid::mc::Type* get_offset_type(void *real_base_address, simgrid::mc::Type* type, int offset, int area_size, mc_snapshot_t snapshot, int process_index) { @@ -1139,9 +1140,9 @@ static mc_type_t get_offset_type(void *real_base_address, mc_type_t type, */ int compare_heap_area(int process_index, const void *area1, const void *area2, mc_snapshot_t snapshot1, mc_snapshot_t snapshot2, xbt_dynar_t previous, - mc_type_t type, int pointer_level) + simgrid::mc::Type* type, int pointer_level) { - mc_process_t process = &mc_model_checker->process(); + simgrid::mc::Process* process = &mc_model_checker->process(); struct s_mc_diff *state = mc_diff_info; @@ -1154,7 +1155,7 @@ int compare_heap_area(int process_index, const void *area1, const void *area2, m int type_size = -1; int offset1 = 0, offset2 = 0; int new_size1 = -1, new_size2 = -1; - mc_type_t new_type1 = NULL, new_type2 = NULL; + simgrid::mc::Type *new_type1 = NULL, *new_type2 = NULL; int match_pairs = 0; diff --git a/src/mc/mc_dwarf.cpp b/src/mc/mc_dwarf.cpp index ed26c43a96..2134b0820a 100644 --- a/src/mc/mc_dwarf.cpp +++ b/src/mc/mc_dwarf.cpp @@ -61,14 +61,14 @@ static uint64_t MC_dwarf_array_element_count(Dwarf_Die * die, Dwarf_Die * unit); * \param unit the DIE of the compile unit of the current DIE * \param frame containg frame if any */ -static void MC_dwarf_handle_die(mc_object_info_t info, Dwarf_Die * die, - Dwarf_Die * unit, mc_frame_t frame, +static void MC_dwarf_handle_die(simgrid::mc::ObjectInformation* info, Dwarf_Die * die, + Dwarf_Die * unit, simgrid::mc::Frame* frame, const char *ns); /** \brief Process a type DIE */ -static void MC_dwarf_handle_type_die(mc_object_info_t info, Dwarf_Die * die, - Dwarf_Die * unit, mc_frame_t frame, +static void MC_dwarf_handle_type_die(simgrid::mc::ObjectInformation* info, Dwarf_Die * die, + Dwarf_Die * unit, simgrid::mc::Frame* frame, const char *ns); /** \brief Calls MC_dwarf_handle_die on all childrend of the given die @@ -78,8 +78,8 @@ static void MC_dwarf_handle_type_die(mc_object_info_t info, Dwarf_Die * die, * \param unit the DIE of the compile unit of the current DIE * \param frame containg frame if any */ -static void MC_dwarf_handle_children(mc_object_info_t info, Dwarf_Die * die, - Dwarf_Die * unit, mc_frame_t frame, +static void MC_dwarf_handle_children(simgrid::mc::ObjectInformation* info, Dwarf_Die * die, + Dwarf_Die * unit, simgrid::mc::Frame* frame, const char *ns); /** \brief Handle a variable (DW_TAG_variable or other) @@ -89,8 +89,8 @@ static void MC_dwarf_handle_children(mc_object_info_t info, Dwarf_Die * die, * \param unit the DIE of the compile unit of the current DIE * \param frame containg frame if any */ -static void MC_dwarf_handle_variable_die(mc_object_info_t info, Dwarf_Die * die, - Dwarf_Die * unit, mc_frame_t frame, +static void MC_dwarf_handle_variable_die(simgrid::mc::ObjectInformation* info, Dwarf_Die * die, + Dwarf_Die * unit, simgrid::mc::Frame* frame, const char *ns); /** \brief Get the DW_TAG_type of the DIE @@ -468,7 +468,7 @@ static bool MC_compare_variable( return a.address < b.address; } -// ***** mc_type_t +// ***** simgrid::mc::Type* /** \brief Initialize the location of a member of a type * (DW_AT_data_member_location of a DW_TAG_member). @@ -477,7 +477,7 @@ static bool MC_compare_variable( * \param member the member of the type * \param child DIE of the member (DW_TAG_member) */ -static void MC_dwarf_fill_member_location(mc_type_t type, mc_type_t member, +static void MC_dwarf_fill_member_location(simgrid::mc::Type* type, simgrid::mc::Type* member, Dwarf_Die * child) { if (dwarf_hasattr(child, DW_AT_data_bit_offset)) { @@ -547,8 +547,8 @@ static void MC_dwarf_fill_member_location(mc_type_t type, mc_type_t member, * \param unit DIE of the compilation unit containing the type DIE * \param type the type */ -static void MC_dwarf_add_members(mc_object_info_t info, Dwarf_Die * die, - Dwarf_Die * unit, mc_type_t type) +static void MC_dwarf_add_members(simgrid::mc::ObjectInformation* info, Dwarf_Die * die, + Dwarf_Die * unit, simgrid::mc::Type* type) { int res; Dwarf_Die child; @@ -606,8 +606,8 @@ static void MC_dwarf_add_members(mc_object_info_t info, Dwarf_Die * die, * \return MC representation of the type */ static simgrid::mc::Type MC_dwarf_die_to_type( - mc_object_info_t info, Dwarf_Die * die, - Dwarf_Die * unit, mc_frame_t frame, + simgrid::mc::ObjectInformation* info, Dwarf_Die * die, + Dwarf_Die * unit, simgrid::mc::Frame* frame, const char *ns) { @@ -690,8 +690,8 @@ static simgrid::mc::Type MC_dwarf_die_to_type( return std::move(type); } -static void MC_dwarf_handle_type_die(mc_object_info_t info, Dwarf_Die * die, - Dwarf_Die * unit, mc_frame_t frame, +static void MC_dwarf_handle_type_die(simgrid::mc::ObjectInformation* info, Dwarf_Die * die, + Dwarf_Die * unit, simgrid::mc::Frame* frame, const char *ns) { simgrid::mc::Type type = MC_dwarf_die_to_type(info, die, unit, frame, ns); @@ -703,8 +703,8 @@ static void MC_dwarf_handle_type_die(mc_object_info_t info, Dwarf_Die * die, static int mc_anonymous_variable_index = 0; static std::unique_ptr MC_die_to_variable( - mc_object_info_t info, Dwarf_Die * die, - Dwarf_Die * unit, mc_frame_t frame, + simgrid::mc::ObjectInformation* info, Dwarf_Die * die, + Dwarf_Die * unit, simgrid::mc::Frame* frame, const char *ns) { // Skip declarations: @@ -814,8 +814,8 @@ static std::unique_ptr MC_die_to_variable( return std::move(variable); } -static void MC_dwarf_handle_variable_die(mc_object_info_t info, Dwarf_Die * die, - Dwarf_Die * unit, mc_frame_t frame, +static void MC_dwarf_handle_variable_die(simgrid::mc::ObjectInformation* info, Dwarf_Die * die, + Dwarf_Die * unit, simgrid::mc::Frame* frame, const char *ns) { std::unique_ptr variable = @@ -831,8 +831,8 @@ static void MC_dwarf_handle_variable_die(mc_object_info_t info, Dwarf_Die * die, xbt_die("No frame for this local variable"); } -static void MC_dwarf_handle_scope_die(mc_object_info_t info, Dwarf_Die * die, - Dwarf_Die * unit, mc_frame_t parent_frame, +static void MC_dwarf_handle_scope_die(simgrid::mc::ObjectInformation* info, Dwarf_Die * die, + Dwarf_Die * unit, simgrid::mc::Frame* parent_frame, const char *ns) { // TODO, handle DW_TAG_type/DW_TAG_location for DW_TAG_with_stmt @@ -926,9 +926,9 @@ static void MC_dwarf_handle_scope_die(mc_object_info_t info, Dwarf_Die * die, parent_frame->scopes.push_back(std::move(frame)); } -static void mc_dwarf_handle_namespace_die(mc_object_info_t info, +static void mc_dwarf_handle_namespace_die(simgrid::mc::ObjectInformation* info, Dwarf_Die * die, Dwarf_Die * unit, - mc_frame_t frame, + simgrid::mc::Frame* frame, const char *ns) { const char *name = MC_dwarf_attr_integrate_string(die, DW_AT_name); @@ -940,8 +940,8 @@ static void mc_dwarf_handle_namespace_die(mc_object_info_t info, xbt_free(new_ns); } -static void MC_dwarf_handle_children(mc_object_info_t info, Dwarf_Die * die, - Dwarf_Die * unit, mc_frame_t frame, +static void MC_dwarf_handle_children(simgrid::mc::ObjectInformation* info, Dwarf_Die * die, + Dwarf_Die * unit, simgrid::mc::Frame* frame, const char *ns) { // For each child DIE: @@ -953,8 +953,8 @@ static void MC_dwarf_handle_children(mc_object_info_t info, Dwarf_Die * die, } } -static void MC_dwarf_handle_die(mc_object_info_t info, Dwarf_Die * die, - Dwarf_Die * unit, mc_frame_t frame, +static void MC_dwarf_handle_die(simgrid::mc::ObjectInformation* info, Dwarf_Die * die, + Dwarf_Die * unit, simgrid::mc::Frame* frame, const char *ns) { int tag = dwarf_tag(die); @@ -992,7 +992,7 @@ static void MC_dwarf_handle_die(mc_object_info_t info, Dwarf_Die * die, * Read the DWARf information of the EFFL object and populate the * lists of types, variables, functions. */ -void MC_dwarf_get_variables(mc_object_info_t info) +void MC_dwarf_get_variables(simgrid::mc::ObjectInformation* info) { int fd = open(info->file_name.c_str(), O_RDONLY); if (fd < 0) @@ -1039,7 +1039,7 @@ static int MC_compare_frame_index_items(simgrid::mc::FunctionIndexEntry* a, return 1; } -static void MC_make_functions_index(mc_object_info_t info) +static void MC_make_functions_index(simgrid::mc::ObjectInformation* info) { info->functions_index.clear(); @@ -1063,7 +1063,7 @@ static void MC_make_functions_index(mc_object_info_t info) }); } -static void MC_post_process_variables(mc_object_info_t info) +static void MC_post_process_variables(simgrid::mc::ObjectInformation* info) { // Someone needs this to be sorted but who? std::sort(info->global_variables.begin(), info->global_variables.end(), @@ -1076,7 +1076,7 @@ static void MC_post_process_variables(mc_object_info_t info) } } -static void mc_post_process_scope(mc_object_info_t info, mc_frame_t scope) +static void mc_post_process_scope(simgrid::mc::ObjectInformation* info, simgrid::mc::Frame* scope) { if (scope->tag == DW_TAG_inlined_subroutine) { @@ -1103,7 +1103,7 @@ static void mc_post_process_scope(mc_object_info_t info, mc_frame_t scope) /** \brief Fill/lookup the "subtype" field. */ -static void MC_resolve_subtype(mc_object_info_t info, mc_type_t type) +static void MC_resolve_subtype(simgrid::mc::ObjectInformation* info, simgrid::mc::Type* type) { if (!type->type_id) return; @@ -1122,7 +1122,7 @@ static void MC_resolve_subtype(mc_object_info_t info, mc_type_t type) type->subtype = *subtype; } -static void MC_post_process_types(mc_object_info_t info) +static void MC_post_process_types(simgrid::mc::ObjectInformation* info) { // Lookup "subtype" field: for(auto& i : info->types) { @@ -1133,11 +1133,11 @@ static void MC_post_process_types(mc_object_info_t info) } /** \brief Finds informations about a given shared object/executable */ -std::shared_ptr MC_find_object_info( +std::shared_ptr MC_find_object_info( std::vector const& maps, const char *name, int executable) { - std::shared_ptr result = - std::make_shared(); + std::shared_ptr result = + std::make_shared(); if (executable) result->flags |= MC_OBJECT_INFO_EXECUTABLE; result->file_name = name; @@ -1153,12 +1153,12 @@ std::shared_ptr MC_find_object_info( /*************************************************************************/ -void MC_post_process_object_info(mc_process_t process, mc_object_info_t info) +void MC_post_process_object_info(simgrid::mc::Process* process, simgrid::mc::ObjectInformation* info) { for (auto& i : info->types) { - mc_type_t type = &(i.second); - mc_type_t subtype = type; + simgrid::mc::Type* type = &(i.second); + simgrid::mc::Type* subtype = type; while (subtype->type == DW_TAG_typedef || subtype->type == DW_TAG_volatile_type || subtype->type == DW_TAG_const_type) { if (subtype->subtype) diff --git a/src/mc/mc_dwarf_expression.cpp b/src/mc/mc_dwarf_expression.cpp index 3e4d99e873..cc4b93076a 100644 --- a/src/mc/mc_dwarf_expression.cpp +++ b/src/mc/mc_dwarf_expression.cpp @@ -430,10 +430,10 @@ int mc_dwarf_execute_expression(size_t n, const Dwarf_Op * ops, */ void mc_dwarf_resolve_location(mc_location_t location, simgrid::mc::DwarfExpression* expression, - mc_object_info_t object_info, + simgrid::mc::ObjectInformation* object_info, unw_cursor_t * c, void *frame_pointer_address, - mc_address_space_t address_space, int process_index) + simgrid::mc::AddressSpace* address_space, int process_index) { s_mc_expression_state_t state; memset(&state, 0, sizeof(s_mc_expression_state_t)); @@ -480,10 +480,10 @@ static simgrid::mc::DwarfExpression* mc_find_expression( void mc_dwarf_resolve_locations(mc_location_t location, simgrid::mc::LocationList* locations, - mc_object_info_t object_info, + simgrid::mc::ObjectInformation* object_info, unw_cursor_t * c, void *frame_pointer_address, - mc_address_space_t address_space, + simgrid::mc::AddressSpace* address_space, int process_index) { @@ -508,7 +508,7 @@ void mc_dwarf_resolve_locations(mc_location_t location, * \param frame * \param unw_cursor */ -void *mc_find_frame_base(mc_frame_t frame, mc_object_info_t object_info, +void *mc_find_frame_base(simgrid::mc::Frame* frame, simgrid::mc::ObjectInformation* object_info, unw_cursor_t * unw_cursor) { s_mc_location_t location; @@ -537,7 +537,7 @@ void *mc_find_frame_base(mc_frame_t frame, mc_object_info_t object_info, } void mc_dwarf_location_list_init( - simgrid::mc::LocationList* list, mc_object_info_t info, + simgrid::mc::LocationList* list, simgrid::mc::ObjectInformation* info, Dwarf_Die * die, Dwarf_Attribute * attr) { list->clear(); diff --git a/src/mc/mc_forward.h b/src/mc/mc_forward.h index 42edadfa2d..a3a56e6df3 100644 --- a/src/mc/mc_forward.h +++ b/src/mc/mc_forward.h @@ -4,68 +4,27 @@ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ +/** \file mc_forward.h + * + * Define type names for pointers of MC objects for the C code + */ + #ifndef SIMGRID_MC_FORWARD_H #define SIMGRID_MC_FORWARD_H -#include -#include - #ifdef __cplusplus -#define MC_OVERRIDE - -namespace simgrid { -namespace mc { - -class PageStore; -class ModelChecker; -class AddressSpace; -class Process; -class Snapshot; -class ObjectInformation; -class Type; -class Variable; -class Frame; - -} -} - -typedef ::simgrid::mc::ModelChecker s_mc_model_checker_t; -typedef ::simgrid::mc::PageStore s_mc_pages_store_t; -typedef ::simgrid::mc::AddressSpace s_mc_address_space_t; -typedef ::simgrid::mc::Process s_mc_process_t; -typedef ::simgrid::mc::Snapshot s_mc_snapshot_t; -typedef ::simgrid::mc::ObjectInformation s_mc_object_info_t; -typedef ::simgrid::mc::Type s_mc_type_t; -typedef ::simgrid::mc::Variable s_mc_variable_t; -typedef ::simgrid::mc::Frame s_mc_frame_t; +// If we're in C++, we give the real definition: +#include "mc_forward.hpp" +typedef simgrid::mc::Snapshot *mc_snapshot_t; +typedef simgrid::mc::Type *mc_type_t; #else -typedef struct _s_mc_model_checker s_mc_model_checker_t; -typedef struct _s_mc_pages_store s_mc_pages_store_t; -typedef struct _s_mc_address_space_t s_mc_address_space_t; -typedef struct _s_mc_process_t s_mc_process_t; -typedef struct _s_mc_snapshot_t s_mc_snapshot_t; -typedef struct _s_mc_object_info_t s_mc_object_info_t; -typedef struct _s_mc_type_t s_mc_type_t; -typedef struct _s_mc_variable_t s_mc_variable_t; -typedef struct _s_mc_frame_t s_mc_frame_t; +// Otherwise we use dummy opaque structs: +typedef struct _mc_snapshot_t *mc_snapshot_t; +typedef struct _s_mc_type_t *mc_type_t; #endif -typedef s_mc_pages_store_t *mc_pages_store_t; -typedef s_mc_model_checker_t *mc_model_checker_t; -typedef s_mc_address_space_t *mc_address_space_t; -typedef s_mc_process_t *mc_process_t; -typedef s_mc_snapshot_t *mc_snapshot_t; -typedef s_mc_object_info_t *mc_object_info_t; -typedef s_mc_type_t *mc_type_t; -typedef s_mc_variable_t *mc_variable_t; -typedef s_mc_frame_t *mc_frame_t; - -SG_BEGIN_DECL() -extern mc_model_checker_t mc_model_checker; -SG_END_DECL() - #endif diff --git a/src/mc/mc_forward.hpp b/src/mc/mc_forward.hpp new file mode 100644 index 0000000000..9bb9813349 --- /dev/null +++ b/src/mc/mc_forward.hpp @@ -0,0 +1,36 @@ +/* Copyright (c) 2007-2014. The SimGrid Team. + * All rights reserved. */ + +/* This program is free software; you can redistribute it and/or modify it + * under the terms of the license (GNU LGPL) which comes with this package. */ + +/** \file mc_forward.hpp + * + * Forward definitions for MC types + */ + +#ifndef SIMGRID_MC_FORWARD_HPP +#define SIMGRID_MC_FORWARD_HPP + +#define MC_OVERRIDE + +namespace simgrid { +namespace mc { + +class PageStore; +class ModelChecker; +class AddressSpace; +class Process; +class Snapshot; +class ObjectInformation; +class Type; +class Variable; +class Frame; + +} +} + +// TODO, try to get rid of the global ModelChecker variable +extern simgrid::mc::ModelChecker* mc_model_checker; + +#endif diff --git a/src/mc/mc_hash.cpp b/src/mc/mc_hash.cpp index ea71646c43..602fcedec5 100644 --- a/src/mc/mc_hash.cpp +++ b/src/mc/mc_hash.cpp @@ -83,10 +83,10 @@ static void mc_hash_binary(hash_type * hash, const void *s, size_t len) * \param type type of the variable * */ static void mc_hash_value(hash_type * hash, mc_hashing_state * state, - mc_object_info_t info, const void *address, - mc_type_t type) + simgrid::mc::ObjectInformation* info, const void *address, + simgrid::mc::Type* type) { - mc_process_t process = &mc_model_checker->process(); + simgrid::mc::Process* process = &mc_model_checker->process(); top: switch (type->type) { @@ -111,7 +111,7 @@ top: return; long element_count = type->element_count; - mc_type_t subtype = type->subtype; + simgrid::mc::Type* subtype = type->subtype; if (subtype == NULL) { XBT_DEBUG("Hash array without subtype"); return; @@ -145,7 +145,7 @@ top: return; unsigned int cursor = 0; - mc_type_t member; + simgrid::mc::Type* member; xbt_dynar_foreach(type->members, cursor, member) { XBT_DEBUG("Hash struct member %s", member->name); if (type->subtype == NULL) @@ -208,10 +208,10 @@ top: } static void mc_hash_object_globals(hash_type * hash, mc_hashing_state * state, - mc_object_info_t info) + simgrid::mc::ObjectInformation* info) { unsigned int cursor = 0; - mc_variable_t variable; + simgrid::mc::Variable* variable; xbt_dynar_foreach(info->global_variables, cursor, variable) { XBT_DEBUG("Hash global variable %s", variable->name); @@ -220,7 +220,7 @@ static void mc_hash_object_globals(hash_type * hash, mc_hashing_state * state, continue; } - mc_type_t type = variable->type; + simgrid::mc::Type* type = variable->type; if (type == NULL) { // Nothing continue; @@ -241,15 +241,15 @@ static void mc_hash_object_globals(hash_type * hash, mc_hashing_state * state, } static void mc_hash_stack_frame(mc_hash_t * hash, - mc_object_info_t info, - unw_cursor_t * unw_cursor, mc_frame_t frame, + simgrid::mc::ObjectInformation* info, + unw_cursor_t * unw_cursor, simgrid::mc::Frame* frame, char *frame_pointer, mc_hashing_state * state) { // return; // TEMP unsigned int cursor = 0; - mc_variable_t variable; + simgrid::mc::Variable* variable; xbt_dynar_foreach(frame->variables, cursor, variable) { if (variable->type_id == NULL) { @@ -268,7 +268,7 @@ static void mc_hash_stack_frame(mc_hash_t * hash, variable->object_info, unw_cursor, frame_pointer, NULL); - mc_type_t type = variable->type; + simgrid::mc::Type* type = variable->type; if (type == NULL) { XBT_DEBUG("Hash local variable %s without loctypeation", variable->name); continue; @@ -291,7 +291,7 @@ static void mc_hash_stack(mc_hash_t * hash, mc_snapshot_stack_t stack, hash_update(*hash, stack_frame.ip); - mc_object_info_t info; + simgrid::mc::ObjectInformation* info; if (stack_frame.ip >= (unw_word_t) libsimgrid_info->start_exec && stack_frame.ip < (unw_word_t) libsimgrid_info->end_exec) info = libsimgrid_info; diff --git a/src/mc/mc_location.h b/src/mc/mc_location.h index 7f603281a8..76a2a26ec0 100644 --- a/src/mc/mc_location.h +++ b/src/mc/mc_location.h @@ -17,7 +17,7 @@ #include #include "mc_base.h" -#include "mc_forward.h" +#include "mc_forward.hpp" #include "AddressSpace.hpp" namespace simgrid { @@ -92,17 +92,17 @@ enum mc_location_type mc_get_location_type(mc_location_t location) { XBT_INTERNAL void mc_dwarf_resolve_location( mc_location_t location, simgrid::mc::DwarfExpression* expression, - mc_object_info_t object_info, unw_cursor_t* c, - void* frame_pointer_address, mc_address_space_t address_space, + simgrid::mc::ObjectInformation* object_info, unw_cursor_t* c, + void* frame_pointer_address, simgrid::mc::AddressSpace* address_space, int process_index); MC_SHOULD_BE_INTERNAL void mc_dwarf_resolve_locations( mc_location_t location, simgrid::mc::LocationList* locations, - mc_object_info_t object_info, unw_cursor_t* c, - void* frame_pointer_address, mc_address_space_t address_space, + simgrid::mc::ObjectInformation* object_info, unw_cursor_t* c, + void* frame_pointer_address, simgrid::mc::AddressSpace* address_space, int process_index); XBT_INTERNAL void mc_dwarf_location_list_init( - simgrid::mc::LocationList*, mc_object_info_t info, Dwarf_Die* die, + simgrid::mc::LocationList*, simgrid::mc::ObjectInformation* info, Dwarf_Die* die, Dwarf_Attribute* attr); #define MC_EXPRESSION_STACK_SIZE 64 @@ -121,8 +121,8 @@ typedef struct s_mc_expression_state { unw_cursor_t* cursor; void* frame_base; - mc_address_space_t address_space; - mc_object_info_t object_info; + simgrid::mc::AddressSpace* address_space; + simgrid::mc::ObjectInformation* object_info; int process_index; } s_mc_expression_state_t, *mc_expression_state_t; @@ -130,7 +130,7 @@ MC_SHOULD_BE_INTERNAL int mc_dwarf_execute_expression( size_t n, const Dwarf_Op* ops, mc_expression_state_t state); MC_SHOULD_BE_INTERNAL void* mc_find_frame_base( - mc_frame_t frame, mc_object_info_t object_info, unw_cursor_t* unw_cursor); + simgrid::mc::Frame* frame, simgrid::mc::ObjectInformation* object_info, unw_cursor_t* unw_cursor); SG_END_DECL() diff --git a/src/mc/mc_member.cpp b/src/mc/mc_member.cpp index b96a30fbb6..59e7e7d06c 100644 --- a/src/mc/mc_member.cpp +++ b/src/mc/mc_member.cpp @@ -17,8 +17,8 @@ * @param snapshot Snapshot (or NULL) * @return Process address of the given member of the 'object' struct/class */ -void *mc_member_resolve(const void *base, mc_type_t type, mc_type_t member, - mc_address_space_t address_space, int process_index) +void *mc_member_resolve(const void *base, simgrid::mc::Type* type, simgrid::mc::Type* member, + simgrid::mc::AddressSpace* address_space, int process_index) { // TODO, get rid of this? if (!member->has_offset_location()) diff --git a/src/mc/mc_memory_map.h b/src/mc/mc_memory_map.h index 21f2bdd44f..27844ada08 100644 --- a/src/mc/mc_memory_map.h +++ b/src/mc/mc_memory_map.h @@ -14,8 +14,10 @@ #include +#include + #include -#include "mc_forward.h" +#include "mc_forward.hpp" namespace simgrid { namespace mc { @@ -40,7 +42,7 @@ std::vector get_memory_map(pid_t pid); extern "C" { XBT_INTERNAL void MC_find_object_address( - std::vector const& maps, mc_object_info_t result); + std::vector const& maps, simgrid::mc::ObjectInformation* result); } diff --git a/src/mc/mc_object_info.cpp b/src/mc/mc_object_info.cpp index 11817a2c03..a582e21a1f 100644 --- a/src/mc/mc_object_info.cpp +++ b/src/mc/mc_object_info.cpp @@ -108,7 +108,7 @@ void *ObjectInformation::base_address() const } /* Find a function by instruction pointer */ -mc_frame_t ObjectInformation::find_function(const void *ip) const +simgrid::mc::Frame* ObjectInformation::find_function(const void *ip) const { /* This is implemented by binary search on a sorted array. * diff --git a/src/mc/mc_object_info.h b/src/mc/mc_object_info.h index b175daf92c..c04b917c38 100644 --- a/src/mc/mc_object_info.h +++ b/src/mc/mc_object_info.h @@ -23,7 +23,7 @@ #include -#include "mc_forward.h" +#include "mc_forward.hpp" #include "mc_location.h" #include "mc_process.h" #include "../smpi/private.h" @@ -59,8 +59,8 @@ public: // Location (for members) is either of: simgrid::mc::DwarfExpression location_expression; - mc_type_t subtype; // DW_AT_type - mc_type_t full_type; // The same (but more complete) type + simgrid::mc::Type* subtype; // DW_AT_type + simgrid::mc::Type* full_type; // The same (but more complete) type bool has_offset_location() const { @@ -105,14 +105,14 @@ public: int global; std::string name; std::uint64_t type_id; - mc_type_t type; + simgrid::mc::Type* type; // Use either of: simgrid::mc::LocationList location_list; void* address; size_t start_scope; - mc_object_info_t object_info; + simgrid::mc::ObjectInformation* object_info; }; class Frame { @@ -128,7 +128,7 @@ public: unsigned long int id; /* DWARF offset of the subprogram */ std::vector scopes; Dwarf_Off abstract_origin_id; - mc_object_info_t object_info; + simgrid::mc::ObjectInformation* object_info; }; /** An entry in the functions index @@ -137,7 +137,7 @@ public: */ struct FunctionIndexEntry { void* low_pc; - mc_frame_t function; + simgrid::mc::Frame* function; }; /** Information about an (ELF) executable/sharedobject @@ -200,7 +200,7 @@ public: void* base_address() const; - mc_frame_t find_function(const void *ip) const; + simgrid::mc::Frame* find_function(const void *ip) const; // TODO, should be simgrid::mc::Variable* simgrid::mc::Variable* find_variable(const char* name) const; @@ -210,17 +210,17 @@ public: } -XBT_INTERNAL std::shared_ptr MC_find_object_info( +XBT_INTERNAL std::shared_ptr MC_find_object_info( std::vector const& maps, const char* name, int executable); -XBT_INTERNAL void MC_post_process_object_info(mc_process_t process, mc_object_info_t info); +XBT_INTERNAL void MC_post_process_object_info(simgrid::mc::Process* process, simgrid::mc::ObjectInformation* info); -XBT_INTERNAL void MC_dwarf_get_variables(mc_object_info_t info); -XBT_INTERNAL void MC_dwarf_get_variables_libdw(mc_object_info_t info); +XBT_INTERNAL void MC_dwarf_get_variables(simgrid::mc::ObjectInformation* info); +XBT_INTERNAL void MC_dwarf_get_variables_libdw(simgrid::mc::ObjectInformation* info); XBT_INTERNAL const char* MC_dwarf_attrname(int attr); XBT_INTERNAL const char* MC_dwarf_tagname(int tag); XBT_INTERNAL void* mc_member_resolve( - const void* base, mc_type_t type, mc_type_t member, - mc_address_space_t snapshot, int process_index); + const void* base, simgrid::mc::Type* type, simgrid::mc::Type* member, + simgrid::mc::AddressSpace* snapshot, int process_index); #endif diff --git a/src/mc/mc_page_snapshot.cpp b/src/mc/mc_page_snapshot.cpp index 7bb42f03d1..91dfcbd961 100644 --- a/src/mc/mc_page_snapshot.cpp +++ b/src/mc/mc_page_snapshot.cpp @@ -69,7 +69,7 @@ extern "C" { * @param page_count Number of pages of the region * @param pagenos */ -void mc_restore_page_snapshot_region(mc_process_t process, +void mc_restore_page_snapshot_region(simgrid::mc::Process* process, void* start_addr, simgrid::mc::PerPageCopy const& pages_copy) { for (size_t i = 0; i != pages_copy.page_count(); ++i) { @@ -82,7 +82,7 @@ void mc_restore_page_snapshot_region(mc_process_t process, // ***** High level API -void mc_region_restore_sparse(mc_process_t process, mc_mem_region_t reg) +void mc_region_restore_sparse(simgrid::mc::Process* process, mc_mem_region_t reg) { xbt_assert(((reg->permanent_address().address()) & (xbt_pagesize-1)) == 0, "Not at the beginning of a page"); diff --git a/src/mc/mc_process.cpp b/src/mc/mc_process.cpp index fda88dd9ed..2cc2b04d2c 100644 --- a/src/mc/mc_process.cpp +++ b/src/mc/mc_process.cpp @@ -218,7 +218,7 @@ Process::Process(pid_t pid, int sockfd) } // Read std_heap (is a struct mdesc*): - mc_variable_t std_heap_var = process->find_variable("__mmalloc_default_mdp"); + simgrid::mc::Variable* std_heap_var = process->find_variable("__mmalloc_default_mdp"); if (!std_heap_var) xbt_die("No heap information in the target process"); if(!std_heap_var->address) @@ -377,7 +377,7 @@ void Process::init_memory_map_info() } } - std::shared_ptr info = + std::shared_ptr info = MC_find_object_info(this->memory_map_, pathname, is_executable); this->object_infos.push_back(info); if (is_executable) @@ -400,7 +400,7 @@ void Process::init_memory_map_info() XBT_DEBUG("Get debug information done !"); } -std::shared_ptr Process::find_object_info(remote_ptr addr) const +std::shared_ptr Process::find_object_info(remote_ptr addr) const { for (auto const& object_info : this->object_infos) { if (addr.address() >= (std::uint64_t)object_info->start @@ -433,29 +433,29 @@ std::shared_ptr Process::find_object_info_rw(remote_ptr return nullptr; } -mc_frame_t Process::find_function(remote_ptr ip) const +simgrid::mc::Frame* Process::find_function(remote_ptr ip) const { - std::shared_ptr info = this->find_object_info_exec(ip); + std::shared_ptr info = this->find_object_info_exec(ip); return info ? info->find_function((void*) ip.address()) : nullptr; } /** Find (one occurence of) the named variable definition */ -mc_variable_t Process::find_variable(const char* name) const +simgrid::mc::Variable* Process::find_variable(const char* name) const { // First lookup the variable in the executable shared object. // A global variable used directly by the executable code from a library // is reinstanciated in the executable memory .data/.bss. // We need to look up the variable in the execvutable first. if (this->binary_info) { - std::shared_ptr const& info = this->binary_info; - mc_variable_t var = info->find_variable(name); + std::shared_ptr const& info = this->binary_info; + simgrid::mc::Variable* var = info->find_variable(name); if (var) return var; } - for (std::shared_ptr const& info : this->object_infos) { - mc_variable_t var = info->find_variable(name); + for (std::shared_ptr const& info : this->object_infos) { + simgrid::mc::Variable* var = info->find_variable(name); if (var) return var; } @@ -465,7 +465,7 @@ mc_variable_t Process::find_variable(const char* name) const void Process::read_variable(const char* name, void* target, size_t size) const { - mc_variable_t var = this->find_variable(name); + simgrid::mc::Variable* var = this->find_variable(name); if (!var->address) xbt_die("No simple location for this variable"); if (!var->type->full_type) @@ -515,7 +515,7 @@ const void *Process::read_bytes(void* buffer, std::size_t size, AddressSpace::ReadMode mode) const { if (process_index != simgrid::mc::ProcessIndexDisabled) { - std::shared_ptr const& info = + std::shared_ptr const& info = this->find_object_info_rw((void*)address.address()); // Segment overlap is not handled. if (info.get() && info.get()->privatized()) { diff --git a/src/mc/mc_process.h b/src/mc/mc_process.h index 3215c4fb82..8aee3c0900 100644 --- a/src/mc/mc_process.h +++ b/src/mc/mc_process.h @@ -27,7 +27,7 @@ #include "simix/popping_private.h" #include "simix/smx_private.h" -#include "mc_forward.h" +#include "mc_forward.hpp" #include "mc_base.h" #include "mc_mmalloc.h" // std_heap #include "mc_memory_map.h" @@ -89,11 +89,11 @@ public: void clear_bytes(remote_ptr address, size_t len); // Debug information: - std::shared_ptr find_object_info(remote_ptr addr) const; - std::shared_ptr find_object_info_exec(remote_ptr addr) const; - std::shared_ptr find_object_info_rw(remote_ptr addr) const; - mc_frame_t find_function(remote_ptr ip) const; - mc_variable_t find_variable(const char* name) const; + std::shared_ptr find_object_info(remote_ptr addr) const; + std::shared_ptr find_object_info_exec(remote_ptr addr) const; + std::shared_ptr find_object_info_rw(remote_ptr addr) const; + simgrid::mc::Frame* find_function(remote_ptr ip) const; + simgrid::mc::Variable* find_variable(const char* name) const; // Heap access: xbt_mheap_t get_heap() @@ -173,10 +173,10 @@ private: std::vector ignored_regions_; public: // object info - // TODO, make private (first, objectify mc_object_info_t) - std::vector> object_infos; - std::shared_ptr libsimgrid_info; - std::shared_ptr binary_info; + // TODO, make private (first, objectify simgrid::mc::ObjectInformation*) + std::vector> object_infos; + std::shared_ptr libsimgrid_info; + std::shared_ptr binary_info; public: // Copies of MCed SMX data structures /** Copy of `simix_global->process_list` @@ -218,7 +218,8 @@ public: // Libunwind-data /** Full-featured MC-aware libunwind address space for the process * * This address space is using a mc_unw_context_t - * (with mc_process_t/mc_address_space_t and unw_context_t). + * (with simgrid::mc::Process* / simgrid::mc::AddressSpace* + * and unw_context_t). */ unw_addr_space_t unw_addr_space; diff --git a/src/mc/mc_safety.h b/src/mc/mc_safety.h index bd5ab1fe8c..8e47e8951d 100644 --- a/src/mc/mc_safety.h +++ b/src/mc/mc_safety.h @@ -11,7 +11,7 @@ #include #include -#include "mc_forward.h" +#include "mc_forward.hpp" #include "mc_state.h" SG_BEGIN_DECL() diff --git a/src/mc/mc_server.cpp b/src/mc/mc_server.cpp index 020e170057..b8825045c8 100644 --- a/src/mc/mc_server.cpp +++ b/src/mc/mc_server.cpp @@ -37,7 +37,7 @@ mc_server_t mc_server; struct mc_symbol_pointer_callback { - mc_process_t process; + simgrid::mc::Process* process; void* value; }; @@ -95,7 +95,7 @@ void s_mc_server::shutdown() { XBT_DEBUG("Shuting down model-checker"); - mc_process_t process = &mc_model_checker->process(); + simgrid::mc::Process* process = &mc_model_checker->process(); int status = process->status(); if (process->running()) { XBT_DEBUG("Killing process"); @@ -123,7 +123,7 @@ void s_mc_server::exit() } } -void s_mc_server::resume(mc_process_t process) +void s_mc_server::resume(simgrid::mc::Process* process) { int res = process->send_message(MC_MESSAGE_CONTINUE); if (res) @@ -336,7 +336,7 @@ void s_mc_server::on_signal(const struct signalfd_siginfo* info) } } -void MC_server_wait_client(mc_process_t process) +void MC_server_wait_client(simgrid::mc::Process* process) { mc_server->resume(process); while (mc_model_checker->process().running()) { @@ -345,7 +345,7 @@ void MC_server_wait_client(mc_process_t process) } } -void MC_server_simcall_handle(mc_process_t process, unsigned long pid, int value) +void MC_server_simcall_handle(simgrid::mc::Process* process, unsigned long pid, int value) { s_mc_simcall_handle_message m; memset(&m, 0, sizeof(m)); diff --git a/src/mc/mc_server.h b/src/mc/mc_server.h index e2c1a2300a..7a54eccc1a 100644 --- a/src/mc/mc_server.h +++ b/src/mc/mc_server.h @@ -28,8 +28,8 @@ typedef struct s_mc_server s_mc_server_t, *mc_server_t; extern mc_server_t mc_server; -XBT_INTERNAL void MC_server_wait_client(mc_process_t process); -XBT_INTERNAL void MC_server_simcall_handle(mc_process_t process, unsigned long pid, int value); +XBT_INTERNAL void MC_server_wait_client(simgrid::mc::Process* process); +XBT_INTERNAL void MC_server_simcall_handle(simgrid::mc::Process* process, unsigned long pid, int value); XBT_INTERNAL void MC_server_loop(mc_server_t server); @@ -47,7 +47,7 @@ public: void start(); void shutdown(); void exit(); - void resume(mc_process_t process); + void resume(simgrid::mc::Process* process); void loop(); bool handle_events(); protected: diff --git a/src/mc/mc_smx.cpp b/src/mc/mc_smx.cpp index 8372875bd8..805d655e5c 100644 --- a/src/mc/mc_smx.cpp +++ b/src/mc/mc_smx.cpp @@ -57,7 +57,7 @@ mc_smx_process_info_t MC_smx_process_get_info(smx_process_t p) * @param remote_swag Address of the process SWAG in the remote list */ static void MC_process_refresh_simix_process_list( - mc_process_t process, + simgrid::mc::Process* process, xbt_dynar_t target, xbt_swag_t remote_swag) { // swag = REMOTE(*simix_global->process_list) @@ -84,7 +84,7 @@ static void MC_process_refresh_simix_process_list( assert(i == swag.count); } -void MC_process_smx_refresh(mc_process_t process) +void MC_process_smx_refresh(simgrid::mc::Process* process) { xbt_assert(mc_mode == MC_MODE_SERVER); xbt_assert(!process->is_self()); @@ -178,7 +178,7 @@ const char* MC_smx_process_get_host_name(smx_process_t p) if (mc_mode == MC_MODE_CLIENT) return SIMIX_host_get_name(p->smx_host); - mc_process_t process = &mc_model_checker->process(); + simgrid::mc::Process* process = &mc_model_checker->process(); // Currently, smx_host_t = xbt_dictelm_t. // TODO, add an static_assert on this if switching to C++ @@ -199,7 +199,7 @@ const char* MC_smx_process_get_host_name(smx_process_t p) const char* MC_smx_process_get_name(smx_process_t p) { - mc_process_t process = &mc_model_checker->process(); + simgrid::mc::Process* process = &mc_model_checker->process(); if (mc_mode == MC_MODE_CLIENT) return p->name; if (!p->name) diff --git a/src/mc/mc_smx.h b/src/mc/mc_smx.h index 49d69be4d4..c9cdd7aa11 100644 --- a/src/mc/mc_smx.h +++ b/src/mc/mc_smx.h @@ -33,7 +33,7 @@ * * The process lists are currently refreshed each time MCed code is executed. * We don't try to give a persistent MCer address for a given MCed process. - * For this reason, a MCer mc_process_t is currently not reusable after + * For this reason, a MCer simgrid::mc::Process* is currently not reusable after * MCed code. */ @@ -51,7 +51,7 @@ struct s_mc_smx_process_info { XBT_INTERNAL xbt_dynar_t MC_smx_process_info_list_new(void); -XBT_INTERNAL void MC_process_smx_refresh(mc_process_t process); +XBT_INTERNAL void MC_process_smx_refresh(simgrid::mc::Process* process); /** Get the issuer of a simcall (`req->issuer`) * diff --git a/src/mc/mc_snapshot.cpp b/src/mc/mc_snapshot.cpp index bfc3d89236..3277f97ec3 100644 --- a/src/mc/mc_snapshot.cpp +++ b/src/mc/mc_snapshot.cpp @@ -24,7 +24,7 @@ extern "C" { * (or NULL if it does not belong to any snapshot region) * */ mc_mem_region_t mc_get_snapshot_region( - const void* addr, const s_mc_snapshot_t* snapshot, int process_index) + const void* addr, const simgrid::mc::Snapshot* snapshot, int process_index) { size_t n = snapshot->snapshot_regions.size(); for (size_t i = 0; i != n; ++i) { diff --git a/src/mc/mc_snapshot.h b/src/mc/mc_snapshot.h index 2c9784838e..418278d948 100644 --- a/src/mc/mc_snapshot.h +++ b/src/mc/mc_snapshot.h @@ -19,7 +19,7 @@ #include #include -#include "mc_forward.h" +#include "mc_forward.hpp" #include "ModelChecker.hpp" #include "PageStore.hpp" #include "mc_mmalloc.h" @@ -31,7 +31,7 @@ SG_BEGIN_DECL() // ***** Snapshot region -XBT_INTERNAL void mc_region_restore_sparse(mc_process_t process, mc_mem_region_t reg); +XBT_INTERNAL void mc_region_restore_sparse(simgrid::mc::Process* process, mc_mem_region_t reg); static inline __attribute__((always_inline)) void* mc_translate_address_region_chunked(uintptr_t addr, mc_mem_region_t region) @@ -72,7 +72,7 @@ void* mc_translate_address_region(uintptr_t addr, mc_mem_region_t region, int pr } XBT_INTERNAL mc_mem_region_t mc_get_snapshot_region( - const void* addr, const s_mc_snapshot_t *snapshot, int process_index); + const void* addr, const simgrid::mc::Snapshot *snapshot, int process_index); } @@ -104,16 +104,16 @@ typedef struct s_mc_stack_frame { /** Stack pointer */ unw_word_t sp; unw_word_t frame_base; - mc_frame_t frame; + simgrid::mc::Frame* frame; std::string frame_name; unw_cursor_t unw_cursor; } s_mc_stack_frame_t, *mc_stack_frame_t; typedef struct s_local_variable{ - mc_frame_t subprogram; + simgrid::mc::Frame* subprogram; unsigned long ip; std::string name; - mc_type_t type; + simgrid::mc::Type* type; void *address; int region; } s_local_variable_t, *local_variable_t; @@ -147,7 +147,7 @@ public: remote_ptr address, int process_index = ProcessIndexAny, ReadMode mode = Normal) const MC_OVERRIDE; public: // To be private - mc_process_t process; + simgrid::mc::Process* process; int num_state; size_t heap_bytes_used; std::vector> snapshot_regions; @@ -181,7 +181,7 @@ XBT_INTERNAL mc_snapshot_t MC_take_snapshot(int num_state); XBT_INTERNAL void MC_restore_snapshot(mc_snapshot_t); XBT_INTERNAL void mc_restore_page_snapshot_region( - mc_process_t process, + simgrid::mc::Process* process, void* start_addr, simgrid::mc::PerPageCopy const& pagenos); MC_SHOULD_BE_INTERNAL const void* MC_region_read_fragmented( diff --git a/src/mc/mc_unw.cpp b/src/mc/mc_unw.cpp index dc688ee3d2..0d7830508a 100644 --- a/src/mc/mc_unw.cpp +++ b/src/mc/mc_unw.cpp @@ -74,7 +74,7 @@ static int get_dyn_info_list_addr(unw_addr_space_t as, /** Read from the target address space memory (libunwind method) * - * Delegates to the `mc_process_t`. + * Delegates to the `simgrid::mc::Process*`. */ static int access_mem(unw_addr_space_t as, unw_word_t addr, unw_word_t *valp, @@ -164,7 +164,7 @@ static int get_proc_name(unw_addr_space_t as, void* arg) { mc_unw_context_t context = (mc_unw_context_t) arg; - mc_frame_t frame = context->process->find_function(remote(addr)); + simgrid::mc::Frame* frame = context->process->find_function(remote(addr)); if (!frame) return - UNW_ENOINFO; *offp = (unw_word_t) frame->low_pc - addr; @@ -195,7 +195,7 @@ unw_accessors_t mc_unw_accessors = // ***** Context management int mc_unw_init_context( - mc_unw_context_t context, mc_process_t process, unw_context_t* c) + mc_unw_context_t context, simgrid::mc::Process* process, unw_context_t* c) { context->address_space = process; context->process = process; @@ -223,9 +223,9 @@ int mc_unw_init_cursor(unw_cursor_t *cursor, mc_unw_context_t context) { if (!context->process || !context->address_space) return -UNW_EUNSPEC; - mc_address_space_t as = context->address_space; + simgrid::mc::AddressSpace* as = context->address_space; - mc_process_t process = dynamic_cast(as); + simgrid::mc::Process* process = dynamic_cast(as); if (process && process->is_self()) return unw_init_local(cursor, &context->context); diff --git a/src/mc/mc_unw.h b/src/mc/mc_unw.h index eac812d778..7928d0b2c4 100644 --- a/src/mc/mc_unw.h +++ b/src/mc/mc_unw.h @@ -17,7 +17,7 @@ * * This component implements the libunwind API for he model-checker: * - * * reading memory from a mc_address_space_t; + * * reading memory from a simgrid::mc::AddressSpace*; * * * reading stack registers from a saved snapshot (context). * @@ -48,7 +48,7 @@ extern unw_accessors_t mc_unw_vmread_accessors; /** Virtual table for our `libunwind` implementation * - * Stack unwinding on a `mc_process_t` (for memory, unwinding information) + * Stack unwinding on a `simgrid::mc::Process*` (for memory, unwinding information) * and `ucontext_t` (for processor registers). * * It works with the `s_mc_unw_context_t` context. @@ -60,14 +60,14 @@ extern XBT_INTERNAL unw_accessors_t mc_unw_accessors; /** A `libunwind` context */ typedef struct s_mc_unw_context { - mc_address_space_t address_space; - mc_process_t process; + simgrid::mc::AddressSpace* address_space; + simgrid::mc::Process* process; unw_context_t context; } s_mc_unw_context_t, *mc_unw_context_t; /** Initialises an already allocated context */ XBT_INTERNAL int mc_unw_init_context( - mc_unw_context_t context, mc_process_t process, unw_context_t* c); + mc_unw_context_t context, simgrid::mc::Process* process, unw_context_t* c); // ***** Libunwind cursor diff --git a/src/mc/mc_visited.cpp b/src/mc/mc_visited.cpp index 4b19189c74..59c43c5c1a 100644 --- a/src/mc/mc_visited.cpp +++ b/src/mc/mc_visited.cpp @@ -54,7 +54,7 @@ void visited_state_free_voidp(void *s) */ static mc_visited_state_t visited_state_new() { - mc_process_t process = &(mc_model_checker->process()); + simgrid::mc::Process* process = &(mc_model_checker->process()); mc_visited_state_t new_state = xbt_new0(s_mc_visited_state_t, 1); new_state->heap_bytes_used = mmalloc_get_bytes_used_remote( process->get_heap()->heaplimit, @@ -76,7 +76,7 @@ static mc_visited_state_t visited_state_new() mc_visited_pair_t MC_visited_pair_new(int pair_num, xbt_automaton_state_t automaton_state, xbt_dynar_t atomic_propositions, mc_state_t graph_state) { - mc_process_t process = &(mc_model_checker->process()); + simgrid::mc::Process* process = &(mc_model_checker->process()); mc_visited_pair_t pair = NULL; pair = xbt_new0(s_mc_visited_pair_t, 1); pair->graph_state = graph_state; diff --git a/src/mc/mc_xbt.cpp b/src/mc/mc_xbt.cpp index 7742139b8a..5f1780b138 100644 --- a/src/mc/mc_xbt.cpp +++ b/src/mc/mc_xbt.cpp @@ -4,6 +4,8 @@ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ +#include + #include "mc/AddressSpace.hpp" #include "mc_xbt.hpp" diff --git a/src/mc/mcer_ignore.cpp b/src/mc/mcer_ignore.cpp index 4c752035be..1de7873988 100644 --- a/src/mc/mcer_ignore.cpp +++ b/src/mc/mcer_ignore.cpp @@ -111,17 +111,17 @@ void MC_heap_region_ignore_remove(void *address, size_t size) void MCer_ignore_global_variable(const char *name) { - mc_process_t process = &mc_model_checker->process(); + simgrid::mc::Process* process = &mc_model_checker->process(); xbt_assert(!process->object_infos.empty(), "MC subsystem not initialized"); - for (std::shared_ptr const& info : process->object_infos) { + for (std::shared_ptr const& info : process->object_infos) { // Binary search: int start = 0; int end = info->global_variables.size() - 1; while (start <= end) { unsigned int cursor = (start + end) / 2; - mc_variable_t current_var = &info->global_variables[cursor]; + simgrid::mc::Variable* current_var = &info->global_variables[cursor]; int cmp = strcmp(current_var->name.c_str(), name); if (cmp == 0) { info->global_variables.erase( @@ -141,25 +141,25 @@ void MCer_ignore_global_variable(const char *name) static void mc_ignore_local_variable_in_scope(const char *var_name, const char *subprogram_name, - mc_frame_t subprogram, - mc_frame_t scope); + simgrid::mc::Frame* subprogram, + simgrid::mc::Frame* scope); static void MC_ignore_local_variable_in_object(const char *var_name, const char *subprogram_name, - mc_object_info_t info); + simgrid::mc::ObjectInformation* info); void MC_ignore_local_variable(const char *var_name, const char *frame_name) { - mc_process_t process = &mc_model_checker->process(); + simgrid::mc::Process* process = &mc_model_checker->process(); if (strcmp(frame_name, "*") == 0) frame_name = NULL; - for (std::shared_ptr const& info : process->object_infos) + for (std::shared_ptr const& info : process->object_infos) MC_ignore_local_variable_in_object(var_name, frame_name, info.get()); } static void MC_ignore_local_variable_in_object(const char *var_name, const char *subprogram_name, - mc_object_info_t info) + simgrid::mc::ObjectInformation* info) { for (auto& entry : info->subprograms) mc_ignore_local_variable_in_scope( @@ -179,8 +179,8 @@ static void MC_ignore_local_variable_in_object(const char *var_name, */ static void mc_ignore_local_variable_in_scope(const char *var_name, const char *subprogram_name, - mc_frame_t subprogram, - mc_frame_t scope) + simgrid::mc::Frame* subprogram, + simgrid::mc::Frame* scope) { // Processing of direct variables: @@ -196,7 +196,7 @@ static void mc_ignore_local_variable_in_scope(const char *var_name, // Dichotomic search: while (start <= end) { int cursor = (start + end) / 2; - mc_variable_t current_var = &scope->variables[cursor]; + simgrid::mc::Variable* current_var = &scope->variables[cursor]; int compare = strcmp(current_var->name.c_str(), var_name); if (compare == 0) { @@ -218,7 +218,7 @@ static void mc_ignore_local_variable_in_scope(const char *var_name, for (simgrid::mc::Frame& nested_scope : scope->scopes) { // The new scope may be an inlined subroutine, in this case we want to use its // namespaced name in recursive calls: - mc_frame_t nested_subprogram = + simgrid::mc::Frame* nested_subprogram = nested_scope.tag == DW_TAG_inlined_subroutine ? &nested_scope : subprogram; diff --git a/teshsuite/mc/dwarf/dwarf.cpp b/teshsuite/mc/dwarf/dwarf.cpp index 40f99bb9d7..4bd2e89c0f 100644 --- a/teshsuite/mc/dwarf/dwarf.cpp +++ b/teshsuite/mc/dwarf/dwarf.cpp @@ -21,7 +21,7 @@ int test_some_array[4][5][6]; struct some_struct { int first; int second[4][5]; } test_some_struct; -static mc_type_t find_type_by_name(mc_object_info_t info, const char* name) +static simgrid::mc::Type* find_type_by_name(simgrid::mc::ObjectInformation* info, const char* name) { for (auto& entry : info->types) if(entry.second.name == name) @@ -29,8 +29,8 @@ static mc_type_t find_type_by_name(mc_object_info_t info, const char* name) return nullptr; } -static mc_frame_t find_function_by_name( - mc_object_info_t info, const char* name) +static simgrid::mc::Frame* find_function_by_name( + simgrid::mc::ObjectInformation* info, const char* name) { for (auto& entry : info->subprograms) if(entry.second.name == name) @@ -38,8 +38,8 @@ static mc_frame_t find_function_by_name( return nullptr; } -static mc_variable_t find_local_variable( - mc_frame_t frame, const char* argument_name) +static simgrid::mc::Variable* find_local_variable( + simgrid::mc::Frame* frame, const char* argument_name) { for (simgrid::mc::Variable& variable : frame->variables) if(argument_name == variable.name) @@ -55,12 +55,12 @@ static mc_variable_t find_local_variable( return nullptr; } -static void test_local_variable(mc_object_info_t info, const char* function, const char* variable, void* address, unw_cursor_t* cursor) { - mc_frame_t subprogram = find_function_by_name(info, function); +static void test_local_variable(simgrid::mc::ObjectInformation* info, const char* function, const char* variable, void* address, unw_cursor_t* cursor) { + simgrid::mc::Frame* subprogram = find_function_by_name(info, function); assert(subprogram); // TODO, Lookup frame by IP and test against name instead - mc_variable_t var = find_local_variable(subprogram, variable); + simgrid::mc::Variable* var = find_local_variable(subprogram, variable); assert(var); void* frame_base = mc_find_frame_base(subprogram, info, cursor); @@ -77,9 +77,9 @@ static void test_local_variable(mc_object_info_t info, const char* function, con } -static mc_variable_t test_global_variable(mc_process_t process, mc_object_info_t info, const char* name, void* address, long byte_size) { +static simgrid::mc::Variable* test_global_variable(simgrid::mc::Process* process, simgrid::mc::ObjectInformation* info, const char* name, void* address, long byte_size) { - mc_variable_t variable = info->find_variable(name); + simgrid::mc::Variable* variable = info->find_variable(name); xbt_assert(variable, "Global variable %s was not found", name); xbt_assert(variable->name == name, "Name mismatch for %s", name); @@ -90,12 +90,12 @@ static mc_variable_t test_global_variable(mc_process_t process, mc_object_info_t auto i = process->binary_info->types.find(variable->type_id); xbt_assert(i != process->binary_info->types.end(), "Missing type for %s", name); - mc_type_t type = &i->second; + simgrid::mc::Type* type = &i->second; xbt_assert(type->byte_size = byte_size, "Byte size mismatch for %s", name); return variable; } -static mc_type_t find_member(mc_object_info_t info, const char* name, mc_type_t type) +static simgrid::mc::Type* find_member(simgrid::mc::ObjectInformation* info, const char* name, simgrid::mc::Type* type) { for (simgrid::mc::Type& member : type->members) if(member.name == name) @@ -107,7 +107,7 @@ int some_local_variable = 0; typedef struct foo {int i;} s_foo; -static void test_type_by_name(mc_process_t process, s_foo my_foo) +static void test_type_by_name(simgrid::mc::Process* process, s_foo my_foo) { assert( process->binary_info->full_types_by_name.find("struct foo") != @@ -118,11 +118,11 @@ int main(int argc, char** argv) { SIMIX_global_init(&argc, argv); - mc_variable_t var; - mc_type_t type; + simgrid::mc::Variable* var; + simgrid::mc::Type* type; - s_mc_process_t p(getpid(), -1); - mc_process_t process = &p; + simgrid::mc::Process p(getpid(), -1); + simgrid::mc::Process* process = &p; test_global_variable(process, process->binary_info.get(), "some_local_variable", &some_local_variable, sizeof(int)); diff --git a/teshsuite/mc/dwarf_expression/dwarf_expression.cpp b/teshsuite/mc/dwarf_expression/dwarf_expression.cpp index fc7ab69c7b..afd40aa3c7 100644 --- a/teshsuite/mc/dwarf_expression/dwarf_expression.cpp +++ b/teshsuite/mc/dwarf_expression/dwarf_expression.cpp @@ -15,7 +15,7 @@ #include "../src/mc/mc_private.h" #include "../src/mc/mc_object_info.h" -static mc_process_t process; +static simgrid::mc::Process* process; static uintptr_t eval_binary_operation(mc_expression_state_t state, int op, uintptr_t a, uintptr_t b) { @@ -119,7 +119,7 @@ int main(int argc, char** argv) { s_mc_expression_state_t state; memset(&state, 0, sizeof(s_mc_expression_state_t)); - state.address_space = (mc_address_space_t) process; + state.address_space = (simgrid::mc::AddressSpace*) process; basic_test(&state);