Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Spell check, again O:-)
[simgrid.git] / tools / generate-dwarf-functions
1 #!/bin/sh
2 # Generate files from a given dwarf.h
3 # Usage: tools/generate-dwarf-functions /usr/include/dwarf.h
4
5 cat - > src/mc/mc_dwarf_tagnames.cpp <<EOF
6 /* Copyright (c) 2014-2015. The SimGrid Team.
7  * All rights reserved.                                                     */
8
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. */
11
12 /* Warning: autogenerated, do not edit! */
13
14 #include <dwarf.h>
15 #include <elfutils/libdw.h>
16
17 #include <xbt/base.h>
18
19 namespace simgrid {
20 namespace dwarf {
21
22 /** \brief Get the name of a dwarf tag (DW_TAG_*) from its code
23  *
24  *  \param tag tag code (see the DWARF specification)
25  *  \return name of the tag
26  */
27 XBT_PRIVATE
28 const char *tagname(int tag)
29 {
30   switch (tag) {
31 $(cat "$1" | grep DW_TAG_ | sed 's/.*\(DW_TAG_[^ ]*\) = \(0x[0-9a-f]*\).*/  case \2: return "\1";/')
32   case DW_TAG_invalid:
33     return "DW_TAG_invalid";
34   default:
35     return "DW_TAG_unknown";
36   }
37 }
38
39 }
40 }
41 EOF
42
43 cat - > src/mc/mc_dwarf_attrnames.cpp << EOF
44 /* Copyright (c) 2014-2015. The SimGrid Team.
45  * All rights reserved.                                                     */
46
47 /* This program is free software; you can redistribute it and/or modify it
48  * under the terms of the license (GNU LGPL) which comes with this package. */
49
50 /* Warning: autogenerated, do not edit! */
51
52 #include <dwarf.h>
53
54 #include <xbt/base.h>
55
56 namespace simgrid {
57 namespace dwarf  {
58
59 /** \brief Get the name of an attribute (DW_AT_*) from its code
60  *
61  *  \param attr attribute code (see the DWARF specification)
62  *  \return name of the attribute
63  */
64 XBT_PRIVATE
65 const char *attrname(int attr)
66 {
67   switch (attr) {
68 $(cat "$1" | grep DW_AT_ | sed 's/.*\(DW_AT_[^ ]*\) = \(0x[0-9a-f]*\).*/  case \2: return "\1";/')
69   default:
70     return "DW_AT_unknown";
71   }
72 }
73
74 }
75 }
76 EOF