Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[mc] Remove ugly #include
[simgrid.git] / tools / generate-dwarf-functions
diff --git a/tools/generate-dwarf-functions b/tools/generate-dwarf-functions
new file mode 100755 (executable)
index 0000000..38bd20e
--- /dev/null
@@ -0,0 +1,63 @@
+#!/bin/sh
+# Generate files from a given dwarf.h
+
+cat - > src/mc/mc_dwarf_tagnames.cpp <<EOF
+/* Copyright (c) 2014. The SimGrid Team.
+ * All rights reserved.                                                     */
+
+/* This program is free software; you can redistribute it and/or modify it
+ * under the terms of the license (GNU LGPL) which comes with this package. */
+
+/* Warning: autogenerated, do not edit! */
+
+#include <dwarf.h>
+
+#include <xbt/base.h>
+#include "mc_object_info.h"
+
+/** \brief Get the name of a dwarf tag (DW_TAG_*) from its code
+ *
+ *  \param tag tag code (see the DWARF specification)
+ *  \return name of the tag
+ */
+XBT_INTERNAL
+const char *MC_dwarf_tagname(int tag)
+{
+  switch (tag) {
+$(cat "$1" | grep DW_TAG_ | sed 's/.*\(DW_TAG_[^ ]*\) = \(0x[0-9a-f]*\).*/  case \2: return "\1";/')
+  case DW_TAG_invalid:
+    return "DW_TAG_invalid";
+  default:
+    return "DW_TAG_unknown";
+  }
+}
+EOF
+
+cat - > src/mc/mc_dwarf_attrnames.cpp << EOF
+/* Copyright (c) 2014. The SimGrid Team.
+ * All rights reserved.                                                     */
+
+/* This program is free software; you can redistribute it and/or modify it
+ * under the terms of the license (GNU LGPL) which comes with this package. */
+
+/* Warning: autogenerated, do not edit! */
+
+#include <xbt/base.h>
+#include <dwarf.h>
+
+#include "mc_object_info.h"
+
+/** \brief Get the name of an attribute (DW_AT_*) from its code
+ *
+ *  \param attr attribute code (see the DWARF specification)
+ *  \return name of the attribute
+ */
+const char *MC_dwarf_attrname(int attr)
+{
+  switch (attr) {
+$(cat "$1" | grep DW_AT_ | sed 's/.*\(DW_AT_[^ ]*\) = \(0x[0-9a-f]*\).*/  case \2: return "\1";/')
+  default:
+    return "DW_AT_unknown";
+  }
+}
+EOF