Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
addd60b281d5936e04a035b3f423d0f7a2e6eee2
[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
16 #include <xbt/base.h>
17
18 /** \brief Get the name of a dwarf tag (DW_TAG_*) from its code
19  *
20  *  \param tag tag code (see the DWARF specification)
21  *  \return name of the tag
22  */
23 XBT_PRIVATE
24 const char *MC_dwarf_tagname(int tag)
25 {
26   switch (tag) {
27 $(cat "$1" | grep DW_TAG_ | sed 's/.*\(DW_TAG_[^ ]*\) = \(0x[0-9a-f]*\).*/  case \2: return "\1";/')
28   default:
29     return "DW_TAG_unknown";
30   }
31 }
32 EOF
33
34 cat - > src/mc/mc_dwarf_attrnames.cpp << EOF
35 /* Copyright (c) 2014-2015. The SimGrid Team.
36  * All rights reserved.                                                     */
37
38 /* This program is free software; you can redistribute it and/or modify it
39  * under the terms of the license (GNU LGPL) which comes with this package. */
40
41 /* Warning: autogenerated, do not edit! */
42
43 #include <xbt/base.h>
44 #include <dwarf.h>
45
46 /** \brief Get the name of an attribute (DW_AT_*) from its code
47  *
48  *  \param attr attribute code (see the DWARF specification)
49  *  \return name of the attribute
50  */
51 const char *MC_dwarf_attrname(int attr)
52 {
53   switch (attr) {
54 $(cat "$1" | grep DW_AT_ | sed 's/.*\(DW_AT_[^ ]*\) = \(0x[0-9a-f]*\).*/  case \2: return "\1";/')
55   default:
56     return "DW_AT_unknown";
57   }
58 }
59 EOF