c99 and posix coverage table generator scirpts
authornsz <nsz@port70.net>
Sat, 18 Jun 2011 19:54:03 +0000 (21:54 +0200)
committernsz <nsz@port70.net>
Sat, 18 Jun 2011 19:54:03 +0000 (21:54 +0200)
tab_c99.sh [new file with mode: 0755]
tab_posix.sh [new file with mode: 0755]

diff --git a/tab_c99.sh b/tab_c99.sh
new file mode 100755 (executable)
index 0000000..80001c2
--- /dev/null
@@ -0,0 +1,100 @@
+#!/bin/sh
+
+export LC_ALL=C
+MUSL=../musl
+
+( cd $MUSL; git log -n1 ) | awk '
+BEGIN {
+       getline
+       hash = $2
+       getline
+
+       commit = "<h4>commit</h4><p>commit <a href=\"http://git.etalabs.net/cgi-bin/gitweb.cgi?p=musl;a=commit;h=" hash "\">" hash "</a>"
+       while (getline == 1)
+               commit = commit "<br>" $0
+
+       FS = "\t"
+
+       c99 = "data/c99"
+       syms = "data/musl.syms"
+       tags = "data/musl.tags"
+
+       while (getline < syms == 1)
+               sym[$2] = $1
+       while (getline < tags == 1) {
+               if ($2 ~ /bits\//)
+                       s = $3 " "
+               else
+                       s = "<a href=\"http://git.etalabs.net/cgi-bin/gitweb.cgi?p=musl;a=blob;f=include/" $2 ";hb=" hash "#l" $4 "\">" $3 "</a> "
+               kind[$1] = kind[$1] $3
+               kindstr[$1] = kindstr[$1] s
+       }
+
+       legend = "<h4>legend</h4><ul><li>status: musl implementation status summary<ul>"
+       legend = legend "<li>(empty) - implemented"
+       legend = legend "<li>nosym - prototype found in include files (see decl) but not in libc.a (see sym)"
+       legend = legend "<li>nodecl - symbol is in libc.a but not declared in a public header"
+       legend = legend "<li>missing - neither in include files (see decl) nor in libc.a (see sym)"
+       legend = legend "</ul><li>sym: external symbol kind as found by `nm libc.a` (symbol kind only reported once)<ul>"
+#      legend = legend "<li>A - symbol value is absolute"
+#      legend = legend "<li>B - symbol is in the uninitialized data section (known as BSS)"
+       legend = legend "<li>C - symbol is common (uninitialized data)"
+       legend = legend "<li>D - symbol is in the initialized data section"
+#      legend = legend "<li>G - symbol is in the initialized data section for small objects"
+#      legend = legend "<li>I - indirect reference to another symbol"
+#      legend = legend "<li>N - debugging symbol"
+       legend = legend "<li>R - symbol is in the read only data section"
+#      legend = legend "<li>S - symbol is in the uninitialized data section for small objects"
+       legend = legend "<li>T - symbol is in the text section"
+#      legend = legend "<li>U - undefined symbol"
+       legend = legend "<li>V - weak object"
+       legend = legend "<li>W - weak symbol"
+       legend = legend "</ul><li>decl: kind of declaration as found by `ctags -R include` (every occurance is reported, arch specific definitions are not linked)<ul>"
+       legend = legend "<li>d - macro definition"
+       legend = legend "<li>t - typedef"
+       legend = legend "<li>s - struct declaration"
+       legend = legend "<li>u - union declaration"
+       legend = legend "<li>p - function prototype"
+       legend = legend "<li>x - external and forward variable declaration"
+       legend = legend "</ul></ul>"
+
+       print "<h3>musl vs c99 api</h3>"
+       print commit
+       print legend
+       print "<h4>table</h4><table border=1><tr><th colspan=3>musl<th colspan=4>c99<tr><th>status<th>sym<th>decl<th>name<th>header<th>proto<th>section"
+       nodecl = nosym = missing = 0
+       while (getline < c99 == 1) {
+               s = "<tr><td>"
+               if (sym[$1] && kind[$1]) {
+                       s = s "&#160;"
+               } else if (sym[$1]) {
+                       s = s "nodecl"
+                       nodecl++
+               } else if (kind[$1] ~ /[dtsu]/) {
+                       s = s "&#160;"
+               } else if (kind[$1]) {
+                       s = s "nosym"
+                       nosym++
+               } else {
+                       s = s "missing"
+                       missing++
+               }
+               s = s "<td>" sym[$1]
+               if (!sym[$1])
+                       s = s "&#160;"
+               s = s "<td>" kindstr[$1]
+               if (!kind[$1])
+                       s = s "&#160;"
+
+               s = s "<td>" $1
+               s = s "<td>" $3
+               if ($2)
+                       s = s "<td>" $2
+               else
+                       s = s "<td>&#160;"
+               s = s "<td>" $4
+               print s
+       }
+       print "</table>"
+       print "<h4>stats</h4><ul><li>missing: " missing "<li>nosym: " nosym "<li>nodecl: " nodecl "</ul>"
+}' >tab_c99.html
diff --git a/tab_posix.sh b/tab_posix.sh
new file mode 100755 (executable)
index 0000000..2dd26f7
--- /dev/null
@@ -0,0 +1,102 @@
+#!/bin/sh
+
+export LC_ALL=C
+
+( cd $MUSL; git log -n1 ) | awk '
+BEGIN {
+       getline
+       hash = $2
+       getline
+
+       commit = "<h4>commit</h4><p>commit <a href=\"http://git.etalabs.net/cgi-bin/gitweb.cgi?p=musl;a=commit;h=" hash "\">" hash "</a>"
+       while (getline == 1)
+               commit = commit "<br>" $0
+
+       FS = "\t"
+
+       posix = "data/posix2008"
+       syms = "data/musl.syms"
+       tags = "data/musl.tags"
+
+       while (getline < syms == 1)
+               sym[$2] = $1
+       while (getline < tags == 1) {
+               if ($2 ~ /bits\//)
+                       s = $3 " "
+               else
+                       s = "<a href=\"http://git.etalabs.net/cgi-bin/gitweb.cgi?p=musl;a=blob;f=include/" $2 ";hb=" hash "#l" $4 "\">" $3 "</a> "
+               kind[$1] = kind[$1] $3
+               kindstr[$1] = kindstr[$1] s
+       }
+
+       legend = "<h4>legend</h4><ul><li>status: musl implementation status summary<ul>"
+       legend = legend "<li>(empty) - implemented"
+       legend = legend "<li>nosym - prototype found in include files (see decl) but not in libc.a (see sym)"
+       legend = legend "<li>nodecl - symbol is in libc.a but not declared in a public header"
+       legend = legend "<li>missing - neither in include files (see decl) nor in libc.a (see sym)"
+       legend = legend "</ul><li>sym: external symbol kind as found by `nm libc.a` (symbol kind only reported once)<ul>"
+#      legend = legend "<li>A - symbol value is absolute"
+#      legend = legend "<li>B - symbol is in the uninitialized data section (known as BSS)"
+       legend = legend "<li>C - symbol is common (uninitialized data)"
+       legend = legend "<li>D - symbol is in the initialized data section"
+#      legend = legend "<li>G - symbol is in the initialized data section for small objects"
+#      legend = legend "<li>I - indirect reference to another symbol"
+#      legend = legend "<li>N - debugging symbol"
+       legend = legend "<li>R - symbol is in the read only data section"
+#      legend = legend "<li>S - symbol is in the uninitialized data section for small objects"
+       legend = legend "<li>T - symbol is in the text section"
+#      legend = legend "<li>U - undefined symbol"
+       legend = legend "<li>V - weak object"
+       legend = legend "<li>W - weak symbol"
+       legend = legend "</ul><li>decl: kind of declaration as found by `ctags -R include` (every occurance is reported)<ul>"
+       legend = legend "<li>d - macro definition"
+       legend = legend "<li>p - function prototype"
+       legend = legend "<li>x - external and forward variable declaration"
+       legend = legend "</ul></ul>"
+       legend = legend "<p>(any option mark found in the synopsis of a manual is listed in the option column, this is often wrong)"
+
+       print "<h3>musl vs posix api</h3>"
+       print commit
+       print legend
+       print "<h4>table</h4><table border=1><tr><th colspan=3>musl<th colspan=4>posix<tr><th>status<th>sym<th>decl<th>name<th>header<th>option<th>desc"
+       nodecl = nosym = missing = 0
+       while (getline < posix == 1) {
+               s = "<tr><td>"
+               if (sym[$1] && kind[$1]) {
+                       s = s "&#160;"
+               } else if (sym[$1]) {
+                       s = s "nodecl"
+                       nodecl++
+               } else if (kind[$1] ~ /d/) {
+                       s = s "&#160;"
+               } else if (kind[$1]) {
+                       s = s "nosym"
+                       nosym++
+               } else {
+                       s = s "missing"
+                       missing++
+               }
+               s = s "<td>" sym[$1]
+               if (!sym[$1])
+                       s = s "&#160;"
+               s = s "<td>" kindstr[$1]
+               if (!kind[$1])
+                       s = s "&#160;"
+
+               s = s "<td><a href=\"http://pubs.opengroup.org/onlinepubs/9699919799/functions/" $1 ".html\">" $1 "</a>"
+               n = split($2, x, " ")
+               s = s "<td>"
+               for (i = 1; i <= n; i++)
+                       s = s " <a href=\"http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/" x[i] ".html\">" x[i] "</a>"
+               n = split($3, x, " ")
+               s = s "<td>"
+               for (i = 1; i <= n; i++)
+                       s = s " <a href=\"http://pubs.opengroup.org/onlinepubs/9699919799/help/codes.html#" x[i] "\">" x[i] "</a>"
+               if (n==0)
+                       s = s "&#160;"
+               s = s "<td>" $4
+               print s
+       }
+       print "</table>"
+       print "<h4>stats</h4><ul><li>missing: " missing "<li>nosym: " nosym "<li>nodecl: " nodecl "</ul>"
+}' >tab_posix.html