Logo AND Algorithmique Numérique Distribuée

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