X-Git-Url: http://bilbo.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/b9625f82f86db0674e911887addce45dca31b57f..75e982c8df081076c4d1c40e94552c4159b46feb:/src/mc/inspect/LocationList.cpp diff --git a/src/mc/inspect/LocationList.cpp b/src/mc/inspect/LocationList.cpp index 07c7c3d002..18a585d385 100644 --- a/src/mc/inspect/LocationList.cpp +++ b/src/mc/inspect/LocationList.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2004-2020. The SimGrid Team. All rights reserved. */ +/* Copyright (c) 2004-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. */ @@ -8,6 +8,7 @@ #include "src/mc/inspect/mc_dwarf.hpp" #include "xbt/asserts.h" +#include "xbt/log.h" #include "xbt/sysdep.h" #include @@ -15,8 +16,9 @@ #include #include -namespace simgrid { -namespace dwarf { +XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(mc_dwarf); + +namespace simgrid::dwarf { /** Resolve a location expression */ Location resolve(simgrid::dwarf::DwarfExpression const& expression, simgrid::mc::ObjectInformation* object_info, @@ -53,11 +55,10 @@ Location resolve(simgrid::dwarf::LocationList const& locations, simgrid::mc::Obj unw_cursor_t* c, void* frame_pointer_address, const simgrid::mc::AddressSpace* address_space) { unw_word_t ip = 0; - if (c && unw_get_reg(c, UNW_REG_IP, &ip)) - xbt_die("Could not resolve IP"); + if (c) + xbt_assert(unw_get_reg(c, UNW_REG_IP, &ip) == 0, "Could not resolve IP"); simgrid::dwarf::DwarfExpression const* expression = find_expression(locations, ip); - if (not expression) - xbt_die("Could not resolve location"); + xbt_assert(expression != nullptr, "Could not resolve location"); return simgrid::dwarf::resolve(*expression, object_info, c, frame_pointer_address, address_space); } @@ -74,12 +75,12 @@ LocationList location_list(const simgrid::mc::ObjectInformation& info, Dwarf_Att offset = dwarf_getlocations(&attr, offset, &base, &start, &end, &ops, &len); - if (offset == 0) + if (offset == -1) + XBT_WARN("Error while loading location list: %s", dwarf_errmsg(-1)); + if (offset <= 0) break; - else if (offset == -1) - xbt_die("Error while loading location list"); - std::uint64_t base_address = (std::uint64_t)info.base_address(); + auto base_address = reinterpret_cast(info.base_address()); LocationListEntry::range_type range; if (start == 0) @@ -88,10 +89,9 @@ LocationList location_list(const simgrid::mc::ObjectInformation& info, Dwarf_Att else range = {base_address + start, base_address + end}; - locations.push_back({DwarfExpression(ops, ops + len), range}); + locations.emplace_back(DwarfExpression(ops, ops + len), range); } return locations; } -} // namespace dwarf -} // namespace simgrid +} // namespace simgrid::dwarf