Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[mc] C++ location lists and expressions
[simgrid.git] / src / mc / mc_location.h
index 5d884da..7f60328 100644 (file)
@@ -25,25 +25,30 @@ namespace mc {
 
 typedef std::vector<Dwarf_Op> DwarfExpression;
 
+
+/** \brief A DWARF expression with optional validity contraints */
+class LocationListEntry {
+public:
+  DwarfExpression expression;
+  void* lowpc, *highpc;
+
+  LocationListEntry() : lowpc(nullptr), highpc(nullptr) {}
+
+  bool valid_for_ip(unw_word_t ip)
+  {
+    return (this->lowpc == nullptr && this->highpc == nullptr)
+        || (ip >= (unw_word_t) this->lowpc
+            && ip < (unw_word_t) this->highpc);
+  }
+};
+
+typedef std::vector<LocationListEntry> LocationList;
+
 }
 }
 
 SG_BEGIN_DECL()
 
-/** \brief a DWARF expression with optional validity contraints */
-typedef struct s_mc_expression {
-  size_t size;
-  Dwarf_Op* ops;
-  // Optional validity:
-  void* lowpc, *highpc;
-} s_mc_expression_t, *mc_expression_t;
-
-/** A location list (list of location expressions) */
-typedef struct s_mc_location_list {
-  size_t size;
-  mc_expression_t locations;
-} s_mc_location_list_t, *mc_location_list_t;
-
 /** A location is either a location in memory of a register location
  *
  *  Usage:
@@ -85,16 +90,20 @@ enum mc_location_type mc_get_location_type(mc_location_t location) {
   }
 }
 
-XBT_INTERNAL void mc_dwarf_resolve_location(mc_location_t location, mc_expression_t expression, mc_object_info_t object_info, unw_cursor_t* c, void* frame_pointer_address, mc_address_space_t address_space, int process_index);
-MC_SHOULD_BE_INTERNAL void mc_dwarf_resolve_locations(mc_location_t location, mc_location_list_t locations, mc_object_info_t object_info, unw_cursor_t* c, void* frame_pointer_address, mc_address_space_t address_space, int process_index);
-
-XBT_INTERNAL void mc_dwarf_expression_clear(mc_expression_t expression);
-XBT_INTERNAL void mc_dwarf_expression_init(mc_expression_t expression, size_t len, Dwarf_Op* ops);
-
-XBT_INTERNAL void mc_dwarf_location_list_clear(mc_location_list_t list);
-
-XBT_INTERNAL void mc_dwarf_location_list_init_from_expression(mc_location_list_t target, size_t len, Dwarf_Op* ops);
-XBT_INTERNAL void mc_dwarf_location_list_init(mc_location_list_t target, mc_object_info_t info, Dwarf_Die* die, Dwarf_Attribute* attr);
+XBT_INTERNAL void mc_dwarf_resolve_location(
+  mc_location_t location, simgrid::mc::DwarfExpression* expression,
+  mc_object_info_t object_info, unw_cursor_t* c,
+  void* frame_pointer_address, mc_address_space_t address_space,
+  int process_index);
+MC_SHOULD_BE_INTERNAL void mc_dwarf_resolve_locations(
+  mc_location_t location, simgrid::mc::LocationList* locations,
+  mc_object_info_t object_info, unw_cursor_t* c,
+  void* frame_pointer_address, mc_address_space_t address_space,
+  int process_index);
+
+XBT_INTERNAL void mc_dwarf_location_list_init(
+  simgrid::mc::LocationList*, mc_object_info_t info, Dwarf_Die* die,
+  Dwarf_Attribute* attr);
 
 #define MC_EXPRESSION_STACK_SIZE 64