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>
18 #include <simgrid_config.h>
20 #include "mc_forward.hpp"
21 #include "mc/AddressSpace.hpp"
22 #include "mc/DwarfExpression.hpp"
27 /** \brief A DWARF expression with optional validity contraints */
28 class LocationListEntry {
30 simgrid::dwarf::DwarfExpression expression;
33 LocationListEntry() : lowpc(nullptr), highpc(nullptr) {}
35 bool always_valid() const
37 return this->lowpc == nullptr && this->highpc == nullptr;
39 bool valid_for_ip(unw_word_t ip) const
41 return always_valid() || (
42 ip >= (unw_word_t) this->lowpc &&
43 ip < (unw_word_t) this->highpc);
47 typedef std::vector<LocationListEntry> LocationList;
49 /** Location of some variable in memory
51 * The variable is located either in memory of a register.
58 Location(void* x) :memory_(x) {}
59 Location(int register_id) :
60 memory_(nullptr), register_id_(register_id) {}
62 bool in_register() const { return memory_ == nullptr; }
63 bool in_memory() const { return memory_ != nullptr; }
66 void* address() const { return memory_; }
67 int register_id() const { return register_id_; }
72 simgrid::dwarf::DwarfExpression const& expression,
73 simgrid::mc::ObjectInformation* object_info, unw_cursor_t* c,
74 void* frame_pointer_address, simgrid::mc::AddressSpace* address_space,
78 simgrid::dwarf::LocationList const& locations,
79 simgrid::mc::ObjectInformation* object_info,
81 void *frame_pointer_address,
82 simgrid::mc::AddressSpace* address_space,
86 simgrid::dwarf::LocationList location_list(
87 simgrid::mc::ObjectInformation& info,
88 Dwarf_Attribute& attr);