Commit | Line | Data |
---|---|---|
b786c521 PM |
1 | #!/bin/sh -x |
2 | ||
3 | # GDB script to create GDB ARI web page. | |
4 | # | |
e2882c85 | 5 | # Copyright (C) 2001-2018 Free Software Foundation, Inc. |
b786c521 PM |
6 | # |
7 | # This file is part of GDB. | |
8 | # | |
9 | # This program is free software; you can redistribute it and/or modify | |
10 | # it under the terms of the GNU General Public License as published by | |
11 | # the Free Software Foundation; either version 3 of the License, or | |
12 | # (at your option) any later version. | |
13 | # | |
14 | # This program is distributed in the hope that it will be useful, | |
15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 | # GNU General Public License for more details. | |
18 | # | |
19 | # You should have received a copy of the GNU General Public License | |
20 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | |
21 | ||
22 | # TODO: setjmp.h, setjmp and longjmp. | |
23 | ||
24 | # Direct stderr into stdout but still hang onto stderr (/dev/fd/3) | |
25 | exec 3>&2 2>&1 | |
26 | ECHO () | |
27 | { | |
28 | # echo "$@" | tee /dev/fd/3 1>&2 | |
29 | echo "$@" 1>&2 | |
30 | echo "$@" 1>&3 | |
31 | } | |
32 | ||
33 | # Really mindless usage | |
34 | if test $# -ne 4 | |
35 | then | |
36 | echo "Usage: $0 <snapshot/sourcedir> <tmpdir> <destdir> <project>" 1>&2 | |
37 | exit 1 | |
38 | fi | |
39 | snapshot=$1 ; shift | |
40 | tmpdir=$1 ; shift | |
41 | wwwdir=$1 ; shift | |
42 | project=$1 ; shift | |
43 | ||
44 | # Try to create destination directory if it doesn't exist yet | |
45 | if [ ! -d ${wwwdir} ] | |
46 | then | |
47 | mkdir -p ${wwwdir} | |
48 | fi | |
49 | ||
50 | # Fail if destination directory doesn't exist or is not writable | |
51 | if [ ! -w ${wwwdir} -o ! -d ${wwwdir} ] | |
52 | then | |
53 | echo ERROR: Can not write to directory ${wwwdir} >&2 | |
54 | exit 2 | |
55 | fi | |
56 | ||
57 | if [ ! -r ${snapshot} ] | |
58 | then | |
59 | echo ERROR: Can not read snapshot file 1>&2 | |
60 | exit 1 | |
61 | fi | |
62 | ||
63 | # FILE formats | |
64 | # ari.*.bug: <FILE>:<LINE>: <CATEGORY>: <BUG>: <DOC> | |
65 | # ari.*.idx: <BUG>:<FILE>:<CATEGORY> | |
66 | # ari.*.doc: <BUG>:<COUNT>:<CATEGORY>:<DOC> | |
67 | # Where ``*'' is {source,warning,indent,doschk} | |
68 | ||
69 | unpack_source_p=true | |
70 | delete_source_p=true | |
71 | ||
72 | check_warning_p=false # broken | |
73 | check_indent_p=false # too slow, too many fail | |
74 | check_source_p=true | |
75 | check_doschk_p=true | |
76 | check_werror_p=true | |
77 | ||
78 | update_doc_p=true | |
79 | update_web_p=true | |
80 | ||
81 | if awk --version 2>&1 </dev/null | grep -i gnu > /dev/null | |
82 | then | |
83 | AWK=awk | |
84 | else | |
85 | AWK=gawk | |
86 | fi | |
87 | export AWK | |
88 | ||
89 | # Set up a few cleanups | |
90 | if ${delete_source_p} | |
91 | then | |
92 | trap "cd /tmp; rm -rf ${tmpdir}; exit" 0 1 2 15 | |
93 | fi | |
94 | ||
95 | ||
96 | # If the first parameter is a directory, | |
97 | #we just use it as the extracted source | |
98 | if [ -d ${snapshot} ] | |
99 | then | |
100 | module=${project} | |
101 | srcdir=${snapshot} | |
102 | aridir=${srcdir}/${module}/contrib/ari | |
103 | unpack_source_p=false | |
104 | delete_source_p=false | |
105 | version_in=${srcdir}/${module}/version.in | |
106 | else | |
107 | # unpack the tar-ball | |
108 | if ${unpack_source_p} | |
109 | then | |
110 | # Was it previously unpacked? | |
111 | if ${delete_source_p} || test ! -d ${tmpdir}/${module}* | |
112 | then | |
113 | /bin/rm -rf "${tmpdir}" | |
114 | /bin/mkdir -p ${tmpdir} | |
115 | if [ ! -d ${tmpdir} ] | |
116 | then | |
117 | echo "Problem creating work directory" | |
118 | exit 1 | |
119 | fi | |
120 | cd ${tmpdir} || exit 1 | |
121 | echo `date`: Unpacking tar-ball ... | |
122 | case ${snapshot} in | |
123 | *.tar.bz2 ) bzcat ${snapshot} ;; | |
124 | *.tar ) cat ${snapshot} ;; | |
125 | * ) ECHO Bad file ${snapshot} ; exit 1 ;; | |
126 | esac | tar xf - | |
127 | fi | |
128 | fi | |
129 | ||
130 | module=`basename ${snapshot}` | |
131 | module=`basename ${module} .bz2` | |
132 | module=`basename ${module} .tar` | |
133 | srcdir=`echo ${tmpdir}/${module}*` | |
134 | aridir=${HOME}/ss | |
135 | version_in=${srcdir}/gdb/version.in | |
136 | fi | |
137 | ||
138 | if [ ! -r ${version_in} ] | |
139 | then | |
140 | echo ERROR: missing version file 1>&2 | |
141 | exit 1 | |
142 | fi | |
b786c521 | 143 | |
ac6dd50f TT |
144 | date=`sed -n -e 's/^.* BFD_VERSION_DATE \(.*\)$/\1/p' $srcdir/bfd/version.h` |
145 | version=`sed -e "s/DATE/$date/" < ${version_in}` | |
b786c521 PM |
146 | |
147 | # THIS HAS SUFFERED BIT ROT | |
148 | if ${check_warning_p} && test -d "${srcdir}" | |
149 | then | |
150 | echo `date`: Parsing compiler warnings 1>&2 | |
151 | cat ${root}/ari.compile | $AWK ' | |
152 | BEGIN { | |
153 | FS=":"; | |
154 | } | |
155 | /^[^:]*:[0-9]*: warning:/ { | |
156 | file = $1; | |
157 | #sub (/^.*\//, "", file); | |
158 | warning[file] += 1; | |
159 | } | |
160 | /^[^:]*:[0-9]*: error:/ { | |
161 | file = $1; | |
162 | #sub (/^.*\//, "", file); | |
163 | error[file] += 1; | |
164 | } | |
165 | END { | |
166 | for (file in warning) { | |
167 | print file ":warning:" level[file] | |
168 | } | |
169 | for (file in error) { | |
170 | print file ":error:" level[file] | |
171 | } | |
172 | } | |
173 | ' > ${root}/ari.warning.bug | |
174 | fi | |
175 | ||
176 | # THIS HAS SUFFERED BIT ROT | |
177 | if ${check_indent_p} && test -d "${srcdir}" | |
178 | then | |
179 | printf "Analizing file indentation:" 1>&2 | |
180 | ( cd "${srcdir}" && /bin/sh ${aridir}/gdb_find.sh ${project} | while read f | |
181 | do | |
182 | if /bin/sh ${aridir}/gdb_indent.sh < ${f} 2>/dev/null | cmp -s - ${f} | |
183 | then | |
184 | : | |
185 | else | |
186 | # ari.*.bug: <FILE>:<LINE>: <CATEGORY>: <BUG>: <DOC> | |
187 | echo "${f}:0: info: indent: Indentation does not match GNU indent output" | |
188 | fi | |
189 | done ) > ${wwwdir}/ari.indent.bug | |
190 | echo "" | |
191 | fi | |
192 | ||
193 | if ${check_source_p} && test -d "${srcdir}" | |
194 | then | |
195 | bugf=${wwwdir}/ari.source.bug | |
196 | oldf=${wwwdir}/ari.source.old | |
197 | srcf=${wwwdir}/ari.source.lines | |
198 | oldsrcf=${wwwdir}/ari.source.lines-old | |
199 | ||
200 | diff=${wwwdir}/ari.source.diff | |
201 | diffin=${diff}-in | |
202 | newf1=${bugf}1 | |
203 | oldf1=${oldf}1 | |
204 | oldpruned=${oldf1}-pruned | |
205 | newpruned=${newf1}-pruned | |
206 | ||
207 | cp -f ${bugf} ${oldf} | |
208 | cp -f ${srcf} ${oldsrcf} | |
209 | rm -f ${srcf} | |
210 | node=`uname -n` | |
211 | echo "`date`: Using source lines ${srcf}" 1>&2 | |
212 | echo "`date`: Checking source code" 1>&2 | |
213 | ( cd "${srcdir}" && /bin/sh ${aridir}/gdb_find.sh "${project}" | \ | |
214 | xargs /bin/sh ${aridir}/gdb_ari.sh -Werror -Wall --print-idx --src=${srcf} | |
215 | ) > ${bugf} | |
216 | # Remove things we are not interested in to signal by email | |
217 | # gdbarch changes are not important here | |
218 | # Also convert ` into ' to avoid command substitution in script below | |
219 | sed -e "/.*: gdbarch:.*/d" -e "s:\`:':g" ${oldf} > ${oldf1} | |
220 | sed -e "/.*: gdbarch:.*/d" -e "s:\`:':g" ${bugf} > ${newf1} | |
221 | # Remove line number info so that code inclusion/deletion | |
222 | # has no impact on the result | |
223 | sed -e "s/\([^:]*\):\([^:]*\):\(.*\)/\1:0:\3/" ${oldf1} > ${oldpruned} | |
224 | sed -e "s/\([^:]*\):\([^:]*\):\(.*\)/\1:0:\3/" ${newf1} > ${newpruned} | |
225 | # Use diff without option to get normal diff output that | |
226 | # is reparsed after | |
227 | diff ${oldpruned} ${newpruned} > ${diffin} | |
228 | # Only keep new warnings | |
229 | sed -n -e "/^>.*/p" ${diffin} > ${diff} | |
230 | sedscript=${wwwdir}/sedscript | |
231 | script=${wwwdir}/script | |
232 | sed -n -e "s|\(^[0-9,]*\)a\(.*\)|echo \1a\2 \n \ | |
233 | sed -n \'\2s:\\\\(.*\\\\):> \\\\1:p\' ${newf1}|p" \ | |
234 | -e "s|\(^[0-9,]*\)d\(.*\)|echo \1d\2\n \ | |
235 | sed -n \'\1s:\\\\(.*\\\\):< \\\\1:p\' ${oldf1}|p" \ | |
236 | -e "s|\(^[0-9,]*\)c\(.*\)|echo \1c\2\n \ | |
237 | sed -n \'\1s:\\\\(.*\\\\):< \\\\1:p\' ${oldf1} \n \ | |
238 | sed -n \"\2s:\\\\(.*\\\\):> \\\\1:p\" ${newf1}|p" \ | |
239 | ${diffin} > ${sedscript} | |
240 | ${SHELL} ${sedscript} > ${wwwdir}/message | |
241 | sed -n \ | |
242 | -e "s;\(.*\);echo \\\"\1\\\";p" \ | |
243 | -e "s;.*< \([^:]*\):\([0-9]*\):.*;grep \"^\1:\2:\" ${oldsrcf};p" \ | |
244 | -e "s;.*> \([^:]*\):\([0-9]*\):.*;grep \"^\1:\2:\" ${srcf};p" \ | |
245 | ${wwwdir}/message > ${script} | |
246 | ${SHELL} ${script} > ${wwwdir}/mail-message | |
247 | if [ "x${branch}" != "x" ]; then | |
248 | email_suffix="`date` in ${branch}" | |
249 | else | |
250 | email_suffix="`date`" | |
251 | fi | |
252 | ||
253 | fi | |
254 | ||
255 | ||
256 | ||
257 | ||
258 | if ${check_doschk_p} && test -d "${srcdir}" | |
259 | then | |
260 | echo "`date`: Checking for doschk" 1>&2 | |
261 | rm -f "${wwwdir}"/ari.doschk.* | |
262 | fnchange_lst="${srcdir}"/gdb/config/djgpp/fnchange.lst | |
263 | fnchange_awk="${wwwdir}"/ari.doschk.awk | |
264 | doschk_in="${wwwdir}"/ari.doschk.in | |
265 | doschk_out="${wwwdir}"/ari.doschk.out | |
266 | doschk_bug="${wwwdir}"/ari.doschk.bug | |
267 | doschk_char="${wwwdir}"/ari.doschk.char | |
268 | ||
269 | # Transform fnchange.lst into fnchange.awk. The program DJTAR | |
270 | # does a textual substitution of each file name using the list. | |
271 | # Generate an awk script that does the equivalent - matches an | |
272 | # exact line and then outputs the replacement. | |
273 | ||
274 | sed -e 's;@[^@]*@[/]*\([^ ]*\) @[^@]*@[/]*\([^ ]*\);\$0 == "\1" { print "\2"\; next\; };' \ | |
275 | < "${fnchange_lst}" > "${fnchange_awk}" | |
276 | echo '{ print }' >> "${fnchange_awk}" | |
277 | ||
278 | # Do the raw analysis - transform the list of files into the DJGPP | |
279 | # equivalents putting it in the .in file | |
280 | ( cd "${srcdir}" && find * \ | |
281 | -name '*.info-[0-9]*' -prune \ | |
282 | -o -name tcl -prune \ | |
283 | -o -name itcl -prune \ | |
284 | -o -name tk -prune \ | |
285 | -o -name libgui -prune \ | |
286 | -o -name tix -prune \ | |
287 | -o -name dejagnu -prune \ | |
288 | -o -name expect -prune \ | |
289 | -o -type f -print ) \ | |
290 | | $AWK -f ${fnchange_awk} > ${doschk_in} | |
291 | ||
292 | # Start with a clean slate | |
293 | rm -f ${doschk_bug} | |
294 | ||
295 | # Check for any invalid characters. | |
296 | grep '[\+\,\;\=\[\]\|\<\>\\\"\:\?\*]' < ${doschk_in} > ${doschk_char} | |
297 | # ari.*.bug: <FILE>:<LINE>: <CATEGORY>: <BUG>: <DOC> | |
298 | sed < ${doschk_char} >> ${doschk_bug} \ | |
299 | -e s'/$/:0: dos: DOSCHK: Invalid DOS character/' | |
300 | ||
301 | # Magic to map ari.doschk.out to ari.doschk.bug goes here | |
302 | doschk < ${doschk_in} > ${doschk_out} | |
303 | cat ${doschk_out} | $AWK >> ${doschk_bug} ' | |
304 | BEGIN { | |
305 | state = 1; | |
306 | invalid_dos = state++; bug[invalid_dos] = "invalid DOS file name"; category[invalid_dos] = "dos"; | |
307 | same_dos = state++; bug[same_dos] = "DOS 8.3"; category[same_dos] = "dos"; | |
308 | same_sysv = state++; bug[same_sysv] = "SysV"; | |
309 | long_sysv = state++; bug[long_sysv] = "long SysV"; | |
310 | internal = state++; bug[internal] = "internal doschk"; category[internal] = "internal"; | |
311 | state = 0; | |
312 | } | |
313 | /^$/ { state = 0; next; } | |
314 | /^The .* not valid DOS/ { state = invalid_dos; next; } | |
315 | /^The .* same DOS/ { state = same_dos; next; } | |
316 | /^The .* same SysV/ { state = same_sysv; next; } | |
317 | /^The .* too long for SysV/ { state = long_sysv; next; } | |
318 | /^The .* / { state = internal; next; } | |
319 | ||
320 | NF == 0 { next } | |
321 | ||
322 | NF == 3 { name = $1 ; file = $3 } | |
323 | NF == 1 { file = $1 } | |
324 | NF > 3 && $2 == "-" { file = $1 ; name = gensub(/^.* - /, "", 1) } | |
325 | ||
326 | state == same_dos { | |
327 | # ari.*.bug: <FILE>:<LINE>: <CATEGORY>: <BUG>: <DOC> | |
328 | print file ":0: " category[state] ": " \ | |
329 | name " " bug[state] " " " dup: " \ | |
330 | " DOSCHK - the names " name " and " file " resolve to the same" \ | |
331 | " file on a " bug[state] \ | |
332 | " system.<br>For DOS, this can be fixed by modifying the file" \ | |
333 | " fnchange.lst." | |
334 | next | |
335 | } | |
336 | state == invalid_dos { | |
337 | # ari.*.bug: <FILE>:<LINE>: <SEVERITY>: <CATEGORY>: <DOC> | |
338 | print file ":0: " category[state] ": " name ": DOSCHK - " name | |
339 | next | |
340 | } | |
341 | state == internal { | |
342 | # ari.*.bug: <FILE>:<LINE>: <SEVERITY>: <CATEGORY>: <DOC> | |
343 | print file ":0: " category[state] ": " bug[state] ": DOSCHK - a " \ | |
344 | bug[state] " problem" | |
345 | } | |
346 | ' | |
347 | fi | |
348 | ||
349 | ||
350 | ||
351 | if ${check_werror_p} && test -d "${srcdir}" | |
352 | then | |
353 | echo "`date`: Checking Makefile.in for non- -Werror rules" | |
354 | rm -f ${wwwdir}/ari.werror.* | |
355 | cat "${srcdir}/${project}/Makefile.in" | $AWK > ${wwwdir}/ari.werror.bug ' | |
356 | BEGIN { | |
357 | count = 0 | |
358 | cont_p = 0 | |
359 | full_line = "" | |
360 | } | |
361 | /^[-_[:alnum:]]+\.o:/ { | |
362 | file = gensub(/.o:.*/, "", 1) ".c" | |
363 | } | |
364 | ||
365 | /[^\\]\\$/ { gsub (/\\$/, ""); full_line = full_line $0; cont_p = 1; next; } | |
366 | cont_p { $0 = full_line $0; cont_p = 0; full_line = ""; } | |
367 | ||
368 | /\$\(COMPILE\.pre\)/ { | |
369 | print file " has line " $0 | |
370 | if (($0 !~ /\$\(.*ERROR_CFLAGS\)/) && ($0 !~ /\$\(INTERNAL_CFLAGS\)/)) { | |
371 | # ari.*.bug: <FILE>:<LINE>: <CATEGORY>: <BUG>: <DOC> | |
372 | print "'"${project}"'/" file ":0: info: Werror: The file is not being compiled with -Werror" | |
373 | } | |
374 | } | |
375 | ' | |
376 | fi | |
377 | ||
378 | ||
379 | # From the warnings, generate the doc and indexed bug files | |
380 | if ${update_doc_p} | |
381 | then | |
382 | cd ${wwwdir} | |
383 | rm -f ari.doc ari.idx ari.doc.bug | |
384 | # Generate an extra file containing all the bugs that the ARI can detect. | |
385 | /bin/sh ${aridir}/gdb_ari.sh -Werror -Wall --print-idx --print-doc >> ari.doc.bug | |
386 | cat ari.*.bug | $AWK > ari.idx ' | |
387 | BEGIN { | |
388 | FS=": *" | |
389 | } | |
390 | { | |
391 | # ari.*.bug: <FILE>:<LINE>: <CATEGORY>: <BUG>: <DOC> | |
392 | file = $1 | |
393 | line = $2 | |
394 | category = $3 | |
395 | bug = $4 | |
396 | if (! (bug in cat)) { | |
397 | cat[bug] = category | |
398 | # strip any trailing .... (supplement) | |
399 | doc[bug] = gensub(/ \([^\)]*\)$/, "", 1, $5) | |
400 | count[bug] = 0 | |
401 | } | |
402 | if (file != "") { | |
403 | count[bug] += 1 | |
404 | # ari.*.idx: <BUG>:<FILE>:<CATEGORY> | |
405 | print bug ":" file ":" category | |
406 | } | |
407 | # Also accumulate some categories as obsolete | |
408 | if (category == "deprecated") { | |
409 | # ari.*.idx: <BUG>:<FILE>:<CATEGORY> | |
410 | if (file != "") { | |
411 | print category ":" file ":" "obsolete" | |
412 | } | |
413 | #count[category]++ | |
414 | #doc[category] = "Contains " category " code" | |
415 | } | |
416 | } | |
417 | END { | |
418 | i = 0; | |
419 | for (bug in count) { | |
420 | # ari.*.doc: <BUG>:<COUNT>:<CATEGORY>:<DOC> | |
421 | print bug ":" count[bug] ":" cat[bug] ":" doc[bug] >> "ari.doc" | |
422 | } | |
423 | } | |
424 | ' | |
425 | fi | |
426 | ||
427 | ||
428 | # print_toc BIAS MIN_COUNT CATEGORIES TITLE | |
429 | ||
430 | # Print a table of contents containing the bugs CATEGORIES. If the | |
431 | # BUG count >= MIN_COUNT print it in the table-of-contents. If | |
432 | # MIN_COUNT is non -ve, also include a link to the table.Adjust the | |
433 | # printed BUG count by BIAS. | |
434 | ||
435 | all= | |
436 | ||
437 | print_toc () | |
438 | { | |
439 | bias="$1" ; shift | |
440 | min_count="$1" ; shift | |
441 | ||
442 | all=" $all $1 " | |
443 | categories="" | |
444 | for c in $1; do | |
445 | categories="${categories} categories[\"${c}\"] = 1 ;" | |
446 | done | |
447 | shift | |
448 | ||
449 | title="$@" ; shift | |
450 | ||
451 | echo "<p>" >> ${newari} | |
452 | echo "<a name=${title}>" | tr '[A-Z]' '[a-z]' >> ${newari} | |
453 | echo "<h3>${title}</h3>" >> ${newari} | |
454 | cat >> ${newari} # description | |
455 | ||
456 | cat >> ${newari} <<EOF | |
457 | <p> | |
458 | <table> | |
459 | <tr><th align=left>BUG</th><th>Total</th><th align=left>Description</th></tr> | |
460 | EOF | |
461 | # ari.*.doc: <BUG>:<COUNT>:<CATEGORY>:<DOC> | |
462 | cat ${wwwdir}/ari.doc \ | |
463 | | sort -t: +1rn -2 +0d \ | |
464 | | $AWK >> ${newari} ' | |
465 | BEGIN { | |
466 | FS=":" | |
467 | '"$categories"' | |
468 | MIN_COUNT = '${min_count}' | |
469 | BIAS = '${bias}' | |
470 | total = 0 | |
471 | nr = 0 | |
472 | } | |
473 | { | |
474 | # ari.*.doc: <BUG>:<COUNT>:<CATEGORY>:<DOC> | |
475 | bug = $1 | |
476 | count = $2 | |
477 | category = $3 | |
478 | doc = $4 | |
479 | if (count < MIN_COUNT) next | |
480 | if (!(category in categories)) next | |
481 | nr += 1 | |
482 | total += count | |
483 | printf "<tr>" | |
484 | printf "<th align=left valign=top><a name=\"%s\">", bug | |
485 | printf "%s", gensub(/_/, " ", "g", bug) | |
486 | printf "</a></th>" | |
487 | printf "<td align=right valign=top>" | |
488 | if (count > 0 && MIN_COUNT >= 0) { | |
489 | printf "<a href=\"#,%s\">%d</a></td>", bug, count + BIAS | |
490 | } else { | |
491 | printf "%d", count + BIAS | |
492 | } | |
493 | printf "</td>" | |
494 | printf "<td align=left valign=top>%s</td>", doc | |
495 | printf "</tr>" | |
496 | print "" | |
497 | } | |
498 | END { | |
499 | print "<tr><th align=right valign=top>" nr "</th><th align=right valign=top>" total "</th><td></td></tr>" | |
500 | } | |
501 | ' | |
502 | cat >> ${newari} <<EOF | |
503 | </table> | |
504 | <p> | |
505 | EOF | |
506 | } | |
507 | ||
508 | ||
509 | print_table () | |
510 | { | |
511 | categories="" | |
512 | for c in $1; do | |
513 | categories="${categories} categories[\"${c}\"] = 1 ;" | |
514 | done | |
515 | # Remember to prune the dir prefix from projects files | |
516 | # ari.*.idx: <BUG>:<FILE>:<CATEGORY> | |
517 | cat ${wwwdir}/ari.idx | $AWK >> ${newari} ' | |
518 | function qsort (table, | |
519 | middle, tmp, left, nr_left, right, nr_right, result) { | |
520 | middle = "" | |
521 | for (middle in table) { break; } | |
522 | nr_left = 0; | |
523 | nr_right = 0; | |
524 | for (tmp in table) { | |
525 | if (tolower(tmp) < tolower(middle)) { | |
526 | nr_left++ | |
527 | left[tmp] = tmp | |
528 | } else if (tolower(tmp) > tolower(middle)) { | |
529 | nr_right++ | |
530 | right[tmp] = tmp | |
531 | } | |
532 | } | |
533 | #print "qsort " nr_left " " middle " " nr_right > "/dev/stderr" | |
534 | result = "" | |
535 | if (nr_left > 0) { | |
536 | result = qsort(left) SUBSEP | |
537 | } | |
538 | result = result middle | |
539 | if (nr_right > 0) { | |
540 | result = result SUBSEP qsort(right) | |
541 | } | |
542 | return result | |
543 | } | |
4574b35a | 544 | function print_heading (nb_file, where, bug_i) { |
b786c521 PM |
545 | print "" |
546 | print "<tr border=1>" | |
4574b35a | 547 | print "<th align=left>File " nb_file "</th>" |
b786c521 PM |
548 | print "<th align=left><em>Total</em></th>" |
549 | print "<th></th>" | |
550 | for (bug_i = 1; bug_i <= nr_bug; bug_i++) { | |
551 | bug = i2bug[bug_i]; | |
552 | printf "<th>" | |
553 | # The title names are offset by one. Otherwize, when the browser | |
554 | # jumps to the name it leaves out half the relevant column. | |
555 | #printf "<a name=\",%s\"> </a>", bug | |
556 | printf "<a name=\",%s\"> </a>", i2bug[bug_i-1] | |
557 | printf "<a href=\"#%s\">", bug | |
558 | printf "%s", gensub(/_/, " ", "g", bug) | |
559 | printf "</a>\n" | |
560 | printf "</th>\n" | |
561 | } | |
562 | #print "<th></th>" | |
563 | printf "<th><a name=\"%s,\"> </a></th>\n", i2bug[bug_i-1] | |
564 | print "<th align=left><em>Total</em></th>" | |
4574b35a | 565 | print "<th align=left>File " nb_file "</th>" |
b786c521 PM |
566 | print "</tr>" |
567 | } | |
568 | function print_totals (where, bug_i) { | |
569 | print "<th align=left><em>Totals</em></th>" | |
570 | printf "<th align=right>" | |
571 | printf "<em>%s</em>", total | |
572 | printf ">" | |
573 | printf "</th>\n" | |
574 | print "<th></th>"; | |
575 | for (bug_i = 1; bug_i <= nr_bug; bug_i++) { | |
576 | bug = i2bug[bug_i]; | |
577 | printf "<th align=right>" | |
578 | printf "<em>" | |
579 | printf "<a href=\"#%s\">%d</a>", bug, bug_total[bug] | |
580 | printf "</em>"; | |
581 | printf "<a href=\"#%s,%s\">^</a>", prev_file[bug, where], bug | |
582 | printf "<a href=\"#%s,%s\">v</a>", next_file[bug, where], bug | |
583 | printf "<a name=\"%s,%s\"> </a>", where, bug | |
584 | printf "</th>"; | |
585 | print "" | |
586 | } | |
587 | print "<th></th>" | |
588 | printf "<th align=right>" | |
589 | printf "<em>%s</em>", total | |
590 | printf "<" | |
591 | printf "</th>\n" | |
592 | print "<th align=left><em>Totals</em></th>" | |
593 | print "</tr>" | |
594 | } | |
595 | BEGIN { | |
596 | FS = ":" | |
597 | '"${categories}"' | |
598 | nr_file = 0; | |
599 | nr_bug = 0; | |
600 | } | |
601 | { | |
602 | # ari.*.idx: <BUG>:<FILE>:<CATEGORY> | |
603 | bug = $1 | |
604 | file = $2 | |
605 | category = $3 | |
606 | # Interested in this | |
607 | if (!(category in categories)) next | |
608 | # Totals | |
609 | db[bug, file] += 1 | |
610 | bug_total[bug] += 1 | |
611 | file_total[file] += 1 | |
612 | total += 1 | |
613 | } | |
614 | END { | |
615 | ||
616 | # Sort the files and bugs creating indexed lists. | |
617 | nr_bug = split(qsort(bug_total), i2bug, SUBSEP); | |
618 | nr_file = split(qsort(file_total), i2file, SUBSEP); | |
619 | ||
620 | # Dummy entries for first/last | |
621 | i2file[0] = 0 | |
622 | i2file[-1] = -1 | |
623 | i2bug[0] = 0 | |
624 | i2bug[-1] = -1 | |
625 | ||
626 | # Construct a cycle of next/prev links. The file/bug "0" and "-1" | |
627 | # are used to identify the start/end of the cycle. Consequently, | |
628 | # prev(0) = -1 (prev of start is the end) and next(-1) = 0 (next | |
629 | # of end is the start). | |
630 | ||
631 | # For all the bugs, create a cycle that goes to the prev / next file. | |
632 | for (bug_i = 1; bug_i <= nr_bug; bug_i++) { | |
633 | bug = i2bug[bug_i] | |
634 | prev = 0 | |
635 | prev_file[bug, 0] = -1 | |
636 | next_file[bug, -1] = 0 | |
637 | for (file_i = 1; file_i <= nr_file; file_i++) { | |
638 | file = i2file[file_i] | |
639 | if ((bug, file) in db) { | |
640 | prev_file[bug, file] = prev | |
641 | next_file[bug, prev] = file | |
642 | prev = file | |
643 | } | |
644 | } | |
645 | prev_file[bug, -1] = prev | |
646 | next_file[bug, prev] = -1 | |
647 | } | |
648 | ||
649 | # For all the files, create a cycle that goes to the prev / next bug. | |
650 | for (file_i = 1; file_i <= nr_file; file_i++) { | |
651 | file = i2file[file_i] | |
652 | prev = 0 | |
653 | prev_bug[file, 0] = -1 | |
654 | next_bug[file, -1] = 0 | |
655 | for (bug_i = 1; bug_i <= nr_bug; bug_i++) { | |
656 | bug = i2bug[bug_i] | |
657 | if ((bug, file) in db) { | |
658 | prev_bug[file, bug] = prev | |
659 | next_bug[file, prev] = bug | |
660 | prev = bug | |
661 | } | |
662 | } | |
663 | prev_bug[file, -1] = prev | |
664 | next_bug[file, prev] = -1 | |
665 | } | |
666 | ||
667 | print "<table border=1 cellspacing=0>" | |
668 | print "<tr></tr>" | |
4574b35a | 669 | print_heading(nr_file, 0); |
b786c521 PM |
670 | print "<tr></tr>" |
671 | print_totals(0); | |
672 | print "<tr></tr>" | |
673 | ||
674 | for (file_i = 1; file_i <= nr_file; file_i++) { | |
675 | file = i2file[file_i]; | |
676 | pfile = gensub(/^'${project}'\//, "", 1, file) | |
677 | print "" | |
678 | print "<tr>" | |
679 | print "<th align=left><a name=\"" file ",\">" pfile "</a></th>" | |
680 | printf "<th align=right>" | |
681 | printf "%s", file_total[file] | |
682 | printf "<a href=\"#%s,%s\">></a>", file, next_bug[file, 0] | |
683 | printf "</th>\n" | |
684 | print "<th></th>" | |
685 | for (bug_i = 1; bug_i <= nr_bug; bug_i++) { | |
686 | bug = i2bug[bug_i]; | |
687 | if ((bug, file) in db) { | |
688 | printf "<td align=right>" | |
689 | printf "<a href=\"#%s\">%d</a>", bug, db[bug, file] | |
690 | printf "<a href=\"#%s,%s\">^</a>", prev_file[bug, file], bug | |
691 | printf "<a href=\"#%s,%s\">v</a>", next_file[bug, file], bug | |
692 | printf "<a name=\"%s,%s\"> </a>", file, bug | |
693 | printf "</td>" | |
694 | print "" | |
695 | } else { | |
696 | print "<td> </td>" | |
697 | #print "<td></td>" | |
698 | } | |
699 | } | |
700 | print "<th></th>" | |
701 | printf "<th align=right>" | |
702 | printf "%s", file_total[file] | |
703 | printf "<a href=\"#%s,%s\"><</a>", file, prev_bug[file, -1] | |
704 | printf "</th>\n" | |
705 | print "<th align=left>" pfile "</th>" | |
706 | print "</tr>" | |
707 | } | |
708 | ||
709 | print "<tr></tr>" | |
710 | print_totals(-1) | |
711 | print "<tr></tr>" | |
4574b35a | 712 | print_heading(nr_file, -1); |
b786c521 PM |
713 | print "<tr></tr>" |
714 | print "" | |
715 | print "</table>" | |
716 | print "" | |
717 | } | |
718 | ' | |
719 | } | |
720 | ||
721 | ||
722 | # Make the scripts available | |
723 | cp ${aridir}/gdb_*.sh ${wwwdir} | |
724 | ||
4574b35a PM |
725 | nb_files=`cd "${srcdir}" && /bin/sh ${aridir}/gdb_find.sh "${project}" | wc -l` |
726 | ||
727 | echo "Total number of tested files is $nb_files" | |
728 | ||
729 | if [ "x$debug_awk" = "x" ] | |
730 | then | |
731 | debug_awk=0 | |
732 | fi | |
733 | ||
b786c521 | 734 | # Compute the ARI index - ratio of zero vs non-zero problems. |
4574b35a | 735 | indexes=`${AWK} -v debug=${debug_awk} -v nr="$nb_files" ' |
b786c521 PM |
736 | BEGIN { |
737 | FS=":" | |
738 | } | |
739 | { | |
740 | # ari.*.doc: <BUG>:<COUNT>:<CATEGORY>:<DOC> | |
741 | bug = $1; count = $2; category = $3; doc = $4 | |
742 | ||
4574b35a PM |
743 | # legacy type error have at least one entry, |
744 | #corresponding to the declaration. | |
745 | if (bug ~ /^legacy /) legacy++ | |
746 | # Idem for deprecated_XXX symbols/functions. | |
747 | if (bug ~ /^deprecated /) deprecated++ | |
b786c521 PM |
748 | |
749 | if (category !~ /^gdbarch$/) { | |
750 | bugs += count | |
4574b35a | 751 | nrtests += 1 |
b786c521 PM |
752 | } |
753 | if (count == 0) { | |
754 | oks++ | |
755 | } | |
756 | } | |
757 | END { | |
4574b35a PM |
758 | if (debug == 1) { |
759 | print "nb files: " nr | |
760 | print "tests/oks: " nrtests "/" oks | |
761 | print "bugs/tests: " bugs "/" nrtests | |
762 | print "bugs/oks: " bugs "/" oks | |
763 | print bugs "/ (" oks "+" legacy "+" deprecated ")" | |
764 | } | |
765 | # This value should be as low as possible | |
b786c521 PM |
766 | print bugs / ( oks + legacy + deprecated ) |
767 | } | |
768 | ' ${wwwdir}/ari.doc` | |
769 | ||
770 | # Merge, generating the ARI tables. | |
771 | if ${update_web_p} | |
772 | then | |
773 | echo "Create the ARI table" 1>&2 | |
774 | oldari=${wwwdir}/old.html | |
775 | ari=${wwwdir}/index.html | |
776 | newari=${wwwdir}/new.html | |
777 | rm -f ${newari} ${newari}.gz | |
778 | cat <<EOF >> ${newari} | |
779 | <html> | |
780 | <head> | |
781 | <title>A.R. Index for GDB version ${version}</title> | |
782 | </head> | |
783 | <body> | |
784 | ||
785 | <center><h2>A.R. Index for GDB version ${version}<h2></center> | |
786 | ||
787 | <!-- body, update above using ../index.sh --> | |
788 | ||
789 | <!-- Navigation. This page contains the following anchors. | |
790 | "BUG": The definition of the bug. | |
791 | "FILE,BUG": The row/column containing FILEs BUG count | |
792 | "0,BUG", "-1,BUG": The top/bottom total for BUGs column. | |
793 | "FILE,O", "FILE,-1": The left/right total for FILEs row. | |
794 | ",BUG": The top title for BUGs column. | |
795 | "FILE,": The left title for FILEs row. | |
796 | --> | |
797 | ||
798 | <center><h3>${indexes}</h3></center> | |
799 | <center><h3>You can not take this seriously!</h3></center> | |
800 | ||
801 | <center> | |
802 | Also available: | |
803 | <a href="../gdb/ari/">most recent branch</a> | |
804 | | | |
805 | <a href="../gdb/current/ari/">current</a> | |
806 | | | |
807 | <a href="../gdb/download/ari/">last release</a> | |
808 | </center> | |
809 | ||
810 | <center> | |
811 | Last updated: `date -u` | |
812 | </center> | |
813 | EOF | |
814 | ||
815 | print_toc 0 1 "internal regression" Critical <<EOF | |
816 | Things previously eliminated but returned. This should always be empty. | |
817 | EOF | |
818 | ||
819 | print_table "regression code comment obsolete gettext" | |
820 | ||
821 | print_toc 0 0 code Code <<EOF | |
822 | Coding standard problems, portability problems, readability problems. | |
823 | EOF | |
824 | ||
825 | print_toc 0 0 comment Comments <<EOF | |
826 | Problems concerning comments in source files. | |
827 | EOF | |
828 | ||
829 | print_toc 0 0 gettext GetText <<EOF | |
830 | Gettext related problems. | |
831 | EOF | |
832 | ||
833 | print_toc 0 -1 dos DOS 8.3 File Names <<EOF | |
834 | File names with problems on 8.3 file systems. | |
835 | EOF | |
836 | ||
837 | print_toc -2 -1 deprecated Deprecated <<EOF | |
838 | Mechanisms that have been replaced with something better, simpler, | |
839 | cleaner; or are no longer required by core-GDB. New code should not | |
840 | use deprecated mechanisms. Existing code, when touched, should be | |
841 | updated to use non-deprecated mechanisms. See obsolete and deprecate. | |
842 | (The declaration and definition are hopefully excluded from count so | |
843 | zero should indicate no remaining uses). | |
844 | EOF | |
845 | ||
846 | print_toc 0 0 obsolete Obsolete <<EOF | |
847 | Mechanisms that have been replaced, but have not yet been marked as | |
848 | such (using the deprecated_ prefix). See deprecate and deprecated. | |
849 | EOF | |
850 | ||
851 | print_toc 0 -1 deprecate Deprecate <<EOF | |
852 | Mechanisms that are a candidate for being made obsolete. Once core | |
853 | GDB no longer depends on these mechanisms and/or there is a | |
854 | replacement available, these mechanims can be deprecated (adding the | |
855 | deprecated prefix) obsoleted (put into category obsolete) or deleted. | |
856 | See obsolete and deprecated. | |
857 | EOF | |
858 | ||
859 | print_toc -2 -1 legacy Legacy <<EOF | |
860 | Methods used to prop up targets using targets that still depend on | |
861 | deprecated mechanisms. (The method's declaration and definition are | |
862 | hopefully excluded from count). | |
863 | EOF | |
864 | ||
865 | print_toc -2 -1 gdbarch Gdbarch <<EOF | |
866 | Count of calls to the gdbarch set methods. (Declaration and | |
867 | definition hopefully excluded from count). | |
868 | EOF | |
869 | ||
870 | print_toc 0 -1 macro Macro <<EOF | |
871 | Breakdown of macro definitions (and #undef) in configuration files. | |
872 | EOF | |
873 | ||
874 | print_toc 0 0 regression Fixed <<EOF | |
875 | Problems that have been expunged from the source code. | |
876 | EOF | |
877 | ||
878 | # Check for invalid categories | |
879 | for a in $all; do | |
880 | alls="$alls all[$a] = 1 ;" | |
881 | done | |
882 | cat ari.*.doc | $AWK >> ${newari} ' | |
883 | BEGIN { | |
884 | FS = ":" | |
885 | '"$alls"' | |
886 | } | |
887 | { | |
888 | # ari.*.doc: <BUG>:<COUNT>:<CATEGORY>:<DOC> | |
889 | bug = $1 | |
890 | count = $2 | |
891 | category = $3 | |
892 | doc = $4 | |
893 | if (!(category in all)) { | |
894 | print "<b>" category "</b>: no documentation<br>" | |
895 | } | |
896 | } | |
897 | ' | |
898 | ||
899 | cat >> ${newari} <<EOF | |
900 | <center> | |
901 | Input files: | |
902 | `( cd ${wwwdir} && ls ari.*.bug ari.idx ari.doc ) | while read f | |
903 | do | |
904 | echo "<a href=\"${f}\">${f}</a>" | |
905 | done` | |
906 | </center> | |
907 | ||
908 | <center> | |
909 | Scripts: | |
910 | `( cd ${wwwdir} && ls *.sh ) | while read f | |
911 | do | |
912 | echo "<a href=\"${f}\">${f}</a>" | |
913 | done` | |
914 | </center> | |
915 | ||
916 | <!-- /body, update below using ../index.sh --> | |
917 | </body> | |
918 | </html> | |
919 | EOF | |
920 | ||
921 | for i in . .. ../..; do | |
922 | x=${wwwdir}/${i}/index.sh | |
923 | if test -x $x; then | |
924 | $x ${newari} | |
925 | break | |
926 | fi | |
927 | done | |
928 | ||
929 | gzip -c -v -9 ${newari} > ${newari}.gz | |
930 | ||
931 | cp ${ari} ${oldari} | |
932 | cp ${ari}.gz ${oldari}.gz | |
933 | cp ${newari} ${ari} | |
934 | cp ${newari}.gz ${ari}.gz | |
935 | ||
936 | fi # update_web_p | |
937 | ||
938 | # ls -l ${wwwdir} | |
939 | ||
940 | exit 0 |