1da0c48c4Sopenharmony_ci#!/bin/gawk -f
2da0c48c4Sopenharmony_ci
3da0c48c4Sopenharmony_ci## Copyright (C) 2012, 2015 Red Hat, Inc.
4da0c48c4Sopenharmony_ci##
5da0c48c4Sopenharmony_ci## This file is part of elfutils.
6da0c48c4Sopenharmony_ci##
7da0c48c4Sopenharmony_ci## This file is free software; you can redistribute it and/or modify
8da0c48c4Sopenharmony_ci## it under the terms of the GNU General Public License as published by
9da0c48c4Sopenharmony_ci## the Free Software Foundation; either version 3 of the License, or
10da0c48c4Sopenharmony_ci## (at your option) any later version.
11da0c48c4Sopenharmony_ci##
12da0c48c4Sopenharmony_ci## elfutils is distributed in the hope that it will be useful, but
13da0c48c4Sopenharmony_ci## WITHOUT ANY WARRANTY; without even the implied warranty of
14da0c48c4Sopenharmony_ci## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15da0c48c4Sopenharmony_ci## GNU General Public License for more details.
16da0c48c4Sopenharmony_ci##
17da0c48c4Sopenharmony_ci## You should have received a copy of the GNU General Public License
18da0c48c4Sopenharmony_ci## along with this program.  If not, see <http://www.gnu.org/licenses/>.
19da0c48c4Sopenharmony_ci
20da0c48c4Sopenharmony_ci$1 == "enum" { set = ""; next }
21da0c48c4Sopenharmony_ci
22da0c48c4Sopenharmony_ciset == "" && $1 ~ /DW_([A-Z_]+)_([^ ]+)/ {
23da0c48c4Sopenharmony_ci  set = $1;
24da0c48c4Sopenharmony_ci  sub(/^DW_/, "", set);
25da0c48c4Sopenharmony_ci  sub(/_[^[:upper:]_].*$/, "", set);
26da0c48c4Sopenharmony_ci  if (set ~ /LANG_.+/) set = "LANG";
27da0c48c4Sopenharmony_ci}
28da0c48c4Sopenharmony_ci
29da0c48c4Sopenharmony_ci$1 ~ /DW([_A-Z]+)_([^ ]+)/ {
30da0c48c4Sopenharmony_ci  match($1, ("DW_" set "_([^ ]+)"), fields);
31da0c48c4Sopenharmony_ci  elt = fields[1];
32da0c48c4Sopenharmony_ci  if (set in DW)
33da0c48c4Sopenharmony_ci    DW[set] = DW[set] "," elt;
34da0c48c4Sopenharmony_ci  else
35da0c48c4Sopenharmony_ci    DW[set] = elt;
36da0c48c4Sopenharmony_ci}
37da0c48c4Sopenharmony_ci
38da0c48c4Sopenharmony_ciEND {
39da0c48c4Sopenharmony_ci  print "/* Generated by config/known-dwarf.awk from libdw/dwarf.h contents.  */";
40da0c48c4Sopenharmony_ci  n = asorti(DW, sets);
41da0c48c4Sopenharmony_ci  for (i = 1; i <= n; ++i) {
42da0c48c4Sopenharmony_ci    set = sets[i];
43da0c48c4Sopenharmony_ci    if (what && what != set) continue;
44da0c48c4Sopenharmony_ci    split(DW[set], elts, ",");
45da0c48c4Sopenharmony_ci    m = asort(elts);
46da0c48c4Sopenharmony_ci    if (m == 0) continue;
47da0c48c4Sopenharmony_ci    print "\n#define DWARF_ALL_KNOWN_DW_" set " \\";
48da0c48c4Sopenharmony_ci    for (j = 1; j <= m; ++j) {
49da0c48c4Sopenharmony_ci      elt = elts[j];
50da0c48c4Sopenharmony_ci      if (elt ~ /(low?|hi|high)_user$/)
51da0c48c4Sopenharmony_ci	continue;
52da0c48c4Sopenharmony_ci      print "  DWARF_ONE_KNOWN_DW_" set " (" elt ", DW_" set "_" elt ") \\";
53da0c48c4Sopenharmony_ci    }
54da0c48c4Sopenharmony_ci    print "  /* End of DW_" set "_*.  */";
55da0c48c4Sopenharmony_ci  }
56da0c48c4Sopenharmony_ci}
57