1 /* Copyright (c) 2004-2019. The SimGrid Team. All rights reserved. */
3 /* This program is free software; you can redistribute it and/or modify it
4 * under the terms of the license (GNU LGPL) which comes with this package. */
6 #ifndef SIMGRID_MC_OBJECT_LOCATION_H
7 #define SIMGRID_MC_OBJECT_LOCATION_H
10 #include "xbt/range.hpp"
12 #include "src/mc/mc_base.h"
13 #include "src/mc/mc_forward.hpp"
14 #include "src/mc/DwarfExpression.hpp"
22 /** A DWARF expression with optional validity constraints */
23 class LocationListEntry {
25 typedef simgrid::xbt::Range<std::uint64_t> range_type;
27 DwarfExpression expression_;
28 // By default, the expression is always valid:
29 range_type range_ = {0, UINT64_MAX};
31 LocationListEntry() = default;
32 LocationListEntry(DwarfExpression expression, range_type range)
33 : expression_(std::move(expression)), range_(range)
35 explicit LocationListEntry(DwarfExpression expression) : expression_(std::move(expression)), range_({0, UINT64_MAX})
39 DwarfExpression& expression()
43 DwarfExpression const& expression() const
47 bool valid_for_ip(unw_word_t ip) const
49 return range_.contain(ip);
53 typedef std::vector<LocationListEntry> LocationList;
55 /** Location of some variable in memory
57 * The variable is located either in memory of a register.
65 explicit Location(void* x) : memory_(x) {}
66 explicit Location(int register_id) : memory_(nullptr), register_id_(register_id) {}
68 bool in_register() const { return memory_ == nullptr; }
69 bool in_memory() const { return memory_ != nullptr; }
72 void* address() const { return memory_; }
73 int register_id() const { return register_id_; }
78 simgrid::dwarf::DwarfExpression const& expression,
79 simgrid::mc::ObjectInformation* object_info, unw_cursor_t* c,
80 void* frame_pointer_address, simgrid::mc::AddressSpace* address_space,
84 simgrid::dwarf::LocationList const& locations,
85 simgrid::mc::ObjectInformation* object_info,
87 void *frame_pointer_address,
88 simgrid::mc::AddressSpace* address_space,
92 simgrid::dwarf::LocationList location_list(
93 simgrid::mc::ObjectInformation& info,
94 Dwarf_Attribute& attr);