X-Git-Url: http://bilbo.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/08e7455d67920bbd7a87f440d00f2c1e071314a0..716c8e0b373bed43c35af2b35514f0b7a69b08a5:/src/mc/inspect/ObjectInformation.cpp diff --git a/src/mc/inspect/ObjectInformation.cpp b/src/mc/inspect/ObjectInformation.cpp index c463bd304b..479dd7f6a5 100644 --- a/src/mc/inspect/ObjectInformation.cpp +++ b/src/mc/inspect/ObjectInformation.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2014-2021. The SimGrid Team. All rights reserved. */ +/* Copyright (c) 2014-2023. 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. */ @@ -14,8 +14,7 @@ #include "src/mc/mc_private.hpp" #include "xbt/file.hpp" -namespace simgrid { -namespace mc { +namespace simgrid::mc { /* For an executable object, addresses are virtual address (there is no offset) i.e. * \f$\text{virtual address} = \{dwarf address}\f$ @@ -40,8 +39,10 @@ void* ObjectInformation::base_address() const return result; } -Frame* ObjectInformation::find_function(const void* ip) const +Frame* ObjectInformation::find_function(const void* ip) { + ensure_dwarf_loaded(); + /* This is implemented by binary search on a sorted array. * * We do quite a lot of those so we want this to be cache efficient. @@ -64,8 +65,10 @@ Frame* ObjectInformation::find_function(const void* ip) const : nullptr; } -const Variable* ObjectInformation::find_variable(const char* var_name) const +const Variable* ObjectInformation::find_variable(const char* var_name) { + ensure_dwarf_loaded(); + auto pos = std::lower_bound(this->global_variables.begin(), this->global_variables.end(), var_name, [](auto const& var, const char* name) { return var.name < name; }); return (pos != this->global_variables.end() && pos->name == var_name) ? &(*pos) : nullptr; @@ -120,8 +123,8 @@ static void remove_local_variable(Frame& scope, const char* var_name, const char void ObjectInformation::remove_local_variable(const char* var_name, const char* subprogram_name) { - for (auto& entry : this->subprograms) - mc::remove_local_variable(entry.second, var_name, subprogram_name, entry.second); + for (auto& [_, entry] : this->subprograms) + mc::remove_local_variable(entry, var_name, subprogram_name, entry); } /** @brief Fills the position of the segments (executable, read-only, read/write) */ @@ -135,10 +138,7 @@ void find_object_address(std::vector const& maps, ObjectInformation* for (size_t i = 0; i < maps.size(); ++i) { simgrid::xbt::VmMap const& reg = maps[i]; - if (maps[i].pathname.empty()) - continue; - std::string map_basename = simgrid::xbt::Path(maps[i].pathname).get_base_name(); - if (map_basename != name) + if (reg.pathname.empty() || name != simgrid::xbt::Path(reg.pathname).get_base_name()) continue; // This is the non-GNU_RELRO-part of the data segment: @@ -172,7 +172,7 @@ void find_object_address(std::vector const& maps, ObjectInformation* else if (reg.prot == PROT_READ) { xbt_assert(not result->start_ro, "Multiple read-only segments for %s, not supported. Compiling with the following may help: " - "-Wl,-znorelro -Wl,-znoseparate-code", + "-g -Wl,-znorelro -Wl,-znoseparate-code", maps[i].pathname.c_str()); result->start_ro = (char*)reg.start_addr; result->end_ro = (char*)reg.end_addr; @@ -194,5 +194,4 @@ void find_object_address(std::vector const& maps, ObjectInformation* xbt_assert(result->start_exec || result->start_rw || result->start_ro); } -} // namespace mc -} // namespace simgrid +} // namespace simgrid::mc