2017-12-09 06:44:10 +08:00
|
|
|
#!/usr/bin/env bash
|
2012-07-19 04:04:44 +08:00
|
|
|
# Wrapper around gcc to tweak the output in various ways when running
|
|
|
|
# the testsuite.
|
2010-10-05 12:28:15 +08:00
|
|
|
|
2020-01-01 14:20:01 +08:00
|
|
|
# Copyright (C) 2010-2020 Free Software Foundation, Inc.
|
2010-10-05 12:28:15 +08:00
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation; either version 3 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
# This program requires gdb and objcopy in addition to gcc.
|
2011-06-08 08:15:54 +08:00
|
|
|
# The default values are gdb from the build tree and objcopy from $PATH.
|
|
|
|
# They may be overridden by setting environment variables GDB and OBJCOPY
|
2012-09-14 16:03:34 +08:00
|
|
|
# respectively. Note that GDB should contain the gdb binary as well as the
|
|
|
|
# -data-directory flag, e.g., "foo/gdb -data-directory foo/data-directory".
|
2010-10-05 12:28:15 +08:00
|
|
|
# We assume the current directory is either $obj/gdb or $obj/gdb/testsuite.
|
|
|
|
#
|
|
|
|
# Example usage:
|
|
|
|
#
|
|
|
|
# bash$ cd $objdir/gdb/testsuite
|
|
|
|
# bash$ runtest \
|
2017-12-09 06:44:10 +08:00
|
|
|
# CC_FOR_TARGET="/bin/bash $srcdir/gdb/contrib/cc-with-tweaks.sh ARGS gcc" \
|
|
|
|
# CXX_FOR_TARGET="/bin/bash $srcdir/gdb/contrib/cc-with-tweaks.sh ARGS g++"
|
2010-10-05 12:28:15 +08:00
|
|
|
#
|
2013-01-17 06:02:16 +08:00
|
|
|
# For documentation on Fission and dwp files:
|
|
|
|
# http://gcc.gnu.org/wiki/DebugFission
|
|
|
|
# http://gcc.gnu.org/wiki/DebugFissionDWP
|
2010-10-05 12:28:15 +08:00
|
|
|
# For documentation on index files: info -f gdb.info -n "Index Files"
|
2012-07-19 04:04:44 +08:00
|
|
|
# For information about 'dwz', see the announcement:
|
|
|
|
# http://gcc.gnu.org/ml/gcc/2012-04/msg00686.html
|
|
|
|
# (More documentation is to come.)
|
2010-10-05 12:28:15 +08:00
|
|
|
|
2012-07-19 04:04:44 +08:00
|
|
|
# ARGS determine what is done. They can be:
|
2012-11-09 03:52:42 +08:00
|
|
|
# -Z invoke objcopy --compress-debug-sections
|
2012-07-19 04:04:44 +08:00
|
|
|
# -z compress using dwz
|
|
|
|
# -m compress using dwz -m
|
2019-05-04 16:11:53 +08:00
|
|
|
# -i make an index (.gdb_index)
|
|
|
|
# -n make a dwarf5 index (.debug_names)
|
2013-02-16 04:30:16 +08:00
|
|
|
# -p create .dwp files (Fission), you need to also use gcc option -gsplit-dwarf
|
2012-07-19 04:04:44 +08:00
|
|
|
# If nothing is given, no changes are made
|
|
|
|
|
|
|
|
myname=cc-with-tweaks.sh
|
2017-12-09 06:44:10 +08:00
|
|
|
mydir=`dirname "$0"`
|
2010-10-05 12:28:15 +08:00
|
|
|
|
|
|
|
if [ -z "$GDB" ]
|
|
|
|
then
|
|
|
|
if [ -f ./gdb ]
|
|
|
|
then
|
2012-09-14 16:03:34 +08:00
|
|
|
GDB="./gdb -data-directory data-directory"
|
2010-10-05 12:28:15 +08:00
|
|
|
elif [ -f ../gdb ]
|
|
|
|
then
|
2012-09-14 16:03:34 +08:00
|
|
|
GDB="../gdb -data-directory ../data-directory"
|
2011-06-08 09:40:58 +08:00
|
|
|
elif [ -f ../../gdb ]
|
|
|
|
then
|
2012-09-14 16:03:34 +08:00
|
|
|
GDB="../../gdb -data-directory ../../data-directory"
|
2010-10-05 12:28:15 +08:00
|
|
|
else
|
|
|
|
echo "$myname: unable to find usable gdb" >&2
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
OBJCOPY=${OBJCOPY:-objcopy}
|
2012-11-05 23:50:22 +08:00
|
|
|
READELF=${READELF:-readelf}
|
2010-10-05 12:28:15 +08:00
|
|
|
|
2012-07-19 04:04:44 +08:00
|
|
|
DWZ=${DWZ:-dwz}
|
2012-11-05 23:50:22 +08:00
|
|
|
DWP=${DWP:-dwp}
|
2012-07-19 04:04:44 +08:00
|
|
|
|
2010-10-05 12:28:15 +08:00
|
|
|
have_link=unknown
|
|
|
|
next_is_output_file=no
|
2010-10-08 03:34:52 +08:00
|
|
|
output_file=a.out
|
2010-10-05 12:28:15 +08:00
|
|
|
|
2012-07-19 04:04:44 +08:00
|
|
|
want_index=false
|
2019-05-04 16:11:53 +08:00
|
|
|
index_options=""
|
2012-07-19 04:04:44 +08:00
|
|
|
want_dwz=false
|
|
|
|
want_multi=false
|
2012-11-05 23:50:22 +08:00
|
|
|
want_dwp=false
|
2012-11-09 03:52:42 +08:00
|
|
|
want_objcopy_compress=false
|
2012-07-19 04:04:44 +08:00
|
|
|
|
|
|
|
while [ $# -gt 0 ]; do
|
|
|
|
case "$1" in
|
2012-11-09 03:52:42 +08:00
|
|
|
-Z) want_objcopy_compress=true ;;
|
2012-07-19 04:04:44 +08:00
|
|
|
-z) want_dwz=true ;;
|
|
|
|
-i) want_index=true ;;
|
2019-05-04 16:11:53 +08:00
|
|
|
-n) want_index=true; index_options=-dwarf-5;;
|
2012-07-19 04:04:44 +08:00
|
|
|
-m) want_multi=true ;;
|
2012-11-05 23:50:22 +08:00
|
|
|
-p) want_dwp=true ;;
|
2012-07-19 04:04:44 +08:00
|
|
|
*) break ;;
|
|
|
|
esac
|
|
|
|
shift
|
|
|
|
done
|
|
|
|
|
2017-12-09 06:44:10 +08:00
|
|
|
if [ "$want_index" = true ]
|
|
|
|
then
|
|
|
|
if [ -z "$GDB_ADD_INDEX" ]
|
|
|
|
then
|
|
|
|
if [ -f $mydir/gdb-add-index.sh ]
|
|
|
|
then
|
|
|
|
GDB_ADD_INDEX="$mydir/gdb-add-index.sh"
|
|
|
|
else
|
|
|
|
echo "$myname: unable to find usable contrib/gdb-add-index.sh" >&2
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2010-10-05 12:28:15 +08:00
|
|
|
for arg in "$@"
|
|
|
|
do
|
|
|
|
if [ "$next_is_output_file" = "yes" ]
|
|
|
|
then
|
|
|
|
output_file="$arg"
|
|
|
|
next_is_output_file=no
|
|
|
|
continue
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Poor man's gcc argument parser.
|
|
|
|
# We don't need to handle all arguments, we just need to know if we're
|
|
|
|
# doing a link and what the output file is.
|
|
|
|
# It's not perfect, but it seems to work well enough for the task at hand.
|
|
|
|
case "$arg" in
|
|
|
|
"-c") have_link=no ;;
|
|
|
|
"-E") have_link=no ;;
|
|
|
|
"-S") have_link=no ;;
|
|
|
|
"-o") next_is_output_file=yes ;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
|
|
|
if [ "$next_is_output_file" = "yes" ]
|
|
|
|
then
|
|
|
|
echo "$myname: Unable to find output file" >&2
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "$have_link" = "no" ]
|
|
|
|
then
|
|
|
|
"$@"
|
|
|
|
exit $?
|
|
|
|
fi
|
|
|
|
|
|
|
|
output_dir="${output_file%/*}"
|
|
|
|
[ "$output_dir" = "$output_file" ] && output_dir="."
|
|
|
|
|
|
|
|
"$@"
|
|
|
|
rc=$?
|
|
|
|
[ $rc != 0 ] && exit $rc
|
|
|
|
if [ ! -f "$output_file" ]
|
|
|
|
then
|
|
|
|
echo "$myname: Internal error: $output_file missing." >&2
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2019-09-30 05:58:21 +08:00
|
|
|
get_tmpdir ()
|
|
|
|
{
|
|
|
|
tmpdir=$(dirname "$output_file")/.tmp
|
|
|
|
mkdir -p "$tmpdir"
|
|
|
|
}
|
|
|
|
|
2012-11-09 03:52:42 +08:00
|
|
|
if [ "$want_objcopy_compress" = true ]; then
|
|
|
|
$OBJCOPY --compress-debug-sections "$output_file"
|
|
|
|
rc=$?
|
|
|
|
[ $rc != 0 ] && exit $rc
|
|
|
|
fi
|
|
|
|
|
2012-07-19 04:04:44 +08:00
|
|
|
if [ "$want_index" = true ]; then
|
[gdb/contrib] Use temp dir for gdb-add-index in cc-with-tweaks.sh
When running test-case gdb.dwarf2/gdb-index.exp cleanly by issuing this
command:
...
$ rm -Rf build/gdb/testsuite/outputs/gdb.dwarf2/gdb-index
...
before running, it passes both with native and target board
cc-with-gdb-index.
But when we run the test-case first with native and then with
cc-with-gdb-index without intermediate cleanup, we get instead:
...
Running src/gdb/testsuite/gdb.dwarf2/gdb-index.exp ...
gdb compile failed, cc-with-tweaks.sh: Index file \
build/gdb/testsuite/outputs/gdb.dwarf2/gdb-index/gdb-index.gdb-index \
exists, won't clobber.
=== gdb Summary ===
# of untested testcases 1
...
What happens is that the native run produces a file
build/gdb/testsuite/outputs/gdb.dwarf2/gdb-index/gdb-index.gdb-index, which
causes gdb/contrib/cc-with-tweaks.sh to hit this code:
...
index_file="${output_file}.gdb-index"
if [ "$want_index" = true ] && [ -f "$index_file" ]
then
echo "$myname: Index file $index_file exists, won't clobber." >&2
exit 1
fi
...
The gdb-add-index script has a problem that it uses temp files alongside the
executable, filed as PR25843.
The code in cc-with-tweaks.sh attempts to detect the case that creating such a
temp file would overwrite an pre-existing file. It however does this only for
a single file, while gdb-add-index uses more temporary files:
- <exec>.gdb-index
- <exec>.debug_names
- <exec>.debug_str
- <exec>.debug_str.merge
- <exec>.debug_str.err
Fix this by working around PR25843 in a more generic way:
- move the executable into a temp directory
- execute gdb-add-index, allowing it to create any temp file alongside the
executable in the temp directory
- move the executable back to the original location
Tested on x86_64-linux, with target board cc-with-debug-index.
gdb/ChangeLog:
2020-04-24 Tom de Vries <tdevries@suse.de>
* contrib/cc-with-tweaks.sh: Remove <exec>.gdb-index file handling.
Run gdb-add-index inside temp dir.
2020-04-24 17:31:06 +08:00
|
|
|
get_tmpdir
|
|
|
|
mv "$output_file" "$tmpdir"
|
|
|
|
tmpfile="$tmpdir/$(basename $output_file)"
|
2017-12-09 06:44:10 +08:00
|
|
|
# Filter out these messages which would stop dejagnu testcase run:
|
|
|
|
# echo "$myname: No index was created for $file" 1>&2
|
|
|
|
# echo "$myname: [Was there no debuginfo? Was there already an index?]" 1>&2
|
[gdb/contrib] Use temp dir for gdb-add-index in cc-with-tweaks.sh
When running test-case gdb.dwarf2/gdb-index.exp cleanly by issuing this
command:
...
$ rm -Rf build/gdb/testsuite/outputs/gdb.dwarf2/gdb-index
...
before running, it passes both with native and target board
cc-with-gdb-index.
But when we run the test-case first with native and then with
cc-with-gdb-index without intermediate cleanup, we get instead:
...
Running src/gdb/testsuite/gdb.dwarf2/gdb-index.exp ...
gdb compile failed, cc-with-tweaks.sh: Index file \
build/gdb/testsuite/outputs/gdb.dwarf2/gdb-index/gdb-index.gdb-index \
exists, won't clobber.
=== gdb Summary ===
# of untested testcases 1
...
What happens is that the native run produces a file
build/gdb/testsuite/outputs/gdb.dwarf2/gdb-index/gdb-index.gdb-index, which
causes gdb/contrib/cc-with-tweaks.sh to hit this code:
...
index_file="${output_file}.gdb-index"
if [ "$want_index" = true ] && [ -f "$index_file" ]
then
echo "$myname: Index file $index_file exists, won't clobber." >&2
exit 1
fi
...
The gdb-add-index script has a problem that it uses temp files alongside the
executable, filed as PR25843.
The code in cc-with-tweaks.sh attempts to detect the case that creating such a
temp file would overwrite an pre-existing file. It however does this only for
a single file, while gdb-add-index uses more temporary files:
- <exec>.gdb-index
- <exec>.debug_names
- <exec>.debug_str
- <exec>.debug_str.merge
- <exec>.debug_str.err
Fix this by working around PR25843 in a more generic way:
- move the executable into a temp directory
- execute gdb-add-index, allowing it to create any temp file alongside the
executable in the temp directory
- move the executable back to the original location
Tested on x86_64-linux, with target board cc-with-debug-index.
gdb/ChangeLog:
2020-04-24 Tom de Vries <tdevries@suse.de>
* contrib/cc-with-tweaks.sh: Remove <exec>.gdb-index file handling.
Run gdb-add-index inside temp dir.
2020-04-24 17:31:06 +08:00
|
|
|
GDB=$GDB $GDB_ADD_INDEX $index_options "$tmpfile" 2>&1 \
|
2019-05-04 16:11:53 +08:00
|
|
|
| grep -v "^${GDB_ADD_INDEX##*/}: " >&2
|
2017-12-09 06:44:10 +08:00
|
|
|
rc=${PIPESTATUS[0]}
|
[gdb/contrib] Use temp dir for gdb-add-index in cc-with-tweaks.sh
When running test-case gdb.dwarf2/gdb-index.exp cleanly by issuing this
command:
...
$ rm -Rf build/gdb/testsuite/outputs/gdb.dwarf2/gdb-index
...
before running, it passes both with native and target board
cc-with-gdb-index.
But when we run the test-case first with native and then with
cc-with-gdb-index without intermediate cleanup, we get instead:
...
Running src/gdb/testsuite/gdb.dwarf2/gdb-index.exp ...
gdb compile failed, cc-with-tweaks.sh: Index file \
build/gdb/testsuite/outputs/gdb.dwarf2/gdb-index/gdb-index.gdb-index \
exists, won't clobber.
=== gdb Summary ===
# of untested testcases 1
...
What happens is that the native run produces a file
build/gdb/testsuite/outputs/gdb.dwarf2/gdb-index/gdb-index.gdb-index, which
causes gdb/contrib/cc-with-tweaks.sh to hit this code:
...
index_file="${output_file}.gdb-index"
if [ "$want_index" = true ] && [ -f "$index_file" ]
then
echo "$myname: Index file $index_file exists, won't clobber." >&2
exit 1
fi
...
The gdb-add-index script has a problem that it uses temp files alongside the
executable, filed as PR25843.
The code in cc-with-tweaks.sh attempts to detect the case that creating such a
temp file would overwrite an pre-existing file. It however does this only for
a single file, while gdb-add-index uses more temporary files:
- <exec>.gdb-index
- <exec>.debug_names
- <exec>.debug_str
- <exec>.debug_str.merge
- <exec>.debug_str.err
Fix this by working around PR25843 in a more generic way:
- move the executable into a temp directory
- execute gdb-add-index, allowing it to create any temp file alongside the
executable in the temp directory
- move the executable back to the original location
Tested on x86_64-linux, with target board cc-with-debug-index.
gdb/ChangeLog:
2020-04-24 Tom de Vries <tdevries@suse.de>
* contrib/cc-with-tweaks.sh: Remove <exec>.gdb-index file handling.
Run gdb-add-index inside temp dir.
2020-04-24 17:31:06 +08:00
|
|
|
mv "$tmpfile" "$output_file"
|
2012-07-19 04:04:44 +08:00
|
|
|
[ $rc != 0 ] && exit $rc
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "$want_dwz" = true ]; then
|
cc-with-tweaks: show dwz stderr and verify result
When running the gdb.base/index-cache.exp test case with the
cc-with-dwz-m board, I noticed that the final executable didn't actually
contain a .gnu_debugaltlink section with the name of the external dwz
file:
$ readelf --debug-dump=links testsuite/outputs/gdb.base/index-cache/index-cache
* empty *
Running dwz by hand, I realized it's because dwz complains that the
output .debug_info section is empty and fails:
$ gcc ~/src/binutils-gdb/gdb/testsuite/gdb.base/index-cache.c -g3 -O0 -o a && cp a b
$ dwz -m foo a b
dwz: foo: .debug_info section not present
$ echo $?
1
This is because index-cache.c is trivial (just an empty main) and dwz
doesn't find anything to factor out to the dwz file. [1]
I think that cc-with-tweaks should fail in this scenario: if the user
asks for an external dwz file to be generated (the -m flag), then it
should be an error if cc-with-tweaks doesn't manage to produce an
executable with the proper link to this external dwz file. Otherwise,
the test runs with a regular non-dwzified executable, which gives a
false sense of security about whether the feature under test works with
dwzified executables.
So this patch adds checks for that after invoking dwz. It also removes
the 2>&1 to allow the error message to be printed like so:
Running /home/smarchi/src/binutils-gdb/gdb/testsuite/gdb.base/index-cache.exp ...
gdb compile failed, dwz: /home/smarchi/build/binutils-gdb/gdb/testsuite/outputs/gdb.base/index-cache/index-cache.dwz: .debug_info section not present
- In the -m case (multi-file compression), we check if the expected output file
exists.
- In the -z case (single-file compression), we check if the file
contents has changed. This should catch cases where dwz doesn't modify the
file because it's not worth it.
It was chosen not to check for dwz's exit code, as it is not very
reliable up to dwz 0.12.
With this patch, fewer tests will pass than before with the
cc-with-dwz and cc-with-dwz-m boards, but those were false positives
anyway, as the test ran with regular executables.
[1] Note that dwz has been patched by Tom de Vries to work correctly in
this case, so we can use dwz master to run the test:
https://sourceware.org/git/?p=dwz.git;a=commit;h=08becc8b33453b6d013a65e7eeae57fc1881e801
gdb/ChangeLog:
* contrib/cc-with-tweaks.sh: Validate dwz's work.
2019-05-11 04:29:00 +08:00
|
|
|
# Validate dwz's result by checking if the executable was modified.
|
|
|
|
cp "$output_file" "${output_file}.copy"
|
|
|
|
$DWZ "$output_file" > /dev/null
|
|
|
|
cmp "$output_file" "$output_file.copy" > /dev/null
|
|
|
|
cmp_rc=$?
|
|
|
|
rm -f "${output_file}.copy"
|
|
|
|
|
|
|
|
case $cmp_rc in
|
|
|
|
0)
|
|
|
|
echo "$myname: dwz did not modify ${output_file}."
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
1)
|
|
|
|
# File was modified, great.
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
# Other cmp error, it presumably has already printed something on
|
|
|
|
# stderr.
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
2012-07-19 04:04:44 +08:00
|
|
|
elif [ "$want_multi" = true ]; then
|
2019-09-30 05:58:21 +08:00
|
|
|
get_tmpdir
|
|
|
|
dwz_file=$tmpdir/$(basename "$output_file").dwz
|
cc-with-tweaks: show dwz stderr and verify result
When running the gdb.base/index-cache.exp test case with the
cc-with-dwz-m board, I noticed that the final executable didn't actually
contain a .gnu_debugaltlink section with the name of the external dwz
file:
$ readelf --debug-dump=links testsuite/outputs/gdb.base/index-cache/index-cache
* empty *
Running dwz by hand, I realized it's because dwz complains that the
output .debug_info section is empty and fails:
$ gcc ~/src/binutils-gdb/gdb/testsuite/gdb.base/index-cache.c -g3 -O0 -o a && cp a b
$ dwz -m foo a b
dwz: foo: .debug_info section not present
$ echo $?
1
This is because index-cache.c is trivial (just an empty main) and dwz
doesn't find anything to factor out to the dwz file. [1]
I think that cc-with-tweaks should fail in this scenario: if the user
asks for an external dwz file to be generated (the -m flag), then it
should be an error if cc-with-tweaks doesn't manage to produce an
executable with the proper link to this external dwz file. Otherwise,
the test runs with a regular non-dwzified executable, which gives a
false sense of security about whether the feature under test works with
dwzified executables.
So this patch adds checks for that after invoking dwz. It also removes
the 2>&1 to allow the error message to be printed like so:
Running /home/smarchi/src/binutils-gdb/gdb/testsuite/gdb.base/index-cache.exp ...
gdb compile failed, dwz: /home/smarchi/build/binutils-gdb/gdb/testsuite/outputs/gdb.base/index-cache/index-cache.dwz: .debug_info section not present
- In the -m case (multi-file compression), we check if the expected output file
exists.
- In the -z case (single-file compression), we check if the file
contents has changed. This should catch cases where dwz doesn't modify the
file because it's not worth it.
It was chosen not to check for dwz's exit code, as it is not very
reliable up to dwz 0.12.
With this patch, fewer tests will pass than before with the
cc-with-dwz and cc-with-dwz-m boards, but those were false positives
anyway, as the test ran with regular executables.
[1] Note that dwz has been patched by Tom de Vries to work correctly in
this case, so we can use dwz master to run the test:
https://sourceware.org/git/?p=dwz.git;a=commit;h=08becc8b33453b6d013a65e7eeae57fc1881e801
gdb/ChangeLog:
* contrib/cc-with-tweaks.sh: Validate dwz's work.
2019-05-11 04:29:00 +08:00
|
|
|
# Remove the dwz output file if it exists, so we don't mistake it for a
|
|
|
|
# new file in case dwz fails.
|
2019-09-30 05:58:21 +08:00
|
|
|
rm -f "$dwz_file"
|
cc-with-tweaks: show dwz stderr and verify result
When running the gdb.base/index-cache.exp test case with the
cc-with-dwz-m board, I noticed that the final executable didn't actually
contain a .gnu_debugaltlink section with the name of the external dwz
file:
$ readelf --debug-dump=links testsuite/outputs/gdb.base/index-cache/index-cache
* empty *
Running dwz by hand, I realized it's because dwz complains that the
output .debug_info section is empty and fails:
$ gcc ~/src/binutils-gdb/gdb/testsuite/gdb.base/index-cache.c -g3 -O0 -o a && cp a b
$ dwz -m foo a b
dwz: foo: .debug_info section not present
$ echo $?
1
This is because index-cache.c is trivial (just an empty main) and dwz
doesn't find anything to factor out to the dwz file. [1]
I think that cc-with-tweaks should fail in this scenario: if the user
asks for an external dwz file to be generated (the -m flag), then it
should be an error if cc-with-tweaks doesn't manage to produce an
executable with the proper link to this external dwz file. Otherwise,
the test runs with a regular non-dwzified executable, which gives a
false sense of security about whether the feature under test works with
dwzified executables.
So this patch adds checks for that after invoking dwz. It also removes
the 2>&1 to allow the error message to be printed like so:
Running /home/smarchi/src/binutils-gdb/gdb/testsuite/gdb.base/index-cache.exp ...
gdb compile failed, dwz: /home/smarchi/build/binutils-gdb/gdb/testsuite/outputs/gdb.base/index-cache/index-cache.dwz: .debug_info section not present
- In the -m case (multi-file compression), we check if the expected output file
exists.
- In the -z case (single-file compression), we check if the file
contents has changed. This should catch cases where dwz doesn't modify the
file because it's not worth it.
It was chosen not to check for dwz's exit code, as it is not very
reliable up to dwz 0.12.
With this patch, fewer tests will pass than before with the
cc-with-dwz and cc-with-dwz-m boards, but those were false positives
anyway, as the test ran with regular executables.
[1] Note that dwz has been patched by Tom de Vries to work correctly in
this case, so we can use dwz master to run the test:
https://sourceware.org/git/?p=dwz.git;a=commit;h=08becc8b33453b6d013a65e7eeae57fc1881e801
gdb/ChangeLog:
* contrib/cc-with-tweaks.sh: Validate dwz's work.
2019-05-11 04:29:00 +08:00
|
|
|
|
2012-07-19 04:04:44 +08:00
|
|
|
cp $output_file ${output_file}.alt
|
2019-09-30 05:58:21 +08:00
|
|
|
$DWZ -m "$dwz_file" "$output_file" ${output_file}.alt > /dev/null
|
2019-04-23 21:35:21 +08:00
|
|
|
rm -f ${output_file}.alt
|
cc-with-tweaks: show dwz stderr and verify result
When running the gdb.base/index-cache.exp test case with the
cc-with-dwz-m board, I noticed that the final executable didn't actually
contain a .gnu_debugaltlink section with the name of the external dwz
file:
$ readelf --debug-dump=links testsuite/outputs/gdb.base/index-cache/index-cache
* empty *
Running dwz by hand, I realized it's because dwz complains that the
output .debug_info section is empty and fails:
$ gcc ~/src/binutils-gdb/gdb/testsuite/gdb.base/index-cache.c -g3 -O0 -o a && cp a b
$ dwz -m foo a b
dwz: foo: .debug_info section not present
$ echo $?
1
This is because index-cache.c is trivial (just an empty main) and dwz
doesn't find anything to factor out to the dwz file. [1]
I think that cc-with-tweaks should fail in this scenario: if the user
asks for an external dwz file to be generated (the -m flag), then it
should be an error if cc-with-tweaks doesn't manage to produce an
executable with the proper link to this external dwz file. Otherwise,
the test runs with a regular non-dwzified executable, which gives a
false sense of security about whether the feature under test works with
dwzified executables.
So this patch adds checks for that after invoking dwz. It also removes
the 2>&1 to allow the error message to be printed like so:
Running /home/smarchi/src/binutils-gdb/gdb/testsuite/gdb.base/index-cache.exp ...
gdb compile failed, dwz: /home/smarchi/build/binutils-gdb/gdb/testsuite/outputs/gdb.base/index-cache/index-cache.dwz: .debug_info section not present
- In the -m case (multi-file compression), we check if the expected output file
exists.
- In the -z case (single-file compression), we check if the file
contents has changed. This should catch cases where dwz doesn't modify the
file because it's not worth it.
It was chosen not to check for dwz's exit code, as it is not very
reliable up to dwz 0.12.
With this patch, fewer tests will pass than before with the
cc-with-dwz and cc-with-dwz-m boards, but those were false positives
anyway, as the test ran with regular executables.
[1] Note that dwz has been patched by Tom de Vries to work correctly in
this case, so we can use dwz master to run the test:
https://sourceware.org/git/?p=dwz.git;a=commit;h=08becc8b33453b6d013a65e7eeae57fc1881e801
gdb/ChangeLog:
* contrib/cc-with-tweaks.sh: Validate dwz's work.
2019-05-11 04:29:00 +08:00
|
|
|
|
|
|
|
# Validate dwz's work by checking if the expected output file exists.
|
2019-09-30 05:58:21 +08:00
|
|
|
if [ ! -f "$dwz_file" ]; then
|
|
|
|
echo "$myname: dwz file $dwz_file missing."
|
cc-with-tweaks: show dwz stderr and verify result
When running the gdb.base/index-cache.exp test case with the
cc-with-dwz-m board, I noticed that the final executable didn't actually
contain a .gnu_debugaltlink section with the name of the external dwz
file:
$ readelf --debug-dump=links testsuite/outputs/gdb.base/index-cache/index-cache
* empty *
Running dwz by hand, I realized it's because dwz complains that the
output .debug_info section is empty and fails:
$ gcc ~/src/binutils-gdb/gdb/testsuite/gdb.base/index-cache.c -g3 -O0 -o a && cp a b
$ dwz -m foo a b
dwz: foo: .debug_info section not present
$ echo $?
1
This is because index-cache.c is trivial (just an empty main) and dwz
doesn't find anything to factor out to the dwz file. [1]
I think that cc-with-tweaks should fail in this scenario: if the user
asks for an external dwz file to be generated (the -m flag), then it
should be an error if cc-with-tweaks doesn't manage to produce an
executable with the proper link to this external dwz file. Otherwise,
the test runs with a regular non-dwzified executable, which gives a
false sense of security about whether the feature under test works with
dwzified executables.
So this patch adds checks for that after invoking dwz. It also removes
the 2>&1 to allow the error message to be printed like so:
Running /home/smarchi/src/binutils-gdb/gdb/testsuite/gdb.base/index-cache.exp ...
gdb compile failed, dwz: /home/smarchi/build/binutils-gdb/gdb/testsuite/outputs/gdb.base/index-cache/index-cache.dwz: .debug_info section not present
- In the -m case (multi-file compression), we check if the expected output file
exists.
- In the -z case (single-file compression), we check if the file
contents has changed. This should catch cases where dwz doesn't modify the
file because it's not worth it.
It was chosen not to check for dwz's exit code, as it is not very
reliable up to dwz 0.12.
With this patch, fewer tests will pass than before with the
cc-with-dwz and cc-with-dwz-m boards, but those were false positives
anyway, as the test ran with regular executables.
[1] Note that dwz has been patched by Tom de Vries to work correctly in
this case, so we can use dwz master to run the test:
https://sourceware.org/git/?p=dwz.git;a=commit;h=08becc8b33453b6d013a65e7eeae57fc1881e801
gdb/ChangeLog:
* contrib/cc-with-tweaks.sh: Validate dwz's work.
2019-05-11 04:29:00 +08:00
|
|
|
exit 1
|
|
|
|
fi
|
2010-10-05 12:28:15 +08:00
|
|
|
fi
|
|
|
|
|
2012-11-05 23:50:22 +08:00
|
|
|
if [ "$want_dwp" = true ]; then
|
|
|
|
dwo_files=$($READELF -wi "${output_file}" | grep _dwo_name | \
|
|
|
|
sed -e 's/^.*: //' | sort | uniq)
|
2013-05-24 08:30:24 +08:00
|
|
|
rc=0
|
|
|
|
if [ -n "$dwo_files" ]; then
|
|
|
|
$DWP -o "${output_file}.dwp" ${dwo_files} > /dev/null
|
|
|
|
rc=$?
|
|
|
|
[ $rc != 0 ] && exit $rc
|
|
|
|
rm -f ${dwo_files}
|
|
|
|
fi
|
2012-11-05 23:50:22 +08:00
|
|
|
fi
|
|
|
|
|
2010-10-05 12:28:15 +08:00
|
|
|
exit $rc
|