2 # Wrapper around gcc to add the .gdb_index section when running the testsuite.
4 # Copyright (C) 2010-2012 Free Software Foundation, Inc.
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 3 of the License, or
8 # (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program. If not, see <http://www.gnu.org/licenses/>.
18 # This program requires gdb and objcopy in addition to gcc.
19 # The default values are gdb from the build tree and objcopy from $PATH.
20 # They may be overridden by setting environment variables GDB and OBJCOPY
22 # We assume the current directory is either $obj/gdb or $obj/gdb/testsuite.
26 # bash$ cd $objdir/gdb/testsuite
28 # CC_FOR_TARGET="/bin/sh $srcdir/cc-with-index.sh gcc" \
29 # CXX_FOR_TARGET="/bin/sh $srcdir/cc-with-index.sh g++"
31 # For documentation on index files: info -f gdb.info -n "Index Files"
33 myname
=cc-with-index.sh
47 echo "$myname: unable to find usable gdb" >&2
52 OBJCOPY
=${OBJCOPY:-objcopy}
55 next_is_output_file
=no
60 if [ "$next_is_output_file" = "yes" ]
63 next_is_output_file
=no
67 # Poor man's gcc argument parser.
68 # We don't need to handle all arguments, we just need to know if we're
69 # doing a link and what the output file is.
70 # It's not perfect, but it seems to work well enough for the task at hand.
75 "-o") next_is_output_file
=yes ;;
79 if [ "$next_is_output_file" = "yes" ]
81 echo "$myname: Unable to find output file" >&2
85 if [ "$have_link" = "no" ]
91 index_file
="${output_file}.gdb-index"
92 if [ -f "$index_file" ]
94 echo "$myname: Index file $index_file exists, won't clobber." >&2
98 output_dir
="${output_file%/*}"
99 [ "$output_dir" = "$output_file" ] && output_dir
="."
103 [ $rc != 0 ] && exit $rc
104 if [ ! -f "$output_file" ]
106 echo "$myname: Internal error: $output_file missing." >&2
110 $GDB --batch-silent -nx -ex "set auto-load no" -ex "file $output_file" -ex "save gdb-index $output_dir"
112 [ $rc != 0 ] && exit $rc
114 # GDB might not always create an index. Cope.
115 if [ -f "$index_file" ]
117 $OBJCOPY --add-section .gdb_index
="$index_file" \
118 --set-section-flags .gdb_index
=readonly \
119 "$output_file" "$output_file"
This page took 0.031994 seconds and 4 git commands to generate.