From: Gabriel Corona Date: Mon, 12 Oct 2015 08:11:27 +0000 (+0200) Subject: [mc] Simplify MC_find_object_info X-Git-Tag: v3_13~1644^2~63 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/6595b7c891982bcbe6c33df00b6698fb77799b0f [mc] Simplify MC_find_object_info --- diff --git a/src/mc/Process.cpp b/src/mc/Process.cpp index 78f4b45738..3af20cb63d 100644 --- a/src/mc/Process.cpp +++ b/src/mc/Process.cpp @@ -383,7 +383,7 @@ void Process::init_memory_map_info() } std::shared_ptr info = - MC_find_object_info(this->memory_map_, pathname, is_executable); + MC_find_object_info(this->memory_map_, pathname); this->object_infos.push_back(info); if (is_executable) this->binary_info = info; diff --git a/src/mc/mc_dwarf.cpp b/src/mc/mc_dwarf.cpp index 727a8cd44e..90fd3d61a1 100644 --- a/src/mc/mc_dwarf.cpp +++ b/src/mc/mc_dwarf.cpp @@ -988,6 +988,19 @@ static void MC_dwarf_handle_die(simgrid::mc::ObjectInformation* info, Dwarf_Die } } +static +Elf64_Half MC_dwarf_elf_type(Dwarf* dwarf) +{ + Elf* elf = dwarf_getelf(dwarf); + Elf64_Ehdr* ehdr64 = elf64_getehdr(elf); + if (ehdr64) + return ehdr64->e_type; + Elf32_Ehdr* ehdr32 = elf32_getehdr(elf); + if (ehdr32) + return ehdr32->e_type; + xbt_die("Could not get ELF heeader"); +} + /** \brief Populate the debugging informations of the given ELF object * * Read the DWARf information of the EFFL object and populate the @@ -1005,6 +1018,11 @@ void MC_dwarf_get_variables(simgrid::mc::ObjectInformation* info) "Your program and its dependencies must have debugging information.\n" "You might want to recompile with -g or install the suitable debugging package.\n", info->file_name.c_str()); + + Elf64_Half elf_type = MC_dwarf_elf_type(dwarf); + if (elf_type == ET_EXEC) + info->flags |= simgrid::mc::ObjectInformation::Executable; + // For each compilation unit: Dwarf_Off offset = 0; Dwarf_Off next_offset = 0; @@ -1134,12 +1152,10 @@ static void MC_post_process_types(simgrid::mc::ObjectInformation* info) /** \brief Finds informations about a given shared object/executable */ std::shared_ptr MC_find_object_info( - std::vector const& maps, const char *name, int executable) + std::vector const& maps, const char *name) { std::shared_ptr result = std::make_shared(); - if (executable) - result->flags |= simgrid::mc::ObjectInformation::Executable; result->file_name = name; MC_find_object_address(maps, result.get()); MC_dwarf_get_variables(result.get()); diff --git a/src/mc/mc_object_info.h b/src/mc/mc_object_info.h index 3516885c2f..d8df6b23a3 100644 --- a/src/mc/mc_object_info.h +++ b/src/mc/mc_object_info.h @@ -16,7 +16,7 @@ #include "mc_memory_map.h" XBT_PRIVATE std::shared_ptr MC_find_object_info( - std::vector const& maps, const char* name, int executable); + std::vector const& maps, const char* name); XBT_PRIVATE void MC_post_process_object_info(simgrid::mc::Process* process, simgrid::mc::ObjectInformation* info); #endif