X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/d57f583f531c3ed96281734e99a3199e0a58ec3f..40616078da72e823931c1fb884949054699ec39d:/src/mc/LocationList.cpp diff --git a/src/mc/LocationList.cpp b/src/mc/LocationList.cpp index 03e4161d76..fdf5cd536c 100644 --- a/src/mc/LocationList.cpp +++ b/src/mc/LocationList.cpp @@ -4,9 +4,18 @@ /* 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. */ -#include "mc_dwarf.hpp" -#include -#include +#include +#include +#include + +#include +#include + +#include + +#include "src/mc/mc_dwarf.hpp" +#include "src/mc/ObjectInformation.hpp" +#include "src/mc/LocationList.hpp" namespace simgrid { namespace dwarf { @@ -47,7 +56,7 @@ static simgrid::dwarf::DwarfExpression const* find_expression( { for (simgrid::dwarf::LocationListEntry const& entry : locations) if (entry.valid_for_ip(ip)) - return &entry.expression; + return &entry.expression(); return nullptr; } @@ -71,5 +80,41 @@ Location resolve( frame_pointer_address, address_space, process_index); } +LocationList location_list( + simgrid::mc::ObjectInformation& info, + Dwarf_Attribute& attr) +{ + LocationList locations; + std::ptrdiff_t offset = 0; + while (1) { + + Dwarf_Addr base, start, end; + Dwarf_Op *ops; + std::size_t len; + + offset = dwarf_getlocations( + &attr, offset, &base, &start, &end, &ops, &len); + + 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(); + + LocationListEntry::range_type range; + if (start == 0) + // If start == 0, this is not a location list: + range = { 0, UINT64_MAX }; + else + range = { base_address + start, base_address + end }; + + locations.push_back({ DwarfExpression(ops, ops+len), range }); + } + + return locations; +} + + } } \ No newline at end of file