annotate contrib/repro_fail @ 158:494b0b89df80 default tip

...
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Mon, 25 May 2020 18:13:55 +0900
parents 04ced10e8804
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 #!/bin/bash -eu
kono
parents:
diff changeset
2 #
kono
parents:
diff changeset
3 # Script to reproduce a test failure from a dejagnu .log file.
kono
parents:
diff changeset
4 #
kono
parents:
diff changeset
5 # Contributed by Diego Novillo <dnovillo@google.com>
kono
parents:
diff changeset
6 #
kono
parents:
diff changeset
7 # Copyright (C) 2011, 2012, 2013 Free Software Foundation, Inc.
kono
parents:
diff changeset
8 #
kono
parents:
diff changeset
9 # This file is part of GCC.
kono
parents:
diff changeset
10 #
kono
parents:
diff changeset
11 # GCC is free software; you can redistribute it and/or modify
kono
parents:
diff changeset
12 # it under the terms of the GNU General Public License as published by
kono
parents:
diff changeset
13 # the Free Software Foundation; either version 3, or (at your option)
kono
parents:
diff changeset
14 # any later version.
kono
parents:
diff changeset
15 #
kono
parents:
diff changeset
16 # GCC is distributed in the hope that it will be useful,
kono
parents:
diff changeset
17 # but WITHOUT ANY WARRANTY; without even the implied warranty of
kono
parents:
diff changeset
18 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
kono
parents:
diff changeset
19 # GNU General Public License for more details.
kono
parents:
diff changeset
20 #
kono
parents:
diff changeset
21 # You should have received a copy of the GNU General Public License
kono
parents:
diff changeset
22 # along with GCC; see the file COPYING. If not, write to
kono
parents:
diff changeset
23 # the Free Software Foundation, 51 Franklin Street, Fifth Floor,
kono
parents:
diff changeset
24 # Boston, MA 02110-1301, USA.
kono
parents:
diff changeset
25
kono
parents:
diff changeset
26 # This script will search a line starting with 'spawn' that includes the
kono
parents:
diff changeset
27 # pattern you are looking for (typically a source file name).
kono
parents:
diff changeset
28 #
kono
parents:
diff changeset
29 # Once it finds that pattern, it re-executes the whole command
kono
parents:
diff changeset
30 # in the spawn line. If the pattern matches more than one spawn
kono
parents:
diff changeset
31 # command, it asks which one you want.
kono
parents:
diff changeset
32
kono
parents:
diff changeset
33 if [ $# -lt 2 ] ; then
kono
parents:
diff changeset
34 echo "usage: $0 [--debug|--debug-tui] pattern file.log [additional-args]"
kono
parents:
diff changeset
35 echo
kono
parents:
diff changeset
36 echo "Finds the 'spawn' line matching PATTERN in FILE.LOG and executes"
kono
parents:
diff changeset
37 echo "the command with any arguments in ADDITIONAL-ARGS."
kono
parents:
diff changeset
38 echo
kono
parents:
diff changeset
39 echo "If --debug is used, the compiler is invoked with -wrapper gdb,--args"
kono
parents:
diff changeset
40 echo "If --debug-tui is used, the compiler is invoked with -wrapper "\
kono
parents:
diff changeset
41 "gdb,--tui,--args"
kono
parents:
diff changeset
42 exit 1
kono
parents:
diff changeset
43 fi
kono
parents:
diff changeset
44
kono
parents:
diff changeset
45 if [ "$1" == "--debug" ] ; then
kono
parents:
diff changeset
46 debug_args="-wrapper gdb,--args"
kono
parents:
diff changeset
47 shift
kono
parents:
diff changeset
48 elif [ "$1" == "--debug-tui" ] ; then
kono
parents:
diff changeset
49 debug_args="-wrapper gdb,--tui,--args"
kono
parents:
diff changeset
50 shift
kono
parents:
diff changeset
51 else
kono
parents:
diff changeset
52 debug_args=""
kono
parents:
diff changeset
53 fi
kono
parents:
diff changeset
54 pattern="$1"
kono
parents:
diff changeset
55 logf="$2"
kono
parents:
diff changeset
56 shift 2
kono
parents:
diff changeset
57
kono
parents:
diff changeset
58 # Find the commands in LOGF that reference PATTERN.
kono
parents:
diff changeset
59 lines=$(grep -E "^spawn .*$pattern" $logf \
kono
parents:
diff changeset
60 | sed -e 's/^spawn -ignore SIGHUP //' \
kono
parents:
diff changeset
61 | sed -e 's/^spawn //')
kono
parents:
diff changeset
62 if [ -z "$lines" ] ; then
kono
parents:
diff changeset
63 echo "Could not find a spawn command for pattern $pattern"
kono
parents:
diff changeset
64 exit 1
kono
parents:
diff changeset
65 fi
kono
parents:
diff changeset
66
kono
parents:
diff changeset
67 # Collect all the command lines into the COMMANDS array.
kono
parents:
diff changeset
68 old_IFS="$IFS"
kono
parents:
diff changeset
69 IFS=" "
kono
parents:
diff changeset
70 num_lines=0
kono
parents:
diff changeset
71 for line in $lines ; do
kono
parents:
diff changeset
72 num_lines=$[$num_lines + 1]
kono
parents:
diff changeset
73 echo "[$num_lines] $line"
kono
parents:
diff changeset
74 commands[$num_lines]=$line
kono
parents:
diff changeset
75 done
kono
parents:
diff changeset
76
kono
parents:
diff changeset
77 # If we found more than one line for PATTERN, ask which one we should run.
kono
parents:
diff changeset
78 cmds_to_run='0'
kono
parents:
diff changeset
79 if [ $num_lines -gt 1 ] ; then
kono
parents:
diff changeset
80 echo
kono
parents:
diff changeset
81 echo
kono
parents:
diff changeset
82 echo -n "Enter the list of commands to run or '0' to run them all: "
kono
parents:
diff changeset
83 read cmds_to_run
kono
parents:
diff changeset
84 fi
kono
parents:
diff changeset
85 if [ "$cmds_to_run" = "0" ] ; then
kono
parents:
diff changeset
86 cmds_to_run=$(seq 1 $num_lines)
kono
parents:
diff changeset
87 fi
kono
parents:
diff changeset
88 IFS="$old_IFS"
kono
parents:
diff changeset
89
kono
parents:
diff changeset
90 # Finally, execute all the commands we were told to execute.
kono
parents:
diff changeset
91 for cmd_num in $cmds_to_run ; do
kono
parents:
diff changeset
92 cmd=${commands[$cmd_num]}
kono
parents:
diff changeset
93 set -x +e
kono
parents:
diff changeset
94 $cmd $debug_args "$@"
kono
parents:
diff changeset
95 set +x -e
kono
parents:
diff changeset
96 done