Logo AND Algorithmique Numérique Distribuée

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