blob: 52ec5b6260272948905b68710fc3fe11a530b459 [file] [log] [blame]
Mark Wielaard387998b2011-10-31 15:01:50 +01001#!/bin/gawk -f
Roland McGrath5513e642009-01-11 01:35:11 -08002
Mark Wielaardde2ed972012-06-05 17:15:16 +02003## Copyright (C) 2012 Red Hat, Inc.
4##
5## This file is part of elfutils.
6##
7## This file is free software; you can redistribute it and/or modify
8## it under the terms of the GNU General Public License as published by
9## the Free Software Foundation; either version 3 of the License, or
10## (at your option) any later version.
11##
12## elfutils is distributed in the hope that it will be useful, but
13## WITHOUT ANY WARRANTY; without even the implied warranty of
14## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15## GNU General Public License for more details.
16##
17## You should have received a copy of the GNU General Public License
18## along with this program. If not, see <http://www.gnu.org/licenses/>.
19
Roland McGrath97b12d02009-01-22 03:08:46 -080020$1 == "enum" { set = ""; next }
21
22set == "" && $1 ~ /DW_([A-Z_]+)_([^ ]+)/ {
23 set = $1;
24 sub(/^DW_/, "", set);
25 sub(/_[^[:upper:]_].*$/, "", set);
26 if (set ~ /LANG_.+/) set = "LANG";
27}
28
29$1 ~ /DW([_A-Z]+)_([^ ]+)/ {
30 match($1, ("DW_" set "_([^ ]+)"), fields);
31 elt = fields[1];
Roland McGrath5513e642009-01-11 01:35:11 -080032 if (set in DW)
33 DW[set] = DW[set] "," elt;
34 else
35 DW[set] = elt;
36 if ($NF == "*/" && $4 == "/*") {
37 c = $5;
38 for (i = 6; i < NF; ++i) c = c " " $i;
39 comment[set, elt] = c;
40 }
41}
Roland McGrath97b12d02009-01-22 03:08:46 -080042
Roland McGrath5513e642009-01-11 01:35:11 -080043END {
Mark Wielaard1da612b2012-07-19 23:31:45 +020044 print "/* Generated by config/known-dwarf.awk from libdw/dwarf.h contents. */";
Roland McGrath5513e642009-01-11 01:35:11 -080045 n = asorti(DW, sets);
46 for (i = 1; i <= n; ++i) {
47 set = sets[i];
48 if (what && what != set) continue;
Roland McGrath5513e642009-01-11 01:35:11 -080049 split(DW[set], elts, ",");
50 m = asort(elts);
51 lo = hi = "";
Roland McGrath97b12d02009-01-22 03:08:46 -080052 if (m == 0) continue;
53 print "\n#define ALL_KNOWN_DW_" set " \\";
Roland McGrath5513e642009-01-11 01:35:11 -080054 for (j = 1; j <= m; ++j) {
55 elt = elts[j];
56 if (elt ~ /(lo|low)_user$/) {
57 lo = elt;
58 continue;
59 }
60 if (elt ~ /(hi|high)_user$/) {
61 hi = elt;
62 continue;
63 }
64 if (comment[set, elt])
65 print " ONE_KNOWN_DW_" set "_DESC (" elt ", DW_" set "_" elt \
66 ", \"" comment[set, elt] "\") \\";
67 else
68 print " ONE_KNOWN_DW_" set " (" elt ", DW_" set "_" elt ") \\";
69 }
70 print " /* End of DW_" set "_*. */";
71 }
72}