X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/391815662d71f9337783f96a7ef8550c3d3e94e0..cee8b7d98f1c3b6738ad5f0b20de7bed9ba08d5a:/src/mc/inspect/mc_dwarf.cpp diff --git a/src/mc/inspect/mc_dwarf.cpp b/src/mc/inspect/mc_dwarf.cpp index f8481b3b65..21bb7a3ff7 100644 --- a/src/mc/inspect/mc_dwarf.cpp +++ b/src/mc/inspect/mc_dwarf.cpp @@ -842,11 +842,9 @@ static void MC_dwarf_handle_die(simgrid::mc::ObjectInformation* info, Dwarf_Die* static Elf64_Half get_type(Elf* elf) { - const Elf64_Ehdr* ehdr64 = elf64_getehdr(elf); - if (ehdr64) + if (const Elf64_Ehdr* ehdr64 = elf64_getehdr(elf)) return ehdr64->e_type; - const Elf32_Ehdr* ehdr32 = elf32_getehdr(elf); - if (ehdr32) + if (const Elf32_Ehdr* ehdr32 = elf32_getehdr(elf)) return ehdr32->e_type; xbt_die("Could not get ELF heeader"); } @@ -990,20 +988,17 @@ static void MC_load_dwarf(simgrid::mc::ObjectInformation* info) xbt_assert(elf != nullptr && elf_kind(elf) == ELF_K_ELF, "%s is not an ELF file", info->file_name.c_str()); // Remember if this is a `ET_EXEC` (fixed location) or `ET_DYN`: - Elf64_Half type = get_type(elf); - if (type == ET_EXEC) + if (get_type(elf) == ET_EXEC) info->flags |= simgrid::mc::ObjectInformation::Executable; // Read DWARF debug information in the file: - Dwarf* dwarf = dwarf_begin_elf(elf, DWARF_C_READ, nullptr); - if (dwarf != nullptr) { + if (Dwarf* dwarf = dwarf_begin_elf(elf, DWARF_C_READ, nullptr)) { read_dwarf_info(info, dwarf); dwarf_end(dwarf); elf_end(elf); close(fd); return; } - dwarf_end(dwarf); // If there was no DWARF in the file, try to find it in a separate file. // Different methods might be used to store the DWARF information: @@ -1028,7 +1023,7 @@ static void MC_load_dwarf(simgrid::mc::ObjectInformation* info) // Load the DWARF info from this file: XBT_DEBUG("Load DWARF for %s", info->file_name.c_str()); - dwarf = dwarf_begin(fd, DWARF_C_READ); + Dwarf* dwarf = dwarf_begin(fd, DWARF_C_READ); xbt_assert(dwarf != nullptr, "No DWARF info for %s", info->file_name.c_str()); read_dwarf_info(info, dwarf); dwarf_end(dwarf); @@ -1051,12 +1046,12 @@ static void MC_make_functions_index(simgrid::mc::ObjectInformation* info) { info->functions_index.clear(); - for (auto& e : info->subprograms) { - if (e.second.range.begin() == 0) + for (auto& [_, e] : info->subprograms) { + if (e.range.begin() == 0) continue; simgrid::mc::FunctionIndexEntry entry; - entry.low_pc = (void*)e.second.range.begin(); - entry.function = &e.second; + entry.low_pc = (void*)e.range.begin(); + entry.function = &e; info->functions_index.push_back(entry); } @@ -1117,8 +1112,7 @@ static simgrid::mc::Type* MC_resolve_type(simgrid::mc::ObjectInformation* info, // Try to find a more complete description of the type: // We need to fix in order to support C++. - simgrid::mc::Type** subtype = simgrid::util::find_map_ptr(info->full_types_by_name, type->name); - if (subtype) + if (simgrid::mc::Type** subtype = simgrid::util::find_map_ptr(info->full_types_by_name, type->name)) type = *subtype; return type; } @@ -1126,9 +1120,9 @@ static simgrid::mc::Type* MC_resolve_type(simgrid::mc::ObjectInformation* info, static void MC_post_process_types(simgrid::mc::ObjectInformation* info) { // Lookup "subtype" field: - for (auto& i : info->types) { - i.second.subtype = MC_resolve_type(info, i.second.type_id); - for (simgrid::mc::Member& member : i.second.members) + for (auto& [_, i] : info->types) { + i.subtype = MC_resolve_type(info, i.type_id); + for (simgrid::mc::Member& member : i.members) member.type = MC_resolve_type(info, member.type_id); } } @@ -1145,8 +1139,8 @@ void ObjectInformation::ensure_dwarf_loaded() MC_load_dwarf(this); MC_post_process_variables(this); MC_post_process_types(this); - for (auto& entry : this->subprograms) - mc_post_process_scope(this, &entry.second); + for (auto& [_, entry] : this->subprograms) + mc_post_process_scope(this, &entry); MC_make_functions_index(this); } @@ -1163,8 +1157,8 @@ std::shared_ptr createObjectInformation(std::vectortypes) { - Type* type = &(t.second); + for (auto& [_, t] : info->types) { + Type* type = &t; Type* subtype = type; while (subtype->type == DW_TAG_typedef || subtype->type == DW_TAG_volatile_type || subtype->type == DW_TAG_const_type)