Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[mc] OOify mc_find_frame_base()
authorGabriel Corona <gabriel.corona@loria.fr>
Mon, 12 Oct 2015 22:16:03 +0000 (00:16 +0200)
committerGabriel Corona <gabriel.corona@loria.fr>
Thu, 15 Oct 2015 09:18:31 +0000 (11:18 +0200)
src/mc/DwarfExpression.cpp
src/mc/Frame.cpp [new file with mode: 0644]
src/mc/Frame.hpp
src/mc/LocationList.hpp
src/mc/mc_checkpoint.cpp
src/mc/mc_dwarf.cpp
teshsuite/mc/dwarf/dwarf.cpp
tools/cmake/DefinePackages.cmake

index 5e89864..ddb3799 100644 (file)
@@ -270,33 +270,6 @@ void execute(
 
 extern "C" {
 
 
 extern "C" {
 
-/** \brief Find the frame base of a given frame
- *
- *  \param frame
- *  \param unw_cursor
- */
-void *mc_find_frame_base(simgrid::mc::Frame* frame, simgrid::mc::ObjectInformation* object_info,
-                         unw_cursor_t * unw_cursor)
-{
-  simgrid::dwarf::Location location = simgrid::dwarf::resolve(
-                             frame->frame_base, object_info,
-                             unw_cursor, NULL, NULL, -1);
-  if (location.in_memory())
-    return location.address();
-  else if (location.in_register()) {
-    // This is a special case.
-    // The register if not the location of the frame base
-    // (a frame base cannot be located in a register)
-    // Instead, DWARF defines this to mean that the register
-    // contains the address of the frame base.
-    unw_word_t word;
-    unw_get_reg(unw_cursor, location.register_id(), &word);
-    return (void*) word;
-  }
-  else xbt_die("Unexpected location type");
-
-}
-
 void mc_dwarf_location_list_init(
   simgrid::dwarf::LocationList* list, simgrid::mc::ObjectInformation* info,
   Dwarf_Die * die, Dwarf_Attribute * attr)
 void mc_dwarf_location_list_init(
   simgrid::dwarf::LocationList* list, simgrid::mc::ObjectInformation* info,
   Dwarf_Die * die, Dwarf_Attribute * attr)
diff --git a/src/mc/Frame.cpp b/src/mc/Frame.cpp
new file mode 100644 (file)
index 0000000..448cfa1
--- /dev/null
@@ -0,0 +1,33 @@
+/* Copyright (c) 2007-2015. The SimGrid Team.
+ * All rights reserved.                                                     */
+
+/* This program is free software; you can redistribute it and/or modify it
+ * under the terms of the license (GNU LGPL) which comes with this package. */
+
+#include <mc/Frame.hpp>
+
+namespace simgrid {
+namespace mc {
+
+void* Frame::frame_base(unw_cursor_t& unw_cursor) const
+{
+  simgrid::dwarf::Location location = simgrid::dwarf::resolve(
+                             frame_base_location, object_info,
+                             &unw_cursor, NULL, NULL, -1);
+  if (location.in_memory())
+    return location.address();
+  else if (location.in_register()) {
+    // This is a special case.
+    // The register if not the location of the frame base
+    // (a frame base cannot be located in a register)
+    // Instead, DWARF defines this to mean that the register
+    // contains the address of the frame base.
+    unw_word_t word;
+    unw_get_reg(&unw_cursor, location.register_id(), &word);
+    return (void*) word;
+  }
+  else xbt_die("Unexpected location type");
+}
+
+}
+}
\ No newline at end of file
index 589a11d..67d638e 100644 (file)
@@ -27,12 +27,14 @@ public:
   std::string name;
   void *low_pc;
   void *high_pc;
   std::string name;
   void *low_pc;
   void *high_pc;
-  simgrid::dwarf::LocationList frame_base;
+  simgrid::dwarf::LocationList frame_base_location;
   std::vector<Variable> variables;
   unsigned long int id; /* DWARF offset of the subprogram */
   std::vector<Frame> scopes;
   unsigned long int abstract_origin_id;
   simgrid::mc::ObjectInformation* object_info;
   std::vector<Variable> variables;
   unsigned long int id; /* DWARF offset of the subprogram */
   std::vector<Frame> scopes;
   unsigned long int abstract_origin_id;
   simgrid::mc::ObjectInformation* object_info;
+
+  void* frame_base(unw_cursor_t& unw_cursor) const;
 };
 
 inline
 };
 
 inline
index 2e04e01..978232a 100644 (file)
@@ -91,9 +91,6 @@ XBT_PRIVATE void mc_dwarf_location_list_init(
   simgrid::dwarf::LocationList*, simgrid::mc::ObjectInformation* info,
   Dwarf_Die* die, Dwarf_Attribute* attr);
 
   simgrid::dwarf::LocationList*, simgrid::mc::ObjectInformation* info,
   Dwarf_Die* die, Dwarf_Attribute* attr);
 
-void* mc_find_frame_base(
-  simgrid::mc::Frame* frame, simgrid::mc::ObjectInformation* object_info, unw_cursor_t* unw_cursor);
-
 SG_END_DECL()
 
 #endif
 SG_END_DECL()
 
 #endif
index 1ea719c..746d20b 100644 (file)
@@ -380,7 +380,7 @@ static std::vector<s_mc_stack_frame_t> MC_unwind_stack_frames(mc_unw_context_t s
       if (frame) {
         stack_frame.frame_name = frame->name;
         stack_frame.frame_base =
       if (frame) {
         stack_frame.frame_name = frame->name;
         stack_frame.frame_base =
-            (unw_word_t) mc_find_frame_base(frame, frame->object_info, &c);
+            (unw_word_t) frame->frame_base(c);
       } else {
         stack_frame.frame_base = 0;
         stack_frame.frame_name = std::string();
       } else {
         stack_frame.frame_base = 0;
         stack_frame.frame_name = std::string();
index 5151a7a..4b88e2f 100644 (file)
@@ -909,7 +909,7 @@ 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))
   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, info, die,
+      mc_dwarf_location_list_init(&frame.frame_base_location, info, die,
                                   &attr_frame_base);
   }
 
                                   &attr_frame_base);
   }
 
index 9af2e2f..383fbf5 100644 (file)
@@ -68,7 +68,7 @@ static void test_local_variable(simgrid::mc::ObjectInformation* info, const char
   simgrid::mc::Variable* var = find_local_variable(subprogram, variable);
   assert(var);
 
   simgrid::mc::Variable* var = find_local_variable(subprogram, variable);
   assert(var);
 
-  void* frame_base = mc_find_frame_base(subprogram, info, cursor);
+  void* frame_base = subprogram->frame_base(*cursor);
   simgrid::dwarf::Location location = simgrid::dwarf::resolve(
     var->location_list, info, cursor, frame_base, NULL, -1);
 
   simgrid::dwarf::Location location = simgrid::dwarf::resolve(
     var->location_list, info, cursor, frame_base, NULL, -1);
 
index a244369..cc7e453 100644 (file)
@@ -613,6 +613,7 @@ set(MC_SRC
   src/mc/AddressSpace.hpp
   src/mc/AddressSpace.cpp
   src/mc/Frame.hpp
   src/mc/AddressSpace.hpp
   src/mc/AddressSpace.cpp
   src/mc/Frame.hpp
+  src/mc/Frame.cpp
   src/mc/ModelChecker.hpp
   src/mc/ModelChecker.cpp
   src/mc/ObjectInformation.hpp
   src/mc/ModelChecker.hpp
   src/mc/ModelChecker.cpp
   src/mc/ObjectInformation.hpp