Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[mc] Move mc_dwarf_location_list_init() into namespace
authorGabriel Corona <gabriel.corona@loria.fr>
Mon, 12 Oct 2015 22:29:35 +0000 (00:29 +0200)
committerGabriel Corona <gabriel.corona@loria.fr>
Thu, 15 Oct 2015 09:18:32 +0000 (11:18 +0200)
src/mc/DwarfExpression.cpp
src/mc/LocationList.cpp
src/mc/LocationList.hpp
src/mc/mc_dwarf.cpp

index ddb3799..65adcca 100644 (file)
@@ -267,39 +267,3 @@ void execute(
 
 }
 }
-
-extern "C" {
-
-void mc_dwarf_location_list_init(
-  simgrid::dwarf::LocationList* list, simgrid::mc::ObjectInformation* info,
-  Dwarf_Die * die, Dwarf_Attribute * attr)
-{
-  list->clear();
-
-  std::ptrdiff_t offset = 0;
-  Dwarf_Addr base, start, end;
-  Dwarf_Op *ops;
-  std::size_t len;
-
-  while (1) {
-
-    offset = dwarf_getlocations(attr, offset, &base, &start, &end, &ops, &len);
-    if (offset == 0)
-      return;
-    else if (offset == -1)
-      xbt_die("Error while loading location list");
-
-    simgrid::dwarf::LocationListEntry entry;
-    entry.expression = simgrid::dwarf::DwarfExpression(ops, ops + len);
-
-    void *base = info->base_address();
-    // If start == 0, this is not a location list:
-    entry.lowpc = start == 0 ? NULL : (char *) base + start;
-    entry.highpc = start == 0 ? NULL : (char *) base + end;
-
-    list->push_back(std::move(entry));
-  }
-
-}
-
-}
index 03e4161..34e55e4 100644 (file)
@@ -71,5 +71,44 @@ Location resolve(
           frame_pointer_address, address_space, process_index);
 }
 
+simgrid::dwarf::LocationList location_list(
+  simgrid::mc::ObjectInformation& info,
+  Dwarf_Attribute& attr)
+{
+  simgrid::dwarf::LocationList locations;
+  std::ptrdiff_t offset = 0;
+  while (1) {
+
+    Dwarf_Addr base, start, end;
+    Dwarf_Op *ops;
+    std::size_t len;
+
+    offset = dwarf_getlocations(
+      &attr, offset, &base, &start, &end, &ops, &len);
+
+    if (offset == 0)
+      return std::move(locations);
+    else if (offset == -1)
+      xbt_die("Error while loading location list");
+
+    simgrid::dwarf::LocationListEntry entry;
+    entry.expression = simgrid::dwarf::DwarfExpression(ops, ops + len);
+
+    void *base_address = info.base_address();
+
+    // If start == 0, this is not a location list:
+    if (start == 0) {
+      entry.lowpc  = nullptr;
+      entry.highpc = nullptr;
+    } else {
+      entry.lowpc  = (char *) base_address + start;
+      entry.highpc = (char *) base_address + end;
+    }
+
+    locations.push_back(std::move(entry));
+  }
+}
+
+
 }
 }
\ No newline at end of file
index 978232a..bfc53c5 100644 (file)
@@ -82,15 +82,12 @@ Location resolve(
   simgrid::mc::AddressSpace* address_space,
   int process_index);
 
+XBT_PRIVATE
+simgrid::dwarf::LocationList location_list(
+  simgrid::mc::ObjectInformation& info,
+  Dwarf_Attribute& attr);
+
 }
 }
 
-SG_BEGIN_DECL()
-
-XBT_PRIVATE void mc_dwarf_location_list_init(
-  simgrid::dwarf::LocationList*, simgrid::mc::ObjectInformation* info,
-  Dwarf_Die* die, Dwarf_Attribute* attr);
-
-SG_END_DECL()
-
 #endif
index 4b88e2f..eeb6a36 100644 (file)
@@ -764,9 +764,8 @@ static std::unique_ptr<simgrid::mc::Variable> MC_die_to_variable(
   case simgrid::dwarf::FormClass::LocListPtr:
   case simgrid::dwarf::FormClass::Constant:
     // Reference to location list:
-    mc_dwarf_location_list_init(
-      &variable->location_list, info, die,
-      &attr_location);
+    variable->location_list = simgrid::dwarf::location_list(
+      *info, attr_location);
     break;
 
   default:
@@ -909,8 +908,8 @@ static void MC_dwarf_handle_scope_die(simgrid::mc::ObjectInformation* info, Dwar
   if (klass == simgrid::dwarf::TagClass::Subprogram) {
     Dwarf_Attribute attr_frame_base;
     if (dwarf_attr_integrate(die, DW_AT_frame_base, &attr_frame_base))
-      mc_dwarf_location_list_init(&frame.frame_base_location, info, die,
-                                  &attr_frame_base);
+      frame.frame_base_location = simgrid::dwarf::location_list(*info,
+                                  attr_frame_base);
   }
 
   // Handle children: