2 # Generate files from a given dwarf.h
3 # Usage: tools/generate-dwarf-functions /usr/include/dwarf.h
6 /* Copyright (c) 2014-$(date +%Y). The SimGrid Team. All rights reserved. */
8 /* This program is free software; you can redistribute it and/or modify it
9 * under the terms of the license (GNU LGPL) which comes with this package. */
11 /* Warning: autogenerated, do not edit! */
13 #include \"src/mc/inspect/mc_dwarf.hpp\"
16 #include <unordered_map>"
18 cat - > src/mc/inspect/mc_dwarf_tagnames.cpp <<EOF
22 const std::unordered_map<int, const char*> tagname_map = {
23 {0x00, "DW_TAG_invalid"},
24 $(sed -n 's/.*\(DW_TAG_[^ ]*\) = \(0x[0-9a-f]*\).*/ {\2, "\1"},/p' -- "$1")
28 namespace simgrid::dwarf {
30 /** @brief Get the name of a dwarf tag (DW_TAG_*) from its code
32 * @param tag tag code (see the DWARF specification)
33 * @return name of the tag
36 const char* tagname(int tag)
38 auto name = tagname_map.find(tag);
39 return name == tagname_map.end() ? "DW_TAG_unknown" : name->second;
42 } // namespace simgrid::dwarf
45 cat - > src/mc/inspect/mc_dwarf_attrnames.cpp << EOF
49 const std::unordered_map<int, const char*> attrname_map = {
50 $(sed -n 's/.*\(DW_AT_[^ ]*\) = \(0x[0-9a-f]*\).*/ {\2, "\1"},/p' -- "$1")
54 namespace simgrid::dwarf {
56 /** @brief Get the name of an attribute (DW_AT_*) from its code
58 * @param attr attribute code (see the DWARF specification)
59 * @return name of the attribute
62 const char* attrname(int attr)
64 auto name = attrname_map.find(attr);
65 return name == attrname_map.end() ? "DW_AT_unknown" : name->second;
68 } // namespace simgrid::dwarf