Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
38bd20e42053630a4791133988eaf86f2f653503
[simgrid.git] / tools / generate-dwarf-functions
1 #!/bin/sh
2 # Generate files from a given dwarf.h
3
4 cat - > src/mc/mc_dwarf_tagnames.cpp <<EOF
5 /* Copyright (c) 2014. The SimGrid Team.
6  * All rights reserved.                                                     */
7
8 /* This program is free software; you can redistribute it and/or modify it
9  * under the terms of the license (GNU LGPL) which comes with this package. */
10
11 /* Warning: autogenerated, do not edit! */
12
13 #include <dwarf.h>
14
15 #include <xbt/base.h>
16 #include "mc_object_info.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_INTERNAL
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   case DW_TAG_invalid:
29     return "DW_TAG_invalid";
30   default:
31     return "DW_TAG_unknown";
32   }
33 }
34 EOF
35
36 cat - > src/mc/mc_dwarf_attrnames.cpp << EOF
37 /* Copyright (c) 2014. The SimGrid Team.
38  * All rights reserved.                                                     */
39
40 /* This program is free software; you can redistribute it and/or modify it
41  * under the terms of the license (GNU LGPL) which comes with this package. */
42
43 /* Warning: autogenerated, do not edit! */
44
45 #include <xbt/base.h>
46 #include <dwarf.h>
47
48 #include "mc_object_info.h"
49
50 /** \brief Get the name of an attribute (DW_AT_*) from its code
51  *
52  *  \param attr attribute code (see the DWARF specification)
53  *  \return name of the attribute
54  */
55 const char *MC_dwarf_attrname(int attr)
56 {
57   switch (attr) {
58 $(cat "$1" | grep DW_AT_ | sed 's/.*\(DW_AT_[^ ]*\) = \(0x[0-9a-f]*\).*/  case \2: return "\1";/')
59   default:
60     return "DW_AT_unknown";
61   }
62 }
63 EOF