Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[mc] Move some code into simgrid::dwarf namespace
authorGabriel Corona <gabriel.corona@loria.fr>
Mon, 12 Oct 2015 06:28:39 +0000 (08:28 +0200)
committerGabriel Corona <gabriel.corona@loria.fr>
Thu, 15 Oct 2015 09:18:31 +0000 (11:18 +0200)
src/mc/mc_dwarf.cpp
src/mc/mc_dwarf.hpp
src/mc/mc_dwarf_attrnames.cpp
src/mc/mc_dwarf_tagnames.cpp
src/mc/mc_object_info.h
tools/generate-dwarf-functions

index b312366..b40ddb8 100644 (file)
@@ -24,6 +24,7 @@
 
 #include "mc_object_info.h"
 #include "mc_private.h"
+#include "mc_dwarf.hpp"
 
 #include "mc/Process.hpp"
 #include "mc/ObjectInformation.hpp"
@@ -133,8 +134,7 @@ enum class FormClass {
   RangeListPtr
 };
 
-namespace {
-
+XBT_PRIVATE
 TagClass classify_tag(int tag)
 {
   switch (tag) {
@@ -193,6 +193,7 @@ TagClass classify_tag(int tag)
  *  \param form The form (values taken from the DWARF spec)
  *  \return An internal representation for the corresponding class
  * */
+XBT_PRIVATE
 FormClass classify_form(int form)
 {
   switch (form) {
@@ -232,18 +233,18 @@ FormClass classify_form(int form)
   }
 }
 
-}
-}
-}
-
 /** \brief Get the name of the tag of a given DIE
  *
  *  \param die DIE
  *  \return name of the tag of this DIE
  */
-static inline const char *MC_dwarf_die_tagname(Dwarf_Die * die)
+inline XBT_PRIVATE
+const char *tagname(Dwarf_Die * die)
 {
-  return MC_dwarf_tagname(dwarf_tag(die));
+  return simgrid::dwarf::tagname(dwarf_tag(die));
+}
+
+}
 }
 
 // ***** Attributes
@@ -351,7 +352,8 @@ static bool MC_dwarf_attr_flag(Dwarf_Die * die, int attribute, bool integrate)
 
   bool result;
   if (dwarf_formflag(&attr, &result))
-    xbt_die("Unexpected form for attribute %s", MC_dwarf_attrname(attribute));
+    xbt_die("Unexpected form for attribute %s",
+      simgrid::dwarf::attrname(attribute));
   return result;
 }
 
@@ -407,7 +409,7 @@ static uint64_t MC_dwarf_subrange_element_count(Dwarf_Die * die,
   xbt_assert(dwarf_tag(die) == DW_TAG_enumeration_type
              || dwarf_tag(die) == DW_TAG_subrange_type,
              "MC_dwarf_subrange_element_count called with DIE of type %s",
-             MC_dwarf_die_tagname(die));
+             simgrid::dwarf::tagname(die));
 
   // Use DW_TAG_count if present:
   if (dwarf_hasattr_integrate(die, DW_AT_count))
@@ -442,7 +444,7 @@ static uint64_t MC_dwarf_array_element_count(Dwarf_Die * die, Dwarf_Die * unit)
 {
   xbt_assert(dwarf_tag(die) == DW_TAG_array_type,
              "MC_dwarf_array_element_count called with DIE of type %s",
-             MC_dwarf_die_tagname(die));
+             simgrid::dwarf::tagname(die));
 
   int result = 1;
   Dwarf_Die child;
index d5b31f5..dcba3ce 100644 (file)
 #include "mc/Variable.hpp"
 #include "mc/mc_memory_map.h"
 
+namespace simgrid {
+namespace dwarf {
+
+XBT_PRIVATE const char* attrname(int attr);
+XBT_PRIVATE const char* tagname(int tag);
+
+}
+}
+
 XBT_PRIVATE std::shared_ptr<simgrid::mc::ObjectInformation> MC_find_object_info(
   std::vector<simgrid::mc::VmMap> const& maps, const char* name, int executable);
 XBT_PRIVATE void MC_post_process_object_info(simgrid::mc::Process* process, simgrid::mc::ObjectInformation* info);
@@ -26,9 +35,6 @@ XBT_PRIVATE void MC_post_process_object_info(simgrid::mc::Process* process, simg
 XBT_PRIVATE void MC_dwarf_get_variables(simgrid::mc::ObjectInformation* info);
 XBT_PRIVATE void MC_dwarf_get_variables_libdw(simgrid::mc::ObjectInformation* info);
 
-XBT_PRIVATE const char* MC_dwarf_attrname(int attr);
-XBT_PRIVATE const char* MC_dwarf_tagname(int tag);
-
 XBT_PRIVATE void* mc_member_resolve(
   const void* base, simgrid::mc::Type* type, simgrid::mc::Member* member,
   simgrid::mc::AddressSpace* snapshot, int process_index);
index 17e4446..193379a 100644 (file)
@@ -6,17 +6,20 @@
 
 /* Warning: autogenerated, do not edit! */
 
-#include <xbt/base.h>
 #include <dwarf.h>
 
-#include "mc_object_info.h"
+#include <xbt/base.h>
+
+namespace simgrid {
+namespace dwarf  {
 
 /** \brief Get the name of an attribute (DW_AT_*) from its code
  *
  *  \param attr attribute code (see the DWARF specification)
  *  \return name of the attribute
  */
-const char *MC_dwarf_attrname(int attr)
+XBT_PRIVATE
+const char *attrname(int attr)
 {
   switch (attr) {
   case 0x01: return "DW_AT_sibling";
@@ -162,3 +165,6 @@ const char *MC_dwarf_attrname(int attr)
     return "DW_AT_unknown";
   }
 }
+
+}
+}
index 983f111..19ee9af 100644 (file)
@@ -10,7 +10,9 @@
 #include <elfutils/libdw.h>
 
 #include <xbt/base.h>
-#include "mc_object_info.h"
+
+namespace simgrid {
+namespace dwarf {
 
 /** \brief Get the name of a dwarf tag (DW_TAG_*) from its code
  *
@@ -18,7 +20,7 @@
  *  \return name of the tag
  */
 XBT_PRIVATE
-const char *MC_dwarf_tagname(int tag)
+const char *tagname(int tag)
 {
   switch (tag) {
   case 0x01: return "DW_TAG_array_type";
@@ -101,3 +103,6 @@ const char *MC_dwarf_tagname(int tag)
     return "DW_TAG_unknown";
   }
 }
+
+}
+}
index 019c758..961bf44 100644 (file)
@@ -22,7 +22,4 @@ XBT_PRIVATE  void MC_post_process_object_info(simgrid::mc::Process* process, sim
 XBT_PRIVATE  void MC_dwarf_get_variables(simgrid::mc::ObjectInformation* info);
 XBT_PRIVATE  void MC_dwarf_get_variables_libdw(simgrid::mc::ObjectInformation* info);
 
-XBT_PRIVATE  const char* MC_dwarf_attrname(int attr);
-XBT_PRIVATE  const char* MC_dwarf_tagname(int tag);
-
 #endif
index 984287c..6f503c2 100755 (executable)
@@ -3,7 +3,7 @@
 # Usage: tools/generate-dwarf-functions /usr/include/dwarf.h
 
 cat - > src/mc/mc_dwarf_tagnames.cpp <<EOF
-/* Copyright (c) 2014. The SimGrid Team.
+/* Copyright (c) 2014-2015. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
@@ -15,7 +15,9 @@ cat - > src/mc/mc_dwarf_tagnames.cpp <<EOF
 #include <elfutils/libdw.h>
 
 #include <xbt/base.h>
-#include "mc_object_info.h"
+
+namespace simgrid {
+namespace dwarf {
 
 /** \brief Get the name of a dwarf tag (DW_TAG_*) from its code
  *
@@ -23,7 +25,7 @@ cat - > src/mc/mc_dwarf_tagnames.cpp <<EOF
  *  \return name of the tag
  */
 XBT_PRIVATE
-const char *MC_dwarf_tagname(int tag)
+const char *tagname(int tag)
 {
   switch (tag) {
 $(cat "$1" | grep DW_TAG_ | sed 's/.*\(DW_TAG_[^ ]*\) = \(0x[0-9a-f]*\).*/  case \2: return "\1";/')
@@ -33,10 +35,13 @@ $(cat "$1" | grep DW_TAG_ | sed 's/.*\(DW_TAG_[^ ]*\) = \(0x[0-9a-f]*\).*/  case
     return "DW_TAG_unknown";
   }
 }
+
+}
+}
 EOF
 
 cat - > src/mc/mc_dwarf_attrnames.cpp << EOF
-/* Copyright (c) 2014. The SimGrid Team.
+/* Copyright (c) 2014-2015. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
@@ -44,17 +49,20 @@ cat - > src/mc/mc_dwarf_attrnames.cpp << EOF
 
 /* Warning: autogenerated, do not edit! */
 
-#include <xbt/base.h>
 #include <dwarf.h>
 
-#include "mc_object_info.h"
+#include <xbt/base.h>
+
+namespace simgrid {
+namespace dwarf  {
 
 /** \brief Get the name of an attribute (DW_AT_*) from its code
  *
  *  \param attr attribute code (see the DWARF specification)
  *  \return name of the attribute
  */
-const char *MC_dwarf_attrname(int attr)
+XBT_PRIVATE
+const char *attrname(int attr)
 {
   switch (attr) {
 $(cat "$1" | grep DW_AT_ | sed 's/.*\(DW_AT_[^ ]*\) = \(0x[0-9a-f]*\).*/  case \2: return "\1";/')
@@ -62,4 +70,7 @@ $(cat "$1" | grep DW_AT_ | sed 's/.*\(DW_AT_[^ ]*\) = \(0x[0-9a-f]*\).*/  case \
     return "DW_AT_unknown";
   }
 }
+
+}
+}
 EOF