Mark Wielaard | 387998b | 2011-10-31 15:01:50 +0100 | [diff] [blame^] | 1 | #!/bin/gawk -f |
Roland McGrath | 5513e64 | 2009-01-11 01:35:11 -0800 | [diff] [blame] | 2 | |
Roland McGrath | 97b12d0 | 2009-01-22 03:08:46 -0800 | [diff] [blame] | 3 | $1 == "enum" { set = ""; next } |
| 4 | |
| 5 | set == "" && $1 ~ /DW_([A-Z_]+)_([^ ]+)/ { |
| 6 | set = $1; |
| 7 | sub(/^DW_/, "", set); |
| 8 | sub(/_[^[:upper:]_].*$/, "", set); |
| 9 | if (set ~ /LANG_.+/) set = "LANG"; |
| 10 | } |
| 11 | |
| 12 | $1 ~ /DW([_A-Z]+)_([^ ]+)/ { |
| 13 | match($1, ("DW_" set "_([^ ]+)"), fields); |
| 14 | elt = fields[1]; |
Roland McGrath | 5513e64 | 2009-01-11 01:35:11 -0800 | [diff] [blame] | 15 | if (set in DW) |
| 16 | DW[set] = DW[set] "," elt; |
| 17 | else |
| 18 | DW[set] = elt; |
| 19 | if ($NF == "*/" && $4 == "/*") { |
| 20 | c = $5; |
| 21 | for (i = 6; i < NF; ++i) c = c " " $i; |
| 22 | comment[set, elt] = c; |
| 23 | } |
| 24 | } |
Roland McGrath | 97b12d0 | 2009-01-22 03:08:46 -0800 | [diff] [blame] | 25 | |
Roland McGrath | 5513e64 | 2009-01-11 01:35:11 -0800 | [diff] [blame] | 26 | END { |
| 27 | print "/* Generated by config/dwarf-known.awk from libdw.h contents. */"; |
| 28 | n = asorti(DW, sets); |
| 29 | for (i = 1; i <= n; ++i) { |
| 30 | set = sets[i]; |
| 31 | if (what && what != set) continue; |
Roland McGrath | 5513e64 | 2009-01-11 01:35:11 -0800 | [diff] [blame] | 32 | split(DW[set], elts, ","); |
| 33 | m = asort(elts); |
| 34 | lo = hi = ""; |
Roland McGrath | 97b12d0 | 2009-01-22 03:08:46 -0800 | [diff] [blame] | 35 | if (m == 0) continue; |
| 36 | print "\n#define ALL_KNOWN_DW_" set " \\"; |
Roland McGrath | 5513e64 | 2009-01-11 01:35:11 -0800 | [diff] [blame] | 37 | for (j = 1; j <= m; ++j) { |
| 38 | elt = elts[j]; |
| 39 | if (elt ~ /(lo|low)_user$/) { |
| 40 | lo = elt; |
| 41 | continue; |
| 42 | } |
| 43 | if (elt ~ /(hi|high)_user$/) { |
| 44 | hi = elt; |
| 45 | continue; |
| 46 | } |
| 47 | if (comment[set, elt]) |
| 48 | print " ONE_KNOWN_DW_" set "_DESC (" elt ", DW_" set "_" elt \ |
| 49 | ", \"" comment[set, elt] "\") \\"; |
| 50 | else |
| 51 | print " ONE_KNOWN_DW_" set " (" elt ", DW_" set "_" elt ") \\"; |
| 52 | } |
| 53 | print " /* End of DW_" set "_*. */"; |
| 54 | } |
| 55 | } |