Home | History | Annotate | Download | only in config
      1 #!/bin/gawk -f
      2 
      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];
     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 }
     25 
     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;
     32     split(DW[set], elts, ",");
     33     m = asort(elts);
     34     lo = hi = "";
     35     if (m == 0) continue;
     36     print "\n#define ALL_KNOWN_DW_" set " \\";
     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 }
     56