From f29b8940106312a89054635c2e1926874c2ce47d Mon Sep 17 00:00:00 2001 From: Gabriel Corona Date: Mon, 12 Oct 2015 08:28:39 +0200 Subject: [PATCH] [mc] Move some code into simgrid::dwarf namespace --- src/mc/mc_dwarf.cpp | 24 +++++++++++++----------- src/mc/mc_dwarf.hpp | 12 +++++++++--- src/mc/mc_dwarf_attrnames.cpp | 12 +++++++++--- src/mc/mc_dwarf_tagnames.cpp | 9 +++++++-- src/mc/mc_object_info.h | 3 --- tools/generate-dwarf-functions | 25 ++++++++++++++++++------- 6 files changed, 56 insertions(+), 29 deletions(-) diff --git a/src/mc/mc_dwarf.cpp b/src/mc/mc_dwarf.cpp index b312366e8f..b40ddb8f1c 100644 --- a/src/mc/mc_dwarf.cpp +++ b/src/mc/mc_dwarf.cpp @@ -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; diff --git a/src/mc/mc_dwarf.hpp b/src/mc/mc_dwarf.hpp index d5b31f535c..dcba3ce478 100644 --- a/src/mc/mc_dwarf.hpp +++ b/src/mc/mc_dwarf.hpp @@ -19,6 +19,15 @@ #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 MC_find_object_info( std::vector 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); diff --git a/src/mc/mc_dwarf_attrnames.cpp b/src/mc/mc_dwarf_attrnames.cpp index 17e4446c6a..193379a657 100644 --- a/src/mc/mc_dwarf_attrnames.cpp +++ b/src/mc/mc_dwarf_attrnames.cpp @@ -6,17 +6,20 @@ /* Warning: autogenerated, do not edit! */ -#include #include -#include "mc_object_info.h" +#include + +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"; } } + +} +} diff --git a/src/mc/mc_dwarf_tagnames.cpp b/src/mc/mc_dwarf_tagnames.cpp index 983f111c31..19ee9af6ed 100644 --- a/src/mc/mc_dwarf_tagnames.cpp +++ b/src/mc/mc_dwarf_tagnames.cpp @@ -10,7 +10,9 @@ #include #include -#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"; } } + +} +} diff --git a/src/mc/mc_object_info.h b/src/mc/mc_object_info.h index 019c758ece..961bf44e72 100644 --- a/src/mc/mc_object_info.h +++ b/src/mc/mc_object_info.h @@ -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 diff --git a/tools/generate-dwarf-functions b/tools/generate-dwarf-functions index 984287c1a2..6f503c2cb0 100755 --- a/tools/generate-dwarf-functions +++ b/tools/generate-dwarf-functions @@ -3,7 +3,7 @@ # Usage: tools/generate-dwarf-functions /usr/include/dwarf.h cat - > src/mc/mc_dwarf_tagnames.cpp < src/mc/mc_dwarf_tagnames.cpp < #include -#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 < 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 #include -#include "mc_object_info.h" +#include + +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 -- 2.20.1