aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
authorTom de Vries <tdevries@suse.de>2021-05-21 18:11:12 +0200
committerTom de Vries <tdevries@suse.de>2021-05-21 18:11:12 +0200
commit778ae9ccc892c95132bb52067ea09bc363878f5f (patch)
tree97df231b199fef31948488c0e41abec4d65ea963 /gdb
parentca43e66033ca0d72bb93837c9b1ab482977e06e6 (diff)
downloadfsf-binutils-gdb-778ae9ccc892c95132bb52067ea09bc363878f5f.zip
fsf-binutils-gdb-778ae9ccc892c95132bb52067ea09bc363878f5f.tar.gz
fsf-binutils-gdb-778ae9ccc892c95132bb52067ea09bc363878f5f.tar.bz2
[gdb/testsuite] Add target board cc-with-gnu-debuglink.exp
Add target board cc-with-gnu-debuglink.exp that splits off debuginfo into a seperate .debug file and links to it using .gnu_debuglink. Tested on x86_64-linux. gdb/ChangeLog: 2021-05-21 Tom de Vries <tdevries@suse.de> PR testsuite/25047 * contrib/cc-with-tweaks.sh: Handle -l. gdb/testsuite/ChangeLog: 2021-05-21 Tom de Vries <tdevries@suse.de> PR testsuite/25047 * boards/cc-with-gnu-debuglink.exp: New file.
Diffstat (limited to 'gdb')
-rw-r--r--gdb/ChangeLog5
-rwxr-xr-xgdb/contrib/cc-with-tweaks.sh46
-rw-r--r--gdb/testsuite/ChangeLog5
-rw-r--r--gdb/testsuite/boards/cc-with-gnu-debuglink.exp26
4 files changed, 81 insertions, 1 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index f579a15..f15bd05 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,10 @@
2021-05-21 Tom de Vries <tdevries@suse.de>
+ PR testsuite/25047
+ * contrib/cc-with-tweaks.sh: Handle -l.
+
+2021-05-21 Tom de Vries <tdevries@suse.de>
+
PR breakpoint/27889
* jit.c (jit_breakpoint_re_set_internal): Skip separate debug
objects. Call get_jiter_objfile_data with the_objfile.
diff --git a/gdb/contrib/cc-with-tweaks.sh b/gdb/contrib/cc-with-tweaks.sh
index 2eda76a..8653dfb 100755
--- a/gdb/contrib/cc-with-tweaks.sh
+++ b/gdb/contrib/cc-with-tweaks.sh
@@ -45,6 +45,7 @@
# -i make an index (.gdb_index)
# -n make a dwarf5 index (.debug_names)
# -p create .dwp files (Fission), you need to also use gcc option -gsplit-dwarf
+# -l creates separate debuginfo files linked to using .gnu_debuglink
# If nothing is given, no changes are made
myname=cc-with-tweaks.sh
@@ -83,6 +84,7 @@ want_dwz=false
want_multi=false
want_dwp=false
want_objcopy_compress=false
+want_gnu_debuglink=false
while [ $# -gt 0 ]; do
case "$1" in
@@ -92,6 +94,7 @@ while [ $# -gt 0 ]; do
-n) want_index=true; index_options=-dwarf-5;;
-m) want_multi=true ;;
-p) want_dwp=true ;;
+ -l) want_gnu_debuglink=true ;;
*) break ;;
esac
shift
@@ -158,7 +161,12 @@ fi
get_tmpdir ()
{
- tmpdir=$(dirname "$output_file")/.tmp
+ subdir="$1"
+ if [ "$subdir" = "" ]; then
+ subdir=.tmp
+ fi
+
+ tmpdir=$(dirname "$output_file")/"$subdir"
mkdir -p "$tmpdir"
}
@@ -234,4 +242,40 @@ if [ "$want_dwp" = true ]; then
fi
fi
+if [ "$want_gnu_debuglink" = true ]; then
+ # Based on gdb_gnu_strip_debug.
+
+ # Gdb looks for the .gnu_debuglink file in the .debug subdirectory
+ # of the directory of the executable.
+ get_tmpdir .debug
+
+ stripped_file="$tmpdir"/$(basename "$output_file").stripped
+ debug_file="$tmpdir"/$(basename "$output_file").debug
+
+ # Create stripped and debug versions of output_file.
+ strip --strip-debug "${output_file}" \
+ -o "${stripped_file}"
+ rc=$?
+ [ $rc != 0 ] && exit $rc
+ strip --only-keep-debug "${output_file}" \
+ -o "${debug_file}"
+ rc=$?
+ [ $rc != 0 ] && exit $rc
+
+ # The .gnu_debuglink is supposed to contain no leading directories.
+ link=$(basename "${debug_file}")
+
+ (
+ # Temporarily cd to tmpdir to allow objcopy to find $link
+ cd "$tmpdir" || exit 1
+
+ # Overwrite output_file with stripped version containing
+ # .gnu_debuglink to debug_file.
+ objcopy --add-gnu-debuglink="$link" "${stripped_file}" \
+ "${output_file}"
+ rc=$?
+ [ $rc != 0 ] && exit $rc
+ )
+fi
+
exit $rc
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index 4a3f53b..df1ba09 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2021-05-21 Tom de Vries <tdevries@suse.de>
+
+ PR testsuite/25047
+ * boards/cc-with-gnu-debuglink.exp: New file.
+
2021-05-21 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com>
* gdb.dwarf2/dw2-inline-with-lexical-scope.c (func): Replace
diff --git a/gdb/testsuite/boards/cc-with-gnu-debuglink.exp b/gdb/testsuite/boards/cc-with-gnu-debuglink.exp
new file mode 100644
index 0000000..ca977d9
--- /dev/null
+++ b/gdb/testsuite/boards/cc-with-gnu-debuglink.exp
@@ -0,0 +1,26 @@
+# Copyright 2021 Free Software Foundation, Inc.
+
+# 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 file is a dejagnu "board file" and is used to run the testsuite
+# with contrib/cc-with-tweaks.sh -l.
+#
+# Example usage:
+# bash$ cd $objdir
+# bash$ make check-gdb \
+# RUNTESTFLAGS='--target_board=cc-with-gnu-debuglink'
+#
+
+set CC_WITH_TWEAKS_FLAGS "-l"
+load_board_description "cc-with-tweaks"