X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/cee8b7d98f1c3b6738ad5f0b20de7bed9ba08d5a..4c753f8d4cabd4104f3f7109823f16be2ebdcce3:/src/mc/inspect/mc_dwarf.cpp diff --git a/src/mc/inspect/mc_dwarf.cpp b/src/mc/inspect/mc_dwarf.cpp index 21bb7a3ff7..7b0c0f5089 100644 --- a/src/mc/inspect/mc_dwarf.cpp +++ b/src/mc/inspect/mc_dwarf.cpp @@ -103,8 +103,7 @@ static void MC_dwarf_handle_variable_die(simgrid::mc::ObjectInformation* info, D */ static std::uint64_t MC_dwarf_at_type(Dwarf_Die* die); -namespace simgrid { -namespace dwarf { +namespace simgrid::dwarf { enum class TagClass { Unknown, Type, Subprogram, Variable, Scope, Namespace }; @@ -204,8 +203,7 @@ inline XBT_PRIVATE const char* tagname(Dwarf_Die* die) return tagname(dwarf_tag(die)); } -} // namespace dwarf -} // namespace simgrid +} // namespace simgrid::dwarf // ***** Attributes @@ -512,13 +510,13 @@ static simgrid::mc::Type MC_dwarf_die_to_type(simgrid::mc::ObjectInformation* in { simgrid::mc::Type type; type.type = dwarf_tag(die); - type.name = std::string(); + type.name = ""; type.element_count = -1; // Global Offset type.id = dwarf_dieoffset(die); - const char* prefix = ""; + const char* prefix; switch (type.type) { case DW_TAG_structure_type: prefix = "struct "; @@ -679,7 +677,7 @@ static std::unique_ptr MC_die_to_variable(simgrid::mc::Ob } if (ns && variable->global) - variable->name = std::string(ns) + "::" + variable->name; + variable->name.insert(0, std::string(ns) + "::"); // The current code needs a variable name, // generate a fake one: @@ -857,8 +855,7 @@ static void read_dwarf_info(simgrid::mc::ObjectInformation* info, Dwarf* dwarf) size_t length; while (dwarf_nextcu(dwarf, offset, &next_offset, &length, nullptr, nullptr, nullptr) == 0) { - Dwarf_Die unit_die; - if (dwarf_offdie(dwarf, offset + length, &unit_die) != nullptr) + if (Dwarf_Die unit_die; dwarf_offdie(dwarf, offset + length, &unit_die) != nullptr) MC_dwarf_handle_children(info, &unit_die, &unit_die, nullptr, nullptr); offset = next_offset; } @@ -961,8 +958,7 @@ static int find_by_build_id(std::vector id) filename = std::string(debug_path) + ".build-id/" + to_hex(id.data(), 1) + '/' + to_hex(id.data() + 1, id.size() - 1) + ".debug"; XBT_DEBUG("Checking debug file: %s", filename.c_str()); - int fd = open(filename.c_str(), O_RDONLY); - if (fd != -1) { + if (int fd = open(filename.c_str(), O_RDONLY); fd != -1) { XBT_DEBUG("Found debug file: %s\n", hex.c_str()); return fd; } @@ -1009,8 +1005,7 @@ static void MC_load_dwarf(simgrid::mc::ObjectInformation* info) // Try with NT_GNU_BUILD_ID: we find the build ID in the ELF file and then // use this ID to find the file in some known locations in the filesystem. - std::vector build_id = get_build_id(elf); - if (not build_id.empty()) { + if (std::vector build_id = get_build_id(elf); not build_id.empty()) { elf_end(elf); close(fd); @@ -1127,8 +1122,7 @@ static void MC_post_process_types(simgrid::mc::ObjectInformation* info) } } -namespace simgrid { -namespace mc { +namespace simgrid::mc { void ObjectInformation::ensure_dwarf_loaded() { @@ -1181,11 +1175,9 @@ void postProcessObjectInformation(const RemoteProcess* process, ObjectInformatio } } -} // namespace mc -} // namespace simgrid +} // namespace simgrid::mc -namespace simgrid { -namespace dwarf { +namespace simgrid::dwarf { /** Convert a DWARF register into a libunwind register * @@ -1214,5 +1206,4 @@ int dwarf_register_to_libunwind(int dwarf_register) #endif } -} // namespace dwarf -} // namespace simgrid +} // namespace simgrid::dwarf