1 /* Copyright (c) 2004-2015. The SimGrid Team.
2 * All rights reserved. */
4 /* This program is free software; you can redistribute it and/or modify it
5 * under the terms of the license (GNU LGPL) which comes with this package. */
7 #ifndef SIMGRID_MC_OBJECT_LOCATION_H
8 #define SIMGRID_MC_OBJECT_LOCATION_H
14 #include <libunwind.h>
16 #include <elfutils/libdw.h>
19 #include "xbt/range.hpp"
21 #include "src/mc/mc_base.h"
22 #include "src/mc/mc_forward.hpp"
23 #include "src/mc/DwarfExpression.hpp"
28 /** A DWARF expression with optional validity constraints */
29 class LocationListEntry {
31 typedef simgrid::xbt::Range<std::uint64_t> range_type;
33 DwarfExpression expression_;
34 // By default, the expression is always valid:
35 range_type range_ = {0, UINT64_MAX};
37 LocationListEntry() {}
38 LocationListEntry(DwarfExpression expression, range_type range)
39 : expression_(std::move(expression)), range_(range)
41 explicit LocationListEntry(DwarfExpression expression) : expression_(std::move(expression)), range_({0, UINT64_MAX})
44 DwarfExpression& expression()
48 DwarfExpression const& expression() const
52 bool valid_for_ip(unw_word_t ip) const
54 return range_.contain(ip);
58 typedef std::vector<LocationListEntry> LocationList;
60 /** Location of some variable in memory
62 * The variable is located either in memory of a register.
69 explicit Location(void* x) : memory_(x) {}
70 explicit Location(int register_id) : memory_(nullptr), register_id_(register_id) {}
72 bool in_register() const { return memory_ == nullptr; }
73 bool in_memory() const { return memory_ != nullptr; }
76 void* address() const { return memory_; }
77 int register_id() const { return register_id_; }
82 simgrid::dwarf::DwarfExpression const& expression,
83 simgrid::mc::ObjectInformation* object_info, unw_cursor_t* c,
84 void* frame_pointer_address, simgrid::mc::AddressSpace* address_space,
88 simgrid::dwarf::LocationList const& locations,
89 simgrid::mc::ObjectInformation* object_info,
91 void *frame_pointer_address,
92 simgrid::mc::AddressSpace* address_space,
96 simgrid::dwarf::LocationList location_list(
97 simgrid::mc::ObjectInformation& info,
98 Dwarf_Attribute& attr);