Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[mc] Cleanup/documentation for simgrid::mc::Frame
authorGabriel Corona <gabriel.corona@loria.fr>
Tue, 23 Feb 2016 15:01:56 +0000 (16:01 +0100)
committerGabriel Corona <gabriel.corona@loria.fr>
Tue, 23 Feb 2016 15:02:07 +0000 (16:02 +0100)
src/mc/Frame.hpp
src/mc/mc_dwarf.cpp

index 2d3e6d6..2e269d3 100644 (file)
@@ -25,16 +25,35 @@ class Frame {
 public:
   Frame();
 
 public:
   Frame();
 
-  int tag;
+  /** Kind of scope (DW_TAG_subprogram, DW_TAG_inlined_subroutine, etc.) */
+  int tag = DW_TAG_invalid;
+
+  /** Name of the function (if it is a function) */
   std::string name;
   std::string name;
+
   /** Range of instruction addresses for which this scope is valid */
   simgrid::xbt::range<std::uint64_t> range;
   /** Range of instruction addresses for which this scope is valid */
   simgrid::xbt::range<std::uint64_t> range;
+
   simgrid::dwarf::LocationList frame_base_location;
   simgrid::dwarf::LocationList frame_base_location;
+
+  /** List of the variables (sorted by name) */
   std::vector<Variable> variables;
   std::vector<Variable> variables;
-  unsigned long int id; /* DWARF offset of the subprogram */
+
+  /* Unique identifier for this scope (in the object_info)
+   *
+   * This is the global DWARF offset of the DIE. */
+  unsigned long int id = 0;
+
   std::vector<Frame> scopes;
   std::vector<Frame> scopes;
-  unsigned long int abstract_origin_id;
-  simgrid::mc::ObjectInformation* object_info;
+
+  /** Value of `DW_AT_abstract_origin`
+   *
+   *  For inlined subprograms, this is the ID of the
+   *  parent function.
+   */
+  unsigned long int abstract_origin_id = 0;
+
+  simgrid::mc::ObjectInformation* object_info = nullptr;
 
   void* frame_base(unw_cursor_t& unw_cursor) const;
   void remove_variable(char* name);
 
   void* frame_base(unw_cursor_t& unw_cursor) const;
   void remove_variable(char* name);
index a6fb218..d5afe09 100644 (file)
@@ -844,19 +844,16 @@ static void MC_dwarf_handle_scope_die(simgrid::mc::ObjectInformation* info, Dwar
     xbt_assert(parent_frame, "No parent scope for this scope");
 
   simgrid::mc::Frame frame;
     xbt_assert(parent_frame, "No parent scope for this scope");
 
   simgrid::mc::Frame frame;
-
   frame.tag = tag;
   frame.id = dwarf_dieoffset(die);
   frame.object_info = info;
 
   if (klass == simgrid::dwarf::TagClass::Subprogram) {
     const char *name = MC_dwarf_attr_integrate_string(die, DW_AT_name);
   frame.tag = tag;
   frame.id = dwarf_dieoffset(die);
   frame.object_info = info;
 
   if (klass == simgrid::dwarf::TagClass::Subprogram) {
     const char *name = MC_dwarf_attr_integrate_string(die, DW_AT_name);
-    if(ns)
+    if (ns)
       frame.name  = std::string(ns) + "::" + name;
     else if (name)
       frame.name = name;
       frame.name  = std::string(ns) + "::" + name;
     else if (name)
       frame.name = name;
-    else
-      frame.name.clear();
   }
 
   frame.abstract_origin_id =
   }
 
   frame.abstract_origin_id =
@@ -913,13 +910,14 @@ static void MC_dwarf_handle_scope_die(simgrid::mc::ObjectInformation* info, Dwar
   // Handle children:
   MC_dwarf_handle_children(info, die, unit, &frame, ns);
 
   // Handle children:
   MC_dwarf_handle_children(info, die, unit, &frame, ns);
 
-  // Someone needs this to be sorted but who?
+  // We sort them in order to have an (somewhat) efficient by name
+  // lookup:
   std::sort(frame.variables.begin(), frame.variables.end(),
     MC_compare_variable);
 
   // Register it:
   if (klass == simgrid::dwarf::TagClass::Subprogram)
   std::sort(frame.variables.begin(), frame.variables.end(),
     MC_compare_variable);
 
   // Register it:
   if (klass == simgrid::dwarf::TagClass::Subprogram)
-    info->subprograms[frame.id] = frame;
+    info->subprograms[frame.id] = std::move(frame);
   else if (klass == simgrid::dwarf::TagClass::Scope)
     parent_frame->scopes.push_back(std::move(frame));
 }
   else if (klass == simgrid::dwarf::TagClass::Scope)
     parent_frame->scopes.push_back(std::move(frame));
 }