1 #!/bin/gawk -f 2 3 ## 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 20 $1 == "enum" { set = ""; next } 21 22 set == "" && $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]; 32 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 } 42 43 END { 44 print "/* Generated by config/known-dwarf.awk from libdw/dwarf.h contents. */"; 45 n = asorti(DW, sets); 46 for (i = 1; i <= n; ++i) { 47 set = sets[i]; 48 if (what && what != set) continue; 49 split(DW[set], elts, ","); 50 m = asort(elts); 51 lo = hi = ""; 52 if (m == 0) continue; 53 print "\n#define ALL_KNOWN_DW_" set " \\"; 54 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 } 73