OSDN Git Service

* flow.c (clear_log_links): Use free_INSN_LIST_list, not
[pf3gnuchains/gcc-fork.git] / gcc / gccbug.in
1 #!/bin/sh
2 # Submit a problem report to a GNATS site.
3 # Copyright (C) 1993, 2000, 2001 Free Software Foundation, Inc.
4 # Contributed by Brendan Kehoe (brendan@cygnus.com), based on a
5 # version written by Heinz G. Seidl (hgs@cygnus.com).
6 #
7 # This file is part of GNU GNATS.
8 #
9 # GNU GNATS 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 2, or (at your option)
12 # any later version.
13 #
14 # GNU GNATS 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 GNU GNATS; see the file COPYING.  If not, write to
21 # the Free Software Foundation, 59 Temple Place - Suite 330,
22 # Boston, MA 02111-1307, USA.
23
24 # The version of this send-pr.
25 VERSION=3.113
26
27 # The submitter-id for your site.
28 SUBMITTER=net
29
30 # The default mail address for PR submissions. 
31 GNATS_ADDR=gcc-gnats@gcc.gnu.org
32
33 # The default release for this host.
34 DEFAULT_RELEASE="@gcc_version_full@"
35
36 # The default organization.
37 DEFAULT_ORGANIZATION=
38
39 # What mailer to use.  This must come after the config file, since it is
40 # host-dependent.
41 # Copied from cvsbug
42 if [ -f /usr/sbin/sendmail ]; then  
43     MAIL_AGENT="/usr/sbin/sendmail -oi -t"
44 else  
45     MAIL_AGENT="/usr/lib/sendmail -oi -t"
46 fi
47 MAILER=`echo $MAIL_AGENT | sed -e 's, .*,,'`
48 if [ ! -f "$MAILER" ] ; then
49     echo "$COMMAND: Cannot file mail program \"$MAILER\"."
50     echo "$COMMAND: Please fix the MAIL_AGENT entry in the $COMMAND file."
51     exit 1
52 fi
53
54
55 # How to read the passwd database.
56 PASSWD="cat /etc/passwd"
57
58 ECHON=bsd
59
60 if [ $ECHON = bsd ] ; then
61   ECHON1="echo -n"
62   ECHON2=
63 elif [ $ECHON = sysv ] ; then
64   ECHON1=echo
65   ECHON2='\c'
66 else
67   ECHON1=echo
68   ECHON2=
69 fi
70
71 #\f
72
73 if [ -z "$TMPDIR" ]; then
74   TMPDIR=/tmp
75 else
76   if [ "`echo $TMPDIR | grep '/$'`" != "" ]; then
77     TMPDIR="`echo $TMPDIR | sed -e 's,/$,,'`"
78   fi
79 fi
80
81 if [ @have_mktemp_command@ = yes ]; then
82         TEMP0=`mktemp $TMPDIR/poXXXXXX` || exit 1
83         TEMP=`mktemp $TMPDIR/pXXXXXX` || exit 1
84         BAD=`mktemp $TMPDIR/pbadXXXXXX` || exit 1
85         REF=`mktemp $TMPDIR/pfXXXXXX` || exit 1
86         REMOVE_TEMP="rm -f $TEMP0 $TEMP $BAD $REF"
87 else
88         TEMPD=$TMPDIR/pd$$
89         TEMP0=$TEMPD/po$$
90         TEMP=$TEMPD/p$$
91         BAD=$TEMPD/pbad$$
92         REF=$TEMPD/pf$$
93         mkdir $TEMPD || exit 1
94         REMOVE_TEMP="rm -rf $TEMPD"
95 fi
96
97 # find a user name
98 if [ "$LOGNAME" = "" ]; then
99         if [ "$USER" != "" ]; then
100                 LOGNAME="$USER"
101         else
102                 LOGNAME="UNKNOWN"
103         fi
104 fi
105
106 FROM="$LOGNAME"
107 REPLY_TO="${REPLY_TO:-${REPLYTO:-$LOGNAME}}"
108
109 # Find out the name of the originator of this PR.
110 if [ -n "$NAME" ]; then
111   ORIGINATOR="$NAME"
112 elif [ -f $HOME/.fullname ]; then
113   ORIGINATOR="`sed -e '1q' $HOME/.fullname`"
114 else
115   # Must use temp file due to incompatibilities in quoting behavior
116   # and to protect shell metacharacters in the expansion of $LOGNAME
117   $PASSWD | grep "^$LOGNAME:" | awk -F: '{print $5}' | sed -e 's/,.*//' > $TEMP0
118   ORIGINATOR="`cat $TEMP0`"
119   rm -f $TEMP0
120 fi
121
122 if [ -n "$ORGANIZATION" ]; then
123   if [ -f "$ORGANIZATION" ]; then
124     ORGANIZATION="`cat $ORGANIZATION`"
125   fi
126 else
127   if [ -n "$DEFAULT_ORGANIZATION" ]; then
128     ORGANIZATION="$DEFAULT_ORGANIZATION"
129   elif [ -f $HOME/.organization ]; then
130     ORGANIZATION="`cat $HOME/.organization`"
131   fi
132 fi
133
134 # If they don't have a preferred editor set, then use
135 if [ -z "$VISUAL" ]; then
136   if [ -z "$EDITOR" ]; then
137     EDIT=vi
138   else
139     EDIT="$EDITOR"
140   fi
141 else
142   EDIT="$VISUAL"
143 fi
144
145 # Find out some information.
146 SYSTEM=`( [ -f /bin/uname ] && /bin/uname -a ) || \
147         ( [ -f /usr/bin/uname ] && /usr/bin/uname -a ) || echo ""`
148 ARCH=`[ -f /bin/arch ] && /bin/arch`
149 MACHINE=`[ -f /bin/machine ] && /bin/machine`
150
151 COMMAND=`echo $0 | sed -e 's,.*/,,'`
152 USAGE="Usage: $COMMAND [-PVL] [-t address] [-f filename] [-s severity]
153        [-c address] [--request-id] [--version]"
154 REMOVE=
155 BATCH=
156 CC=
157 SEVERITY_C=
158
159 while [ $# -gt 0 ]; do
160   case "$1" in
161     -r) ;;              # Ignore for backward compat.
162     -t | --to) if [ $# -eq 1 ]; then echo "$USAGE"; $REMOVE_TEMP; exit 1; fi
163         shift ; GNATS_ADDR="$1"
164         EXPLICIT_GNATS_ADDR=true
165         ;;
166     -f | --file) if [ $# -eq 1 ]; then echo "$USAGE"; $REMOVE_TEMP; exit 1; fi
167         shift ; IN_FILE="$1"
168         if [ "$IN_FILE" != "-" -a ! -r "$IN_FILE" ]; then
169           echo "$COMMAND: cannot read $IN_FILE"
170           $REMOVE_TEMP
171           exit 1
172         fi
173         ;;
174     -b | --batch) BATCH=true ;;
175     -c | --cc) if [ $# -eq 1 ]; then echo "$USAGE"; $REMOVE_TEMP; exit 1; fi
176         shift ; CC="$1"
177         ;;
178     -s | --severity) if [ $# -eq 1 ]; then echo "$USAGE"; $REMOVE_TEMP; exit 1; fi
179         shift ; SEVERITY_C="$1"
180         ;;
181     -p | -P | --print) PRINT=true ;;
182     -L | --list) FORMAT=norm ;;
183     -l | -CL | --lisp) FORMAT=lisp ;;
184     --request-id) REQUEST_ID=true ;;
185     -h | --help) echo "$USAGE"; $REMOVE_TEMP; exit 0 ;;
186     -V | --version) echo "$VERSION"; $REMOVE_TEMP; exit 0 ;;
187     -*) echo "$USAGE" ; $REMOVE_TEMP; exit 1 ;;
188     *) echo "$USAGE" ; $REMOVE_TEMP; exit 1
189  esac
190  shift
191 done
192
193 # spam does not need to be listed here
194 CATEGORIES="ada bootstrap c++ c debug fortran java libf2c libgcj libobjc libstdc++ middle-end objc optimization other preprocessor target web"
195
196 case "$FORMAT" in
197   lisp) echo "$CATEGORIES" | \
198         awk 'BEGIN {printf "( "} {printf "(\"%s\") ",$0} END {printf ")\n"}'
199         $REMOVE_TEMP
200         exit 0
201         ;;
202   norm) l=`echo "$CATEGORIES" | \
203         awk 'BEGIN {max = 0; } { if (length($0) > max) { max = length($0); } }
204              END {print max + 1;}'`
205         c=`expr 70 / $l`
206         if [ $c -eq 0 ]; then c=1; fi
207         echo "$CATEGORIES" | \
208         awk 'BEGIN {print "Known categories:"; i = 0 }
209           { printf ("%-'$l'.'$l's", $0); if ((++i % '$c') == 0) { print "" } }
210             END { print ""; }'
211         $REMOVE_TEMP
212         exit 0
213         ;;
214 esac
215
216 ORIGINATOR_C='<name of the PR author (one line)>'
217 ORGANIZATION_C='<organization of PR author (multiple lines)>'
218 SYNOPSIS_C='<synopsis of the problem (one line)>'
219 if [ -z "$SEVERITY_C" ]; then
220   SEVERITY_C='<[ non-critical | serious | critical ] (one line)>'
221 fi
222 PRIORITY_C='<[ low | medium ] (one line)>'
223 CATEGORY_C='<choose from the top of this file (one line)>'
224 RELEASE_C='<release number or tag (one line)>'
225 ENVIRONMENT_C='<machine, os, target, libraries (multiple lines)>'
226 DESCRIPTION_C='<precise description of the problem (multiple lines)>'
227 HOW_TO_REPEAT_C='<When reporting a compiler error, preprocessor output must be included>'
228 FIX_C='<how to correct or work around the problem, if known (multiple lines)>'
229
230 # Catch some signals. ($xs kludge needed by Sun /bin/sh)
231 xs=0
232 trap '$REMOVE_TEMP; exit $xs' 0
233 trap 'echo "$COMMAND: Aborting ..."; $REMOVE_TEMP; xs=1; exit' 1 3 13 15
234
235 # If they told us to use a specific file, then do so.
236 if [ -n "$IN_FILE" ]; then
237   if [ "$IN_FILE" = "-" ]; then
238     # The PR is coming from the standard input.
239     if [ -n "$EXPLICIT_GNATS_ADDR" ]; then
240       sed -e "s;^[Tt][Oo]:.*;To: $GNATS_ADDR;" > $TEMP
241     else
242       cat > $TEMP
243     fi
244   else
245     # Use the file they named.
246     if [ -n "$EXPLICIT_GNATS_ADDR" ]; then
247       sed -e "s;^[Tt][Oo]:.*;To: $GNATS_ADDR;" $IN_FILE > $TEMP
248     else
249       cat $IN_FILE > $TEMP
250     fi
251   fi
252 else
253
254   if [ -n "$PR_FORM" -a -z "$PRINT_INTERN" ]; then
255     # If their PR_FORM points to a bogus entry, then bail.
256     if [ ! -f "$PR_FORM" -o ! -r "$PR_FORM" -o ! -s "$PR_FORM" ]; then
257       echo "$COMMAND: can't seem to read your template file (\`$PR_FORM'), ignoring PR_FORM"
258       sleep 1
259       PRINT_INTERN=bad_prform
260     fi
261   fi
262
263   if [ -n "$PR_FORM" -a -z "$PRINT_INTERN" ]; then
264     cp $PR_FORM $TEMP || 
265       ( echo "$COMMAND: could not copy $PR_FORM" ; xs=1; exit )
266   else
267     for file in $TEMP $REF ; do
268       cat  > $file << '__EOF__'
269 SEND-PR: -*- send-pr -*-
270 SEND-PR: Lines starting with `SEND-PR' will be removed automatically, as
271 SEND-PR: will all comments (text enclosed in `<' and `>').
272 SEND-PR: 
273 SEND-PR: Please consult the GCC manual if you are not sure how to
274 SEND-PR: fill out a problem report.
275 SEND-PR: Note that the Synopsis field is mandatory.  The Subject (for
276 SEND-PR: the mail) will be made the same as Synopsis unless explicitly
277 SEND-PR: changed.
278 SEND-PR:
279 SEND-PR: Choose from the following categories:
280 SEND-PR:
281 __EOF__
282
283       # Format the categories so they fit onto lines.
284         l=`echo "$CATEGORIES" | \
285         awk 'BEGIN {max = 0; } { if (length($0) > max) { max = length($0); } }
286              END {print max + 1;}'`
287         c=`expr 61 / $l`
288         if [ $c -eq 0 ]; then c=1; fi
289         echo "$CATEGORIES" | \
290         awk 'BEGIN {printf "SEND-PR: "; i = 0 }
291           { printf ("%-'$l'.'$l's", $0);
292             if ((++i % '$c') == 0) { printf "\nSEND-PR: " } }
293             END { printf "\nSEND-PR:\n"; }' >> $file
294
295       cat >> $file << __EOF__
296 To: $GNATS_ADDR
297 Subject: 
298 From: $FROM
299 Reply-To: $REPLYTO
300 Cc: $CC
301 X-send-pr-version: $VERSION
302 X-GNATS-Notify: 
303
304
305 >Submitter-Id:  $SUBMITTER
306 >Originator:    $ORIGINATOR
307 >Organization:  ${ORGANIZATION-$ORGANIZATION_C}
308 >Confidential:  no
309 SEND-PR: Leave "Confidential" as "no"; all GCC PRs are public.
310 >Synopsis:      $SYNOPSIS_C
311 >Severity:      $SEVERITY_C
312 SEND-PR: critical     GCC is completely not operational; no work-around known.
313 SEND-PR: serious      GCC is not working properly; a work-around is possible.
314 SEND-PR: non-critical Report indicates minor problem.
315 >Priority:      $PRIORITY_C
316 SEND-PR: medium       The problem should be solved in the next release.
317 SEND-PR: low          The problem should be solve in a future release.
318 >Category:      $CATEGORY_C
319 >Class:         <[ doc-bug | accepts-illegal | rejects-legal | wrong-code | ice-on-legal-code| ice-on-illegal-code | pessimizes-code | sw-bug | change-request | support ] (one line)>
320 SEND-PR: doc-bug          The documentation is incorrect.
321 SEND-PR: accepts-illegal  GCC fails to reject erroneous code.
322 SEND-PR: rejects-legal    GCC gives an error message for correct code.
323 SEND-PR: wrong-code       The machine code generated by gcc is incorrect.
324 SEND-PR: ice-on-legal-code   GCC gives an Internal Compiler Error (ICE)
325 SEND-PR:                     for correct code
326 SEND-PR: ice-on-illegal-code GCC gives an ICE instead of reporting an error
327 SEND-PR: pessimizes-code     GCC misses an important optimization opportunity
328 SEND-PR: sw-bug              Software bug of some other class than above
329 SEND-PR: change-request      A feature in GCC is missing.
330 SEND-PR: support             I need help with gcc.
331 >Release:       ${DEFAULT_RELEASE-$RELEASE_C}
332 >Environment:
333 `[ -n "$SYSTEM" ] && echo System: $SYSTEM`
334 `[ -n "$ARCH" ] && echo Architecture: $ARCH`
335 `[ -n "$MACHINE" ] && echo Machine: $MACHINE`
336         $ENVIRONMENT_C
337 host: @host@
338 build: @build@
339 target: @target@
340 configured with: @gcc_config_arguments@
341 >Description:
342         $DESCRIPTION_C
343 >How-To-Repeat:
344         $HOW_TO_REPEAT_C
345 >Fix:
346         $FIX_C
347 __EOF__
348     done
349   fi
350
351   if [ "$PRINT" = true -o "$PRINT_INTERN" = true ]; then
352     cat $TEMP
353     xs=0; exit
354   fi
355
356   chmod u+w $TEMP
357   if [ -z "$REQUEST_ID" ]; then
358     eval $EDIT $TEMP
359   else
360     ed -s $TEMP << '__EOF__'
361 /^Subject/s/^Subject:.*/Subject: request for a customer id/
362 /^>Category/s/^>Category:.*/>Category: send-pr/
363 w
364 q
365 __EOF__
366   fi
367
368   if cmp -s $REF $TEMP ; then
369     echo "$COMMAND: problem report not filled out, therefore not sent"
370     xs=1; exit
371   fi
372 fi
373
374 #\f
375 #       Check the enumeration fields
376
377 # This is a "sed-subroutine" with one keyword parameter 
378 # (with workaround for Sun sed bug)
379 #
380 SED_CMD='
381 /$PATTERN/{
382 s|||
383 s|<.*>||
384 s|^[    ]*||
385 s|[     ]*$||
386 p
387 q
388 }'
389
390
391 while [ -z "$REQUEST_ID" ]; do
392   CNT=0
393
394   # 1) Confidential
395   #
396   PATTERN=">Confidential:"
397   CONFIDENTIAL=`eval sed -n -e "\"$SED_CMD\"" $TEMP`
398   case "$CONFIDENTIAL" in
399     no) CNT=`expr $CNT + 1` ;;
400     *) echo "$COMMAND: \`$CONFIDENTIAL' is not a valid value for \`Confidential'." ;;
401   esac
402   #
403   # 2) Severity
404   #
405   PATTERN=">Severity:"
406   SEVERITY=`eval sed -n -e "\"$SED_CMD\"" $TEMP`
407   case "$SEVERITY" in
408     ""|non-critical|serious|critical) CNT=`expr $CNT + 1` ;;
409     *)  echo "$COMMAND: \`$SEVERITY' is not a valid value for \`Severity'."
410   esac
411   #
412   # 3) Priority
413   #
414   PATTERN=">Priority:"
415   PRIORITY=`eval sed -n -e "\"$SED_CMD\"" $TEMP`
416   case "$PRIORITY" in
417     ""|low|medium) CNT=`expr $CNT + 1` ;;
418     high) echo "$COMMAND: \`Priority: high' is reserved for GCC maintainers." ;;
419     *)  echo "$COMMAND: \`$PRIORITY' is not a valid value for \`Priority'."
420   esac
421   #
422   # 4) Category
423   #
424   PATTERN=">Category:"
425   CATEGORY=`eval sed -n -e "\"$SED_CMD\"" $TEMP`
426   FOUND=
427   for C in $CATEGORIES
428   do
429     if [ "$C" = "$CATEGORY" ]; then FOUND=true ; break ; fi
430   done
431   if [ -n "$FOUND" ]; then
432     CNT=`expr $CNT + 1` 
433   else
434     if [ -z "$CATEGORY" ]; then
435       echo "$COMMAND: you must include a Category: field in your report."
436     else
437       echo "$COMMAND: \`$CATEGORY' is not a known category."
438     fi
439   fi
440   #
441   # 5) Class
442   #
443   PATTERN=">Class:"
444   CLASS=`eval sed -n -e "\"$SED_CMD\"" $TEMP`
445   case "$CLASS" in
446     ""|doc-bug|accepts-illegal|rejects-legal|wrong-code|ice-on-legal-code|ice-on-illegal-code|pessimizes-code|sw-bug|change-request|support) CNT=`expr $CNT + 1` ;;
447     *)  echo "$COMMAND: \`$CLASS' is not a valid value for \`Class'."
448   esac
449   #
450   # 6) Check that synopsis is not empty
451   #
452   if grep "^>Synopsis:[         ]*${SYNOPSIS_C}\$" $TEMP > /dev/null
453   then
454     echo "$COMMAND: Synopsis must not be empty."
455   else
456     CNT=`expr $CNT + 1`
457   fi
458
459   [ $CNT -lt 6 -a -z "$BATCH" ] && 
460     echo "Errors were found with the problem report."
461
462   while true; do
463     if [ -z "$BATCH" ]; then
464       $ECHON1 "a)bort, e)dit or s)end? $ECHON2"
465       read input
466     else
467       if [ $CNT -eq 6 ]; then
468         input=s
469       else
470         input=a
471       fi
472     fi
473     case "$input" in
474       a*)
475         if [ -z "$BATCH" ]; then
476           echo "$COMMAND: the problem report remains in $BAD and is not sent."
477           REMOVE_TEMP="rm -f $TEMP0 $TEMP $REF"
478           mv $TEMP $BAD
479         else
480           echo "$COMMAND: the problem report is not sent."
481         fi
482         xs=1; exit
483         ;;
484       e*)
485         eval $EDIT $TEMP
486         continue 2
487         ;;
488       s*)
489         break 2
490         ;;
491     esac
492   done
493 done
494
495 #
496 # Make sure the mail has got a Subject.  If not, use the same as
497 # in Synopsis.
498 #
499
500 if grep '^Subject:[     ]*$' $TEMP > /dev/null
501 then
502   SYNOPSIS=`grep '^>Synopsis:' $TEMP | sed -e 's/^>Synopsis:[   ]*//'`
503   ed -s $TEMP << __EOF__
504 /^Subject:/s/:.*\$/: $SYNOPSIS/
505 w
506 q
507 __EOF__
508 fi
509
510 #
511 #       Remove comments and send the problem report
512 #       (we have to use patterns, where the comment contains regex chars)
513 #
514 # /^>Originator:/s;$ORIGINATOR;;
515 sed  -e "
516 /^SEND-PR:/d
517 /^>Organization:/,/^>[A-Za-z-]*:/s;$ORGANIZATION_C;;
518 /^>Confidential:/s;<.*>;;
519 /^>Synopsis:/s;$SYNOPSIS_C;;
520 /^>Severity:/s;<.*>;;
521 /^>Priority:/s;<.*>;;
522 /^>Category:/s;$CATEGORY_C;;
523 /^>Class:/s;<.*>;;
524 /^>Release:/,/^>[A-Za-z-]*:/s;$RELEASE_C;;
525 /^>Environment:/,/^>[A-Za-z-]*:/s;$ENVIRONMENT_C;;
526 /^>Description:/,/^>[A-Za-z-]*:/s;$DESCRIPTION_C;;
527 /^>How-To-Repeat:/,/^>[A-Za-z-]*:/s;$HOW_TO_REPEAT_C;;
528 /^>Fix:/,/^>[A-Za-z-]*:/s;$FIX_C;;
529 " $TEMP > $REF
530
531 if $MAIL_AGENT < $REF; then
532   echo "$COMMAND: problem report sent"
533   xs=0; exit
534 else
535   echo "$COMMAND: mysterious mail failure."
536   if [ -z "$BATCH" ]; then
537     echo "$COMMAND: the problem report remains in $BAD and is not sent."
538     REMOVE_TEMP="rm -f $TEMP0 $TEMP $REF"
539     mv $REF $BAD
540   else
541     echo "$COMMAND: the problem report is not sent."
542   fi
543   xs=1; exit
544 fi