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.
7 * All rights reserved. */
9 /* This program is free software; you can redistribute it and/or modify it
10 * under the terms of the license (GNU LGPL) which comes with this package. */
12 /* Warning: autogenerated, do not edit! */
15 #include <unordered_map>
17 #include \"src/mc/mc_dwarf.hpp\""
19 cat - > src/mc/mc_dwarf_tagnames.cpp <<EOF
23 const std::unordered_map<int, const char*> tagname_map = {
24 {0x00, "DW_TAG_invalid"},
25 $(cat "$1" | grep DW_TAG_ | sed 's/.*\(DW_TAG_[^ ]*\) = \(0x[0-9a-f]*\).*/ {\2, "\1"},/')
32 /** @brief Get the name of a dwarf tag (DW_TAG_*) from its code
34 * @param tag tag code (see the DWARF specification)
35 * @return name of the tag
38 const char *tagname(int tag)
40 auto name = tagname_map.find(tag);
41 return name == tagname_map.end() ? "DW_TAG_unknown" : name->second;
48 cat - > src/mc/mc_dwarf_attrnames.cpp << EOF
52 const std::unordered_map<int, const char*> attrname_map = {
53 $(cat "$1" | grep DW_AT_ | sed 's/.*\(DW_AT_[^ ]*\) = \(0x[0-9a-f]*\).*/ {\2, "\1"},/')
60 /** @brief Get the name of an attribute (DW_AT_*) from its code
62 * @param attr attribute code (see the DWARF specification)
63 * @return name of the attribute
66 const char *attrname(int attr)
68 auto name = attrname_map.find(attr);
69 return name == attrname_map.end() ? "DW_AT_unknown" : name->second;