gdb/contrib/ari/update-web-ari.sh - gdb

Functions defined

Source code

  1. #!/bin/sh -x

  2. # GDB script to create GDB ARI web page.
  3. #
  4. # Copyright (C) 2001-2015 Free Software Foundation, Inc.
  5. #
  6. # This file is part of GDB.
  7. #
  8. # This program is free software; you can redistribute it and/or modify
  9. # it under the terms of the GNU General Public License as published by
  10. # the Free Software Foundation; either version 3 of the License, or
  11. # (at your option) any later version.
  12. #
  13. # This program is distributed in the hope that it will be useful,
  14. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  16. # GNU General Public License for more details.
  17. #
  18. # You should have received a copy of the GNU General Public License
  19. # along with this program.  If not, see <http://www.gnu.org/licenses/>.

  20. # TODO: setjmp.h, setjmp and longjmp.

  21. # Direct stderr into stdout but still hang onto stderr (/dev/fd/3)
  22. exec 3>&2 2>&1
  23. ECHO ()
  24. {
  25. #   echo "$@" | tee /dev/fd/3 1>&2
  26.     echo "$@" 1>&2
  27.     echo "$@" 1>&3
  28. }

  29. # Really mindless usage
  30. if test $# -ne 4
  31. then
  32.     echo "Usage: $0 <snapshot/sourcedir> <tmpdir> <destdir> <project>" 1>&2
  33.     exit 1
  34. fi
  35. snapshot=$1 ; shift
  36. tmpdir=$1 ; shift
  37. wwwdir=$1 ; shift
  38. project=$1 ; shift

  39. # Try to create destination directory if it doesn't exist yet
  40. if [ ! -d ${wwwdir} ]
  41. then
  42.   mkdir -p ${wwwdir}
  43. fi

  44. # Fail if destination directory doesn't exist or is not writable
  45. if [ ! -w ${wwwdir} -o ! -d ${wwwdir} ]
  46. then
  47.   echo ERROR: Can not write to directory ${wwwdir} >&2
  48.   exit 2
  49. fi

  50. if [ ! -r ${snapshot} ]
  51. then
  52.     echo ERROR: Can not read snapshot file 1>&2
  53.     exit 1
  54. fi

  55. # FILE formats
  56. # ari.*.bug: <FILE>:<LINE>: <CATEGORY>: <BUG>: <DOC>
  57. # ari.*.idx: <BUG>:<FILE>:<CATEGORY>
  58. # ari.*.doc: <BUG>:<COUNT>:<CATEGORY>:<DOC>
  59. # Where ``*'' is {source,warning,indent,doschk}

  60. unpack_source_p=true
  61. delete_source_p=true

  62. check_warning_p=false # broken
  63. check_indent_p=false # too slow, too many fail
  64. check_source_p=true
  65. check_doschk_p=true
  66. check_werror_p=true

  67. update_doc_p=true
  68. update_web_p=true

  69. if awk --version 2>&1 </dev/null | grep -i gnu > /dev/null
  70. then
  71.   AWK=awk
  72. else
  73.   AWK=gawk
  74. fi
  75. export AWK

  76. # Set up a few cleanups
  77. if ${delete_source_p}
  78. then
  79.     trap "cd /tmp; rm -rf ${tmpdir}; exit" 0 1 2 15
  80. fi


  81. # If the first parameter is a directory,
  82. #we just use it as the extracted source
  83. if [ -d ${snapshot} ]
  84. then
  85.   module=${project}
  86.   srcdir=${snapshot}
  87.   aridir=${srcdir}/${module}/contrib/ari
  88.   unpack_source_p=false
  89.   delete_source_p=false
  90.   version_in=${srcdir}/${module}/version.in
  91. else
  92.   # unpack the tar-ball
  93.   if ${unpack_source_p}
  94.   then
  95.     # Was it previously unpacked?
  96.     if ${delete_source_p} || test ! -d ${tmpdir}/${module}*
  97.     then
  98.         /bin/rm -rf "${tmpdir}"
  99.         /bin/mkdir -p ${tmpdir}
  100.         if [ ! -d ${tmpdir} ]
  101.         then
  102.             echo "Problem creating work directory"
  103.             exit 1
  104.         fi
  105.         cd ${tmpdir} || exit 1
  106.         echo `date`: Unpacking tar-ball ...
  107.         case ${snapshot} in
  108.             *.tar.bz2 ) bzcat ${snapshot} ;;
  109.             *.tar ) cat ${snapshot} ;;
  110.             * ) ECHO Bad file ${snapshot} ; exit 1 ;;
  111.         esac | tar xf -
  112.     fi
  113.   fi

  114.   module=`basename ${snapshot}`
  115.   module=`basename ${module} .bz2`
  116.   module=`basename ${module} .tar`
  117.   srcdir=`echo ${tmpdir}/${module}*`
  118.   aridir=${HOME}/ss
  119.   version_in=${srcdir}/gdb/version.in
  120. fi

  121. if [ ! -r ${version_in} ]
  122. then
  123.     echo ERROR: missing version file 1>&2
  124.     exit 1
  125. fi

  126. date=`sed -n -e 's/^.* BFD_VERSION_DATE \(.*\)$/\1/p' $srcdir/bfd/version.h`
  127. version=`sed -e "s/DATE/$date/" < ${version_in}`

  128. # THIS HAS SUFFERED BIT ROT
  129. if ${check_warning_p} && test -d "${srcdir}"
  130. then
  131.     echo `date`: Parsing compiler warnings 1>&2
  132.     cat ${root}/ari.compile | $AWK '
  133. BEGIN {
  134.     FS=":";
  135. }
  136. /^[^:]*:[0-9]*: warning:/ {
  137.   file = $1;
  138.   #sub (/^.*\//, "", file);
  139.   warning[file] += 1;
  140. }
  141. /^[^:]*:[0-9]*: error:/ {
  142.   file = $1;
  143.   #sub (/^.*\//, "", file);
  144.   error[file] += 1;
  145. }
  146. END {
  147.   for (file in warning) {
  148.     print file ":warning:" level[file]
  149.   }
  150.   for (file in error) {
  151.     print file ":error:" level[file]
  152.   }
  153. }
  154. ' > ${root}/ari.warning.bug
  155. fi

  156. # THIS HAS SUFFERED BIT ROT
  157. if ${check_indent_p} && test -d "${srcdir}"
  158. then
  159.     printf "Analizing file indentation:" 1>&2
  160.     ( cd "${srcdir}" && /bin/sh ${aridir}/gdb_find.sh ${project} | while read f
  161.     do
  162.         if /bin/sh ${aridir}/gdb_indent.sh < ${f} 2>/dev/null | cmp -s - ${f}
  163.         then
  164.             :
  165.         else
  166.             # ari.*.bug: <FILE>:<LINE>: <CATEGORY>: <BUG>: <DOC>
  167.             echo "${f}:0: info: indent: Indentation does not match GNU indent output"
  168.         fi
  169.     done ) > ${wwwdir}/ari.indent.bug
  170.     echo ""
  171. fi

  172. if ${check_source_p} && test -d "${srcdir}"
  173. then
  174.     bugf=${wwwdir}/ari.source.bug
  175.     oldf=${wwwdir}/ari.source.old
  176.     srcf=${wwwdir}/ari.source.lines
  177.     oldsrcf=${wwwdir}/ari.source.lines-old

  178.     diff=${wwwdir}/ari.source.diff
  179.     diffin=${diff}-in
  180.     newf1=${bugf}1
  181.     oldf1=${oldf}1
  182.     oldpruned=${oldf1}-pruned
  183.     newpruned=${newf1}-pruned

  184.     cp -f ${bugf} ${oldf}
  185.     cp -f ${srcf} ${oldsrcf}
  186.     rm -f ${srcf}
  187.     node=`uname -n`
  188.     echo "`date`: Using source lines ${srcf}" 1>&2
  189.     echo "`date`: Checking source code" 1>&2
  190.     ( cd "${srcdir}" && /bin/sh ${aridir}/gdb_find.sh "${project}" | \
  191.         xargs /bin/sh ${aridir}/gdb_ari.sh -Werror -Wall --print-idx --src=${srcf}
  192.     ) > ${bugf}
  193.     # Remove things we are not interested in to signal by email
  194.     # gdbarch changes are not important here
  195.     # Also convert ` into ' to avoid command substitution in script below
  196.     sed -e "/.*: gdbarch:.*/d" -e "s:\`:':g" ${oldf} > ${oldf1}
  197.     sed -e "/.*: gdbarch:.*/d" -e "s:\`:':g" ${bugf} > ${newf1}
  198.     # Remove line number info so that code inclusion/deletion
  199.     # has no impact on the result
  200.     sed -e "s/\([^:]*\):\([^:]*\):\(.*\)/\1:0:\3/" ${oldf1} > ${oldpruned}
  201.     sed -e "s/\([^:]*\):\([^:]*\):\(.*\)/\1:0:\3/" ${newf1} > ${newpruned}
  202.     # Use diff without option to get normal diff output that
  203.     # is reparsed after
  204.     diff ${oldpruned} ${newpruned} > ${diffin}
  205.     # Only keep new warnings
  206.     sed -n -e "/^>.*/p" ${diffin} > ${diff}
  207.     sedscript=${wwwdir}/sedscript
  208.     script=${wwwdir}/script
  209.     sed -n -e "s|\(^[0-9,]*\)a\(.*\)|echo \1a\2 \n \
  210.         sed -n \'\2s:\\\\(.*\\\\):> \\\\1:p\' ${newf1}|p" \
  211.         -e "s|\(^[0-9,]*\)d\(.*\)|echo \1d\2\n \
  212.         sed -n \'\1s:\\\\(.*\\\\):< \\\\1:p\' ${oldf1}|p" \
  213.         -e "s|\(^[0-9,]*\)c\(.*\)|echo \1c\2\n \
  214.         sed -n \'\1s:\\\\(.*\\\\):< \\\\1:p\' ${oldf1} \n \
  215.         sed -n \"\2s:\\\\(.*\\\\):> \\\\1:p\" ${newf1}|p" \
  216.         ${diffin} > ${sedscript}
  217.     ${SHELL} ${sedscript} > ${wwwdir}/message
  218.     sed -n \
  219.         -e "s;\(.*\);echo \\\"\1\\\";p" \
  220.         -e "s;.*< \([^:]*\):\([0-9]*\):.*;grep \"^\1:\2:\" ${oldsrcf};p" \
  221.         -e "s;.*> \([^:]*\):\([0-9]*\):.*;grep \"^\1:\2:\" ${srcf};p" \
  222.         ${wwwdir}/message > ${script}
  223.     ${SHELL} ${script} > ${wwwdir}/mail-message
  224.     if [ "x${branch}" != "x" ]; then
  225.         email_suffix="`date` in ${branch}"
  226.     else
  227.         email_suffix="`date`"
  228.     fi

  229. fi




  230. if ${check_doschk_p} && test -d "${srcdir}"
  231. then
  232.     echo "`date`: Checking for doschk" 1>&2
  233.     rm -f "${wwwdir}"/ari.doschk.*
  234.     fnchange_lst="${srcdir}"/gdb/config/djgpp/fnchange.lst
  235.     fnchange_awk="${wwwdir}"/ari.doschk.awk
  236.     doschk_in="${wwwdir}"/ari.doschk.in
  237.     doschk_out="${wwwdir}"/ari.doschk.out
  238.     doschk_bug="${wwwdir}"/ari.doschk.bug
  239.     doschk_char="${wwwdir}"/ari.doschk.char

  240.     # Transform fnchange.lst into fnchange.awk.  The program DJTAR
  241.     # does a textual substitution of each file name using the list.
  242.     # Generate an awk script that does the equivalent - matches an
  243.     # exact line and then outputs the replacement.

  244.     sed -e 's;@[^@]*@[/]*\([^ ]*\) @[^@]*@[/]*\([^ ]*\);\$0 == "\1" { print "\2"\; next\; };' \
  245.         < "${fnchange_lst}" > "${fnchange_awk}"
  246.     echo '{ print }' >> "${fnchange_awk}"

  247.     # Do the raw analysis - transform the list of files into the DJGPP
  248.     # equivalents putting it in the .in file
  249.     ( cd "${srcdir}" && find * \
  250.         -name '*.info-[0-9]*' -prune \
  251.         -o -name tcl -prune \
  252.         -o -name itcl -prune \
  253.         -o -name tk -prune \
  254.         -o -name libgui -prune \
  255.         -o -name tix -prune \
  256.         -o -name dejagnu -prune \
  257.         -o -name expect -prune \
  258.         -o -type f -print ) \
  259.     | $AWK -f ${fnchange_awk} > ${doschk_in}

  260.     # Start with a clean slate
  261.     rm -f ${doschk_bug}

  262.     # Check for any invalid characters.
  263.     grep '[\+\,\;\=\[\]\|\<\>\\\"\:\?\*]' < ${doschk_in} > ${doschk_char}
  264.     # ari.*.bug: <FILE>:<LINE>: <CATEGORY>: <BUG>: <DOC>
  265.     sed < ${doschk_char} >> ${doschk_bug} \
  266.         -e s'/$/:0: dos: DOSCHK: Invalid DOS character/'

  267.     # Magic to map ari.doschk.out to ari.doschk.bug goes here
  268.     doschk < ${doschk_in} > ${doschk_out}
  269.     cat ${doschk_out} | $AWK >> ${doschk_bug} '
  270. BEGIN {
  271.     state = 1;
  272.     invalid_dos = state++; bug[invalid_dos] = "invalid DOS file name";  category[invalid_dos] = "dos";
  273.     same_dos = state++;    bug[same_dos]    = "DOS 8.3";                category[same_dos] = "dos";
  274.     same_sysv = state++;   bug[same_sysv]   = "SysV";
  275.     long_sysv = state++;   bug[long_sysv]   = "long SysV";
  276.     internal = state++;    bug[internal]    = "internal doschk";        category[internal] = "internal";
  277.     state = 0;
  278. }
  279. /^$/ { state = 0; next; }
  280. /^The .* not valid DOS/     { state = invalid_dos; next; }
  281. /^The .* same DOS/          { state = same_dos; next; }
  282. /^The .* same SysV/         { state = same_sysv; next; }
  283. /^The .* too long for SysV/ { state = long_sysv; next; }
  284. /^The .* /                  { state = internal; next; }

  285. NF == 0 { next }

  286. NF == 3 { name = $1 ; file = $3 }
  287. NF == 1 { file = $1 }
  288. NF > 3 && $2 == "-" { file = $1 ; name = gensub(/^.* - /, "", 1) }

  289. state == same_dos {
  290.     # ari.*.bug: <FILE>:<LINE>: <CATEGORY>: <BUG>: <DOC>
  291.     print  file ":0: " category[state] ": " \
  292.         name " " bug[state] " " " dup: " \
  293.         " DOSCHK - the names " name " and " file " resolve to the same" \
  294.         " file on a " bug[state] \
  295.         " system.<br>For DOS, this can be fixed by modifying the file" \
  296.         " fnchange.lst."
  297.     next
  298. }
  299. state == invalid_dos {
  300.     # ari.*.bug: <FILE>:<LINE>: <SEVERITY>: <CATEGORY>: <DOC>
  301.     print file ":0: " category[state] ": "  name ": DOSCHK - " name
  302.     next
  303. }
  304. state == internal {
  305.     # ari.*.bug: <FILE>:<LINE>: <SEVERITY>: <CATEGORY>: <DOC>
  306.     print file ":0: " category[state] ": "  bug[state] ": DOSCHK - a " \
  307.         bug[state] " problem"
  308. }
  309. '
  310. fi



  311. if ${check_werror_p} && test -d "${srcdir}"
  312. then
  313.     echo "`date`: Checking Makefile.in for non- -Werror rules"
  314.     rm -f ${wwwdir}/ari.werror.*
  315.     cat "${srcdir}/${project}/Makefile.in" | $AWK > ${wwwdir}/ari.werror.bug '
  316. BEGIN {
  317.     count = 0
  318.     cont_p = 0
  319.     full_line = ""
  320. }
  321. /^[-_[:alnum:]]+\.o:/ {
  322.     file = gensub(/.o:.*/, "", 1) ".c"
  323. }

  324. /[^\\]\\$/ { gsub (/\\$/, ""); full_line = full_line $0; cont_p = 1; next; }
  325. cont_p { $0 = full_line $0; cont_p = 0; full_line = ""; }

  326. /\$\(COMPILE\.pre\)/ {
  327.     print file " has  line " $0
  328.     if (($0 !~ /\$\(.*ERROR_CFLAGS\)/) && ($0 !~ /\$\(INTERNAL_CFLAGS\)/)) {
  329.         # ari.*.bug: <FILE>:<LINE>: <CATEGORY>: <BUG>: <DOC>
  330.         print "'"${project}"'/" file ":0: info: Werror: The file is not being compiled with -Werror"
  331.     }
  332. }
  333. '
  334. fi


  335. # From the warnings, generate the doc and indexed bug files
  336. if ${update_doc_p}
  337. then
  338.     cd ${wwwdir}
  339.     rm -f ari.doc ari.idx ari.doc.bug
  340.     # Generate an extra file containing all the bugs that the ARI can detect.
  341.     /bin/sh ${aridir}/gdb_ari.sh -Werror -Wall --print-idx --print-doc >> ari.doc.bug
  342.     cat ari.*.bug | $AWK > ari.idx '
  343. BEGIN {
  344.     FS=": *"
  345. }
  346. {
  347.     # ari.*.bug: <FILE>:<LINE>: <CATEGORY>: <BUG>: <DOC>
  348.     file = $1
  349.     line = $2
  350.     category = $3
  351.     bug = $4
  352.     if (! (bug in cat)) {
  353.         cat[bug] = category
  354.         # strip any trailing .... (supplement)
  355.         doc[bug] = gensub(/ \([^\)]*\)$/, "", 1, $5)
  356.         count[bug] = 0
  357.     }
  358.     if (file != "") {
  359.         count[bug] += 1
  360.         # ari.*.idx: <BUG>:<FILE>:<CATEGORY>
  361.         print bug ":" file ":" category
  362.     }
  363.     # Also accumulate some categories as obsolete
  364.     if (category == "deprecated") {
  365.         # ari.*.idx: <BUG>:<FILE>:<CATEGORY>
  366.         if (file != "") {
  367.             print category ":" file ":" "obsolete"
  368.         }
  369.         #count[category]++
  370.         #doc[category] = "Contains " category " code"
  371.     }
  372. }
  373. END {
  374.     i = 0;
  375.     for (bug in count) {
  376.         # ari.*.doc: <BUG>:<COUNT>:<CATEGORY>:<DOC>
  377.         print bug ":" count[bug] ":" cat[bug] ":" doc[bug] >> "ari.doc"
  378.     }
  379. }
  380. '
  381. fi


  382. # print_toc BIAS MIN_COUNT CATEGORIES TITLE

  383. # Print a table of contents containing the bugs CATEGORIES.  If the
  384. # BUG count >= MIN_COUNT print it in the table-of-contents.  If
  385. # MIN_COUNT is non -ve, also include a link to the table.Adjust the
  386. # printed BUG count by BIAS.

  387. all=

  388. print_toc ()
  389. {
  390.     bias="$1" ; shift
  391.     min_count="$1" ; shift

  392.     all=" $all $1 "
  393.     categories=""
  394.     for c in $1; do
  395.         categories="${categories} categories[\"${c}\"] = 1 ;"
  396.     done
  397.     shift

  398.     title="$@" ; shift

  399.     echo "<p>" >> ${newari}
  400.     echo "<a name=${title}>" | tr '[A-Z]' '[a-z]' >> ${newari}
  401.     echo "<h3>${title}</h3>" >> ${newari}
  402.     cat >> ${newari} # description

  403.     cat >> ${newari} <<EOF
  404. <p>
  405. <table>
  406. <tr><th align=left>BUG</th><th>Total</th><th align=left>Description</th></tr>
  407. EOF
  408.     # ari.*.doc: <BUG>:<COUNT>:<CATEGORY>:<DOC>
  409.     cat ${wwwdir}/ari.doc \
  410.     | sort -t: +1rn -2 +0d \
  411.     | $AWK >> ${newari} '
  412. BEGIN {
  413.     FS=":"
  414.     '"$categories"'
  415.     MIN_COUNT = '${min_count}'
  416.     BIAS = '${bias}'
  417.     total = 0
  418.     nr = 0
  419. }
  420. {
  421.     # ari.*.doc: <BUG>:<COUNT>:<CATEGORY>:<DOC>
  422.     bug = $1
  423.     count = $2
  424.     category = $3
  425.     doc = $4
  426.     if (count < MIN_COUNT) next
  427.     if (!(category in categories)) next
  428.     nr += 1
  429.     total += count
  430.     printf "<tr>"
  431.     printf "<th align=left valign=top><a name=\"%s\">", bug
  432.     printf "%s", gensub(/_/, " ", "g", bug)
  433.     printf "</a></th>"
  434.     printf "<td align=right valign=top>"
  435.     if (count > 0 && MIN_COUNT >= 0) {
  436.         printf "<a href=\"#,%s\">%d</a></td>", bug, count + BIAS
  437.     } else {
  438.         printf "%d", count + BIAS
  439.     }
  440.     printf "</td>"
  441.     printf "<td align=left valign=top>%s</td>", doc
  442.     printf "</tr>"
  443.     print ""
  444. }
  445. END {
  446.     print "<tr><th align=right valign=top>" nr "</th><th align=right valign=top>" total "</th><td></td></tr>"
  447. }
  448. '
  449. cat >> ${newari} <<EOF
  450. </table>
  451. <p>
  452. EOF
  453. }


  454. print_table ()
  455. {
  456.     categories=""
  457.     for c in $1; do
  458.         categories="${categories} categories[\"${c}\"] = 1 ;"
  459.     done
  460.     # Remember to prune the dir prefix from projects files
  461.     # ari.*.idx: <BUG>:<FILE>:<CATEGORY>
  462.     cat ${wwwdir}/ari.idx | $AWK >> ${newari} '
  463. function qsort (table,
  464.                 middle, tmp, left, nr_left, right, nr_right, result) {
  465.     middle = ""
  466.     for (middle in table) { break; }
  467.     nr_left = 0;
  468.     nr_right = 0;
  469.     for (tmp in table) {
  470.         if (tolower(tmp) < tolower(middle)) {
  471.             nr_left++
  472.             left[tmp] = tmp
  473.         } else if (tolower(tmp) > tolower(middle)) {
  474.             nr_right++
  475.             right[tmp] = tmp
  476.         }
  477.     }
  478.     #print "qsort " nr_left " " middle " " nr_right > "/dev/stderr"
  479.     result = ""
  480.     if (nr_left > 0) {
  481.         result = qsort(left) SUBSEP
  482.     }
  483.     result = result middle
  484.     if (nr_right > 0) {
  485.         result = result SUBSEP qsort(right)
  486.     }
  487.     return result
  488. }
  489. function print_heading (nb_file, where, bug_i) {
  490.     print ""
  491.     print "<tr border=1>"
  492.     print "<th align=left>File " nb_file "</th>"
  493.     print "<th align=left><em>Total</em></th>"
  494.     print "<th></th>"
  495.     for (bug_i = 1; bug_i <= nr_bug; bug_i++) {
  496.         bug = i2bug[bug_i];
  497.         printf "<th>"
  498.         # The title names are offset by one.  Otherwize, when the browser
  499.         # jumps to the name it leaves out half the relevant column.
  500.         #printf "<a name=\",%s\">&nbsp;</a>", bug
  501.         printf "<a name=\",%s\">&nbsp;</a>", i2bug[bug_i-1]
  502.         printf "<a href=\"#%s\">", bug
  503.         printf "%s", gensub(/_/, " ", "g", bug)
  504.         printf "</a>\n"
  505.         printf "</th>\n"
  506.     }
  507.     #print "<th></th>"
  508.     printf "<th><a name=\"%s,\">&nbsp;</a></th>\n", i2bug[bug_i-1]
  509.     print "<th align=left><em>Total</em></th>"
  510.     print "<th align=left>File " nb_file "</th>"
  511.     print "</tr>"
  512. }
  513. function print_totals (where, bug_i) {
  514.     print "<th align=left><em>Totals</em></th>"
  515.     printf "<th align=right>"
  516.     printf "<em>%s</em>", total
  517.     printf "&gt;"
  518.     printf "</th>\n"
  519.     print "<th></th>";
  520.     for (bug_i = 1; bug_i <= nr_bug; bug_i++) {
  521.         bug = i2bug[bug_i];
  522.         printf "<th align=right>"
  523.         printf "<em>"
  524.         printf "<a href=\"#%s\">%d</a>", bug, bug_total[bug]
  525.         printf "</em>";
  526.         printf "<a href=\"#%s,%s\">^</a>", prev_file[bug, where], bug
  527.         printf "<a href=\"#%s,%s\">v</a>", next_file[bug, where], bug
  528.         printf "<a name=\"%s,%s\">&nbsp;</a>", where, bug
  529.         printf "</th>";
  530.         print ""
  531.     }
  532.     print "<th></th>"
  533.     printf "<th align=right>"
  534.     printf "<em>%s</em>", total
  535.     printf "&lt;"
  536.     printf "</th>\n"
  537.     print "<th align=left><em>Totals</em></th>"
  538.     print "</tr>"
  539. }
  540. BEGIN {
  541.     FS = ":"
  542.     '"${categories}"'
  543.     nr_file = 0;
  544.     nr_bug = 0;
  545. }
  546. {
  547.     # ari.*.idx: <BUG>:<FILE>:<CATEGORY>
  548.     bug = $1
  549.     file = $2
  550.     category = $3
  551.     # Interested in this
  552.     if (!(category in categories)) next
  553.     # Totals
  554.     db[bug, file] += 1
  555.     bug_total[bug] += 1
  556.     file_total[file] += 1
  557.     total += 1
  558. }
  559. END {

  560.     # Sort the files and bugs creating indexed lists.
  561.     nr_bug = split(qsort(bug_total), i2bug, SUBSEP);
  562.     nr_file = split(qsort(file_total), i2file, SUBSEP);

  563.     # Dummy entries for first/last
  564.     i2file[0] = 0
  565.     i2file[-1] = -1
  566.     i2bug[0] = 0
  567.     i2bug[-1] = -1

  568.     # Construct a cycle of next/prev links.  The file/bug "0" and "-1"
  569.     # are used to identify the start/end of the cycle.  Consequently,
  570.     # prev(0) = -1 (prev of start is the end) and next(-1) = 0 (next
  571.     # of end is the start).

  572.     # For all the bugs, create a cycle that goes to the prev / next file.
  573.     for (bug_i = 1; bug_i <= nr_bug; bug_i++) {
  574.         bug = i2bug[bug_i]
  575.         prev = 0
  576.         prev_file[bug, 0] = -1
  577.         next_file[bug, -1] = 0
  578.         for (file_i = 1; file_i <= nr_file; file_i++) {
  579.             file = i2file[file_i]
  580.             if ((bug, file) in db) {
  581.                 prev_file[bug, file] = prev
  582.                 next_file[bug, prev] = file
  583.                 prev = file
  584.             }
  585.         }
  586.         prev_file[bug, -1] = prev
  587.         next_file[bug, prev] = -1
  588.     }

  589.     # For all the files, create a cycle that goes to the prev / next bug.
  590.     for (file_i = 1; file_i <= nr_file; file_i++) {
  591.         file = i2file[file_i]
  592.         prev = 0
  593.         prev_bug[file, 0] = -1
  594.         next_bug[file, -1] = 0
  595.         for (bug_i = 1; bug_i <= nr_bug; bug_i++) {
  596.             bug = i2bug[bug_i]
  597.             if ((bug, file) in db) {
  598.                 prev_bug[file, bug] = prev
  599.                 next_bug[file, prev] = bug
  600.                 prev = bug
  601.             }
  602.         }
  603.         prev_bug[file, -1] = prev
  604.         next_bug[file, prev] = -1
  605.     }

  606.     print "<table border=1 cellspacing=0>"
  607.     print "<tr></tr>"
  608.     print_heading(nr_file, 0);
  609.     print "<tr></tr>"
  610.     print_totals(0);
  611.     print "<tr></tr>"

  612.     for (file_i = 1; file_i <= nr_file; file_i++) {
  613.         file = i2file[file_i];
  614.         pfile = gensub(/^'${project}'\//, "", 1, file)
  615.         print ""
  616.         print "<tr>"
  617.         print "<th align=left><a name=\"" file ",\">" pfile "</a></th>"
  618.         printf "<th align=right>"
  619.         printf "%s", file_total[file]
  620.         printf "<a href=\"#%s,%s\">&gt;</a>", file, next_bug[file, 0]
  621.         printf "</th>\n"
  622.         print "<th></th>"
  623.         for (bug_i = 1; bug_i <= nr_bug; bug_i++) {
  624.             bug = i2bug[bug_i];
  625.             if ((bug, file) in db) {
  626.                 printf "<td align=right>"
  627.                 printf "<a href=\"#%s\">%d</a>", bug, db[bug, file]
  628.                 printf "<a href=\"#%s,%s\">^</a>", prev_file[bug, file], bug
  629.                 printf "<a href=\"#%s,%s\">v</a>", next_file[bug, file], bug
  630.                 printf "<a name=\"%s,%s\">&nbsp;</a>", file, bug
  631.                 printf "</td>"
  632.                 print ""
  633.             } else {
  634.                 print "<td>&nbsp;</td>"
  635.                 #print "<td></td>"
  636.             }
  637.         }
  638.         print "<th></th>"
  639.         printf "<th align=right>"
  640.         printf "%s", file_total[file]
  641.         printf "<a href=\"#%s,%s\">&lt;</a>", file, prev_bug[file, -1]
  642.         printf "</th>\n"
  643.         print "<th align=left>" pfile "</th>"
  644.         print "</tr>"
  645.     }

  646.     print "<tr></tr>"
  647.     print_totals(-1)
  648.     print "<tr></tr>"
  649.     print_heading(nr_file, -1);
  650.     print "<tr></tr>"
  651.     print ""
  652.     print "</table>"
  653.     print ""
  654. }
  655. '
  656. }


  657. # Make the scripts available
  658. cp ${aridir}/gdb_*.sh ${wwwdir}

  659. nb_files=`cd "${srcdir}" && /bin/sh ${aridir}/gdb_find.sh "${project}" | wc -l`

  660. echo "Total number of tested files is $nb_files"

  661. if [ "x$debug_awk" = "x" ]
  662. then
  663.   debug_awk=0
  664. fi

  665. # Compute the ARI index - ratio of zero vs non-zero problems.
  666. indexes=`${AWK} -v debug=${debug_awk} -v nr="$nb_files" '
  667. BEGIN {
  668.     FS=":"
  669. }
  670. {
  671.     # ari.*.doc: <BUG>:<COUNT>:<CATEGORY>:<DOC>
  672.     bug = $1; count = $2; category = $3; doc = $4

  673.     # legacy type error have at least one entry,
  674.     #corresponding to the declaration.
  675.     if (bug ~ /^legacy /) legacy++
  676.     # Idem for deprecated_XXX symbols/functions.
  677.     if (bug ~ /^deprecated /) deprecated++

  678.     if (category !~ /^gdbarch$/) {
  679.         bugs += count
  680.         nrtests += 1
  681.     }
  682.     if (count == 0) {
  683.         oks++
  684.     }
  685. }
  686. END {
  687.     if (debug == 1) {
  688.       print "nb files: " nr
  689.       print "tests/oks: " nrtests "/" oks
  690.       print "bugs/tests: " bugs "/" nrtests
  691.       print "bugs/oks: " bugs "/" oks
  692.       print bugs "/ (" oks "+" legacy "+" deprecated ")"
  693.     }
  694.     # This value should be as low as possible
  695.     print bugs / ( oks + legacy + deprecated )
  696. }
  697. ' ${wwwdir}/ari.doc`

  698. # Merge, generating the ARI tables.
  699. if ${update_web_p}
  700. then
  701.     echo "Create the ARI table" 1>&2
  702.     oldari=${wwwdir}/old.html
  703.     ari=${wwwdir}/index.html
  704.     newari=${wwwdir}/new.html
  705.     rm -f ${newari} ${newari}.gz
  706.     cat <<EOF >> ${newari}
  707. <html>
  708. <head>
  709. <title>A.R. Index for GDB version ${version}</title>
  710. </head>
  711. <body>

  712. <center><h2>A.R. Index for GDB version ${version}<h2></center>

  713. <!-- body, update above using ../index.sh -->

  714. <!-- Navigation.  This page contains the following anchors.
  715. "BUG": The definition of the bug.
  716. "FILE,BUG": The row/column containing FILEs BUG count
  717. "0,BUG", "-1,BUG": The top/bottom total for BUGs column.
  718. "FILE,O", "FILE,-1": The left/right total for FILEs row.
  719. ",BUG": The top title for BUGs column.
  720. "FILE,": The left title for FILEs row.
  721. -->

  722. <center><h3>${indexes}</h3></center>
  723. <center><h3>You can not take this seriously!</h3></center>

  724. <center>
  725. Also available:
  726. <a href="../gdb/ari/">most recent branch</a>
  727. |
  728. <a href="../gdb/current/ari/">current</a>
  729. |
  730. <a href="../gdb/download/ari/">last release</a>
  731. </center>

  732. <center>
  733. Last updated: `date -u`
  734. </center>
  735. EOF

  736.     print_toc 0 1 "internal regression" Critical <<EOF
  737. Things previously eliminated but returned.  This should always be empty.
  738. EOF

  739.     print_table "regression code comment obsolete gettext"

  740.     print_toc 0 0 code Code <<EOF
  741. Coding standard problems, portability problems, readability problems.
  742. EOF

  743.     print_toc 0 0 comment Comments <<EOF
  744. Problems concerning comments in source files.
  745. EOF

  746.     print_toc 0 0 gettext GetText <<EOF
  747. Gettext related problems.
  748. EOF

  749.     print_toc 0 -1 dos DOS 8.3 File Names <<EOF
  750. File names with problems on 8.3 file systems.
  751. EOF

  752.     print_toc -2 -1 deprecated Deprecated <<EOF
  753. Mechanisms that have been replaced with something better, simpler,
  754. cleaner; or are no longer required by core-GDB.  New code should not
  755. use deprecated mechanisms.  Existing code, when touched, should be
  756. updated to use non-deprecated mechanisms.  See obsolete and deprecate.
  757. (The declaration and definition are hopefully excluded from count so
  758. zero should indicate no remaining uses).
  759. EOF

  760.     print_toc 0 0 obsolete Obsolete <<EOF
  761. Mechanisms that have been replaced, but have not yet been marked as
  762. such (using the deprecated_ prefix).  See deprecate and deprecated.
  763. EOF

  764.     print_toc 0 -1 deprecate Deprecate <<EOF
  765. Mechanisms that are a candidate for being made obsolete.  Once core
  766. GDB no longer depends on these mechanisms and/or there is a
  767. replacement available, these mechanims can be deprecated (adding the
  768. deprecated prefix) obsoleted (put into category obsolete) or deleted.
  769. See obsolete and deprecated.
  770. EOF

  771.     print_toc -2 -1 legacy Legacy <<EOF
  772. Methods used to prop up targets using targets that still depend on
  773. deprecated mechanisms. (The method's declaration and definition are
  774. hopefully excluded from count).
  775. EOF

  776.     print_toc -2 -1 gdbarch Gdbarch <<EOF
  777. Count of calls to the gdbarch set methods.  (Declaration and
  778. definition hopefully excluded from count).
  779. EOF

  780.     print_toc 0 -1 macro Macro <<EOF
  781. Breakdown of macro definitions (and #undef) in configuration files.
  782. EOF

  783.     print_toc 0 0 regression Fixed <<EOF
  784. Problems that have been expunged from the source code.
  785. EOF

  786.     # Check for invalid categories
  787.     for a in $all; do
  788.         alls="$alls all[$a] = 1 ;"
  789.     done
  790.     cat ari.*.doc | $AWK >> ${newari} '
  791. BEGIN {
  792.     FS = ":"
  793.     '"$alls"'
  794. }
  795. {
  796.     # ari.*.doc: <BUG>:<COUNT>:<CATEGORY>:<DOC>
  797.     bug = $1
  798.     count = $2
  799.     category = $3
  800.     doc = $4
  801.     if (!(category in all)) {
  802.         print "<b>" category "</b>: no documentation<br>"
  803.     }
  804. }
  805. '

  806.     cat >> ${newari} <<EOF
  807. <center>
  808. Input files:
  809. `( cd ${wwwdir} && ls ari.*.bug ari.idx ari.doc ) | while read f
  810. do
  811.     echo "<a href=\"${f}\">${f}</a>"
  812. done`
  813. </center>

  814. <center>
  815. Scripts:
  816. `( cd ${wwwdir} && ls *.sh ) | while read f
  817. do
  818.     echo "<a href=\"${f}\">${f}</a>"
  819. done`
  820. </center>

  821. <!-- /body, update below using ../index.sh -->
  822. </body>
  823. </html>
  824. EOF

  825.     for i in . .. ../..; do
  826.         x=${wwwdir}/${i}/index.sh
  827.         if test -x $x; then
  828.             $x ${newari}
  829.             break
  830.         fi
  831.     done

  832.     gzip -c -v -9 ${newari} > ${newari}.gz

  833.     cp ${ari} ${oldari}
  834.     cp ${ari}.gz ${oldari}.gz
  835.     cp ${newari} ${ari}
  836.     cp ${newari}.gz ${ari}.gz

  837. fi # update_web_p

  838. # ls -l ${wwwdir}

  839. exit 0