Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[mc] Move ObjectInformation methods in mc_object_info.cpp
authorGabriel Corona <gabriel.corona@loria.fr>
Mon, 20 Jul 2015 13:42:47 +0000 (15:42 +0200)
committerGabriel Corona <gabriel.corona@loria.fr>
Tue, 21 Jul 2015 12:18:31 +0000 (14:18 +0200)
src/mc/mc_dwarf.cpp
src/mc/mc_object_info.cpp

index 4e86738..91e62c0 100644 (file)
 #include "mc_object_info.h"
 #include "mc_private.h"
 
-static void mc_variable_free_voidp(void *t)
-{
-  delete *(simgrid::mc::Variable**)t;
-}
-
-static void mc_frame_free(void* frame)
-{
-  delete (simgrid::mc::Frame*)frame;
-}
-
 static void MC_dwarf_register_global_variable(
   mc_object_info_t info, std::unique_ptr<simgrid::mc::Variable> variable);
 static void MC_register_variable(
@@ -1030,77 +1020,6 @@ void MC_dwarf_get_variables(mc_object_info_t info)
   close(fd);
 }
 
-/************************** Free functions *************************/
-
-static void dw_type_free(mc_type_t t)
-{
-  delete t;
-}
-
-// ***** object_info
-
-namespace simgrid {
-namespace mc {
-
-ObjectInformation::ObjectInformation()
-{
-  this->flags = 0;
-  this->file_name = nullptr;
-  this->start = nullptr;
-  this->end = nullptr;
-  this->start_exec = nullptr;
-  this->end_exec = nullptr;
-  this->start_rw = nullptr;
-  this->end_rw = nullptr;
-  this->start_ro = nullptr;
-  this->end_ro = nullptr;
-  this->subprograms = xbt_dict_new_homogeneous(mc_frame_free);
-  this->types = xbt_dict_new_homogeneous((void (*)(void *)) dw_type_free);
-  this->full_types_by_name = xbt_dict_new_homogeneous(NULL);
-  this->functions_index = nullptr;
-}
-
-ObjectInformation::~ObjectInformation()
-{
-  xbt_free(this->file_name);
-  xbt_dict_free(&this->subprograms);
-  xbt_dict_free(&this->types);
-  xbt_dict_free(&this->full_types_by_name);
-  xbt_dynar_free(&this->functions_index);
-}
-
-/** Find the DWARF offset for this ELF object
- *
- *  An offset is applied to address found in DWARF:
- *
- *  <ul>
- *    <li>for an executable obejct, addresses are virtual address
- *        (there is no offset) i.e. \f$\text{virtual address} = \{dwarf address}\f$;</li>
- *    <li>for a shared object, the addreses are offset from the begining
- *        of the shared object (the base address of the mapped shared
- *        object must be used as offset
- *        i.e. \f$\text{virtual address} = \text{shared object base address}
- *             + \text{dwarf address}\f$.</li>
- *
- */
-void *ObjectInformation::base_address() const
-{
-  if (this->executable())
-    return nullptr;
-
-  void *result = this->start_exec;
-  if (this->start_rw != NULL && result > (void *) this->start_rw)
-    result = this->start_rw;
-  if (this->start_ro != NULL && result > (void *) this->start_ro)
-    result = this->start_ro;
-  return result;
-}
-
-}
-}
-
-// ***** Helpers
-
 // ***** Functions index
 
 static int MC_compare_frame_index_items(mc_function_index_item_t a,
index 7fc9808..6034269 100644 (file)
 namespace simgrid {
 namespace mc {
 
+// Free functions
+
+static void mc_frame_free(void* frame)
+{
+  delete (simgrid::mc::Frame*)frame;
+}
+
+static void mc_type_free(void* t)
+{
+  delete (simgrid::mc::Type*)t;
+}
+
 // Type
 
 Type::Type()
@@ -53,6 +65,60 @@ Frame::Frame()
 
 // ObjectInformations
 
+ObjectInformation::ObjectInformation()
+{
+  this->flags = 0;
+  this->file_name = nullptr;
+  this->start = nullptr;
+  this->end = nullptr;
+  this->start_exec = nullptr;
+  this->end_exec = nullptr;
+  this->start_rw = nullptr;
+  this->end_rw = nullptr;
+  this->start_ro = nullptr;
+  this->end_ro = nullptr;
+  this->subprograms = xbt_dict_new_homogeneous(mc_frame_free);
+  this->types = xbt_dict_new_homogeneous((void (*)(void *)) mc_type_free);
+  this->full_types_by_name = xbt_dict_new_homogeneous(NULL);
+  this->functions_index = nullptr;
+}
+
+ObjectInformation::~ObjectInformation()
+{
+  xbt_free(this->file_name);
+  xbt_dict_free(&this->subprograms);
+  xbt_dict_free(&this->types);
+  xbt_dict_free(&this->full_types_by_name);
+  xbt_dynar_free(&this->functions_index);
+}
+
+/** Find the DWARF offset for this ELF object
+ *
+ *  An offset is applied to address found in DWARF:
+ *
+ *  <ul>
+ *    <li>for an executable obejct, addresses are virtual address
+ *        (there is no offset) i.e. \f$\text{virtual address} = \{dwarf address}\f$;</li>
+ *    <li>for a shared object, the addreses are offset from the begining
+ *        of the shared object (the base address of the mapped shared
+ *        object must be used as offset
+ *        i.e. \f$\text{virtual address} = \text{shared object base address}
+ *             + \text{dwarf address}\f$.</li>
+ *
+ */
+void *ObjectInformation::base_address() const
+{
+  if (this->executable())
+    return nullptr;
+
+  void *result = this->start_exec;
+  if (this->start_rw != NULL && result > (void *) this->start_rw)
+    result = this->start_rw;
+  if (this->start_ro != NULL && result > (void *) this->start_ro)
+    result = this->start_ro;
+  return result;
+}
+
 mc_frame_t ObjectInformation::find_function(const void *ip) const
 {
   xbt_dynar_t dynar = this->functions_index;