{
for (simgrid::dwarf::LocationListEntry const& entry : locations)
if (entry.valid_for_ip(ip))
- return &entry.expression;
+ return &entry.expression();
return nullptr;
}
frame_pointer_address, address_space, process_index);
}
-simgrid::dwarf::LocationList location_list(
+LocationList location_list(
simgrid::mc::ObjectInformation& info,
Dwarf_Attribute& attr)
{
- simgrid::dwarf::LocationList locations;
+ LocationList locations;
std::ptrdiff_t offset = 0;
while (1) {
&attr, offset, &base, &start, &end, &ops, &len);
if (offset == 0)
- return std::move(locations);
+ break;
else if (offset == -1)
xbt_die("Error while loading location list");
- simgrid::dwarf::LocationListEntry entry;
- entry.expression = simgrid::dwarf::DwarfExpression(ops, ops + len);
+ std::uint64_t base_address = (std::uint64_t) info.base_address();
- void *base_address = info.base_address();
+ LocationListEntry::range_type range;
+ if (start == 0)
+ // If start == 0, this is not a location list:
+ range = {0, 0};
+ else
+ range = { base_address + start, base_address + end };
- // If start == 0, this is not a location list:
- if (start == 0) {
- entry.lowpc = nullptr;
- entry.highpc = nullptr;
- } else {
- entry.lowpc = (char *) base_address + start;
- entry.highpc = (char *) base_address + end;
- }
-
- locations.push_back(std::move(entry));
+ locations.push_back({ DwarfExpression(ops, ops+len), range });
}
+
+ return std::move(locations);
}
#ifndef SIMGRID_MC_OBJECT_LOCATION_H
#define SIMGRID_MC_OBJECT_LOCATION_H
-#include <stdint.h>
+#include <cstdint>
#include <vector>
#include <dwarf.h>
#include <elfutils/libdw.h>
+#include <xbt/range.hpp>
+
#include "simgrid_config.h"
#include "src/mc/mc_base.h"
#include "src/mc/mc_forward.hpp"
/** \brief A DWARF expression with optional validity contraints */
class LocationListEntry {
public:
- simgrid::dwarf::DwarfExpression expression;
- void* lowpc, *highpc;
-
- LocationListEntry() : lowpc(nullptr), highpc(nullptr) {}
-
+ typedef simgrid::xbt::range<std::uint64_t> range_type;
+private:
+ DwarfExpression expression_;
+ range_type range_ = {0, 0};
+public:
+ LocationListEntry() {}
+ LocationListEntry(DwarfExpression expression, range_type range)
+ : expression_(std::move(expression)), range_(range)
+ {}
+ LocationListEntry(DwarfExpression expression)
+ : expression_(std::move(expression)), range_({0, 0})
+ {}
+
+ DwarfExpression& expression()
+ {
+ return expression_;
+ }
+ DwarfExpression const& expression() const
+ {
+ return expression_;
+ }
bool always_valid() const
{
- return this->lowpc == nullptr && this->highpc == nullptr;
+ return range_.begin() == 0 && range_.end() == 0;
}
bool valid_for_ip(unw_word_t ip) const
{
- return always_valid() || (
- ip >= (unw_word_t) this->lowpc &&
- ip < (unw_word_t) this->highpc);
+ return always_valid() || range_.contain(ip);
}
};
uintptr_t offset = (uintptr_t) expr[0].number;
uintptr_t base = (uintptr_t) info->base_address();
variable->address = (void *) (base + offset);
- } else {
- simgrid::dwarf::LocationListEntry entry;
- entry.expression = {expr, expr + len};
- variable->location_list = { std::move(entry) };
- }
+ } else
+ variable->location_list = {
+ simgrid::dwarf::DwarfExpression(expr, expr + len) };
break;
}