Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Remove unused type definitions.
[simgrid.git] / src / mc / LocationList.hpp
1 /* Copyright (c) 2004-2019. The SimGrid Team. All rights reserved.          */
2
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. */
5
6 #ifndef SIMGRID_MC_OBJECT_LOCATION_H
7 #define SIMGRID_MC_OBJECT_LOCATION_H
8
9 #include "xbt/base.h"
10 #include "xbt/range.hpp"
11
12 #include "src/mc/mc_base.h"
13 #include "src/mc/mc_forward.hpp"
14 #include "src/mc/DwarfExpression.hpp"
15
16 #include <cstdint>
17 #include <vector>
18
19 namespace simgrid {
20 namespace dwarf {
21
22 /** A DWARF expression with optional validity constraints */
23 class LocationListEntry {
24 public:
25   typedef simgrid::xbt::Range<std::uint64_t> range_type;
26 private:
27   DwarfExpression expression_;
28   // By default, the expression is always valid:
29   range_type range_ = {0, UINT64_MAX};
30 public:
31   LocationListEntry() = default;
32   LocationListEntry(DwarfExpression expression, range_type range)
33     : expression_(std::move(expression)), range_(range)
34   {}
35   explicit LocationListEntry(DwarfExpression expression) : expression_(std::move(expression)), range_({0, UINT64_MAX})
36   {
37   }
38
39   DwarfExpression& expression()
40   {
41     return expression_;
42   }
43   DwarfExpression const& expression() const
44   {
45     return expression_;
46   }
47   bool valid_for_ip(unw_word_t ip) const
48   {
49     return range_.contain(ip);
50   }
51 };
52
53 typedef std::vector<LocationListEntry> LocationList;
54
55 /** Location of some variable in memory
56  *
57  *  The variable is located either in memory of a register.
58  */
59 class Location {
60 private:
61   void* memory_;
62   int register_id_ = 0;
63
64 public:
65   explicit Location(void* x) : memory_(x) {}
66   explicit Location(int register_id) : memory_(nullptr), register_id_(register_id) {}
67   // Type of location:
68   bool in_register() const { return memory_ == nullptr; }
69   bool in_memory()   const { return memory_ != nullptr; }
70
71   // Get the location:
72   void* address()    const { return memory_; }
73   int register_id()  const { return register_id_;     }
74 };
75
76 XBT_PRIVATE
77 Location resolve(
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,
81   int process_index);
82
83 Location resolve(
84   simgrid::dwarf::LocationList const& locations,
85   simgrid::mc::ObjectInformation* object_info,
86   unw_cursor_t * c,
87   void *frame_pointer_address,
88   simgrid::mc::AddressSpace* address_space,
89   int process_index);
90
91 XBT_PRIVATE
92 simgrid::dwarf::LocationList location_list(
93   simgrid::mc::ObjectInformation& info,
94   Dwarf_Attribute& attr);
95
96 }
97 }
98
99 #endif