diff --git a/_gdb.spec.Patch.include b/_gdb.spec.Patch.include index 13eb704..a514977 100644 --- a/_gdb.spec.Patch.include +++ b/_gdb.spec.Patch.include @@ -237,14 +237,19 @@ Patch056: gdb-container-rh-pkg.patch #=fedora Patch057: gdb-linux_perf-bundle.patch -# Fix gdb-headless /usr/bin/ executables (BZ 1390251). +# Update gdb-add-index.sh such that, when the GDB environment +# variable is not set, the script is smarter than just looking for +# 'gdb' in the $PATH. # -# Also, make /usr/bin/gdb.minimal be the default GDB used, if it's -# present. For rationale, see: +# The actual search order is now: /usr/bin/gdb.minimal, gdb (in the +# $PATH), then /usr/libexec/gdb. +# +# For the rationale of looking for gdb.minimal see: # # https://fedoraproject.org/wiki/Changes/Minimal_GDB_in_buildroot +# #=fedora -Patch058: gdb-libexec-add-index.patch +Patch058: gdb-add-index.patch # [s390x] Backport arch12 instructions decoding (RH BZ 1553104). # =fedoratest diff --git a/_patch_order b/_patch_order index 60e004b..9aa6157 100644 --- a/_patch_order +++ b/_patch_order @@ -55,7 +55,7 @@ gdb-opcodes-clflushopt-test.patch gdb-rhbz1261564-aarch64-hw-watchpoint-test.patch gdb-container-rh-pkg.patch gdb-linux_perf-bundle.patch -gdb-libexec-add-index.patch +gdb-add-index.patch gdb-rhbz1553104-s390x-arch12-test.patch gdb-rhbz2177655-aarch64-pauth-valid-regcache.patch gdb-rhbz2183595-rustc-inside_main.patch diff --git a/gdb-add-index.patch b/gdb-add-index.patch new file mode 100644 index 0000000..b95e06f --- /dev/null +++ b/gdb-add-index.patch @@ -0,0 +1,77 @@ +From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 +From: Fedora GDB patches +Date: Fri, 27 Oct 2017 21:07:50 +0200 +Subject: gdb-add-index.patch + +;; Update gdb-add-index.sh such that, when the GDB environment +;; variable is not set, the script is smarter than just looking for +;; 'gdb' in the $PATH. +;; +;; The actual search order is now: /usr/bin/gdb.minimal, gdb (in the +;; $PATH), then /usr/libexec/gdb. +;; +;; For the rationale of looking for gdb.minimal see: +;; +;; https://fedoraproject.org/wiki/Changes/Minimal_GDB_in_buildroot +;; +;;=fedora + +diff --git a/gdb/contrib/gdb-add-index.sh b/gdb/contrib/gdb-add-index.sh +--- a/gdb/contrib/gdb-add-index.sh ++++ b/gdb/contrib/gdb-add-index.sh +@@ -16,14 +16,52 @@ + # You should have received a copy of the GNU General Public License + # along with this program. If not, see . + +-# This program assumes gdb and objcopy are in $PATH. +-# If not, or you want others, pass the following in the environment +-GDB=${GDB:=gdb} ++# This program assumes objcopy and readelf are in $PATH. If not, or ++# you want others, pass the following in the environment + OBJCOPY=${OBJCOPY:=objcopy} + READELF=${READELF:=readelf} + + myname="${0##*/}" + ++# For GDB itself we need to be a little smarter. If GDB is set in the ++# environment then we will use that. But if GDB is not set in the ++# environment then we have a couple of options that we need to check ++# through. ++# ++# Our default choice is for /usr/bin/gdb.minimal. For an explanation ++# of why this is chosen, check out: ++# https://bugzilla.redhat.com/show_bug.cgi?id=1695015 ++# https://fedoraproject.org/wiki/Changes/Minimal_GDB_in_buildroot ++# ++# If gdb.minimal is not found then we look for a 'gdb' executable on ++# the path. ++# ++# And finally, we check for /usr/libexec/gdb. ++# ++# If none of those result in a useable GDB then we give an error and ++# exit. ++if test -z "$GDB"; then ++ for possible_gdb in /usr/bin/gdb.minimal gdb /usr/libexec/gdb; do ++ if ! which "$possible_gdb" 2>/dev/null; then ++ continue ++ fi ++ ++ possible_gdb=$(which "$possible_gdb") ++ ++ if ! test -x "$possible_gdb"; then ++ continue ++ fi ++ ++ GDB="$possible_gdb" ++ break ++ done ++ ++ if test -z "$GDB"; then ++ echo "$myname: Failed to find a useable GDB binary" 1>&2 ++ exit 1 ++ fi ++fi ++ + dwarf5="" + if [ "$1" = "-dwarf-5" ]; then + dwarf5="$1" diff --git a/gdb-libexec-add-index.patch b/gdb-libexec-add-index.patch deleted file mode 100644 index 19f6b54..0000000 --- a/gdb-libexec-add-index.patch +++ /dev/null @@ -1,37 +0,0 @@ -From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 -From: Fedora GDB patches -Date: Fri, 27 Oct 2017 21:07:50 +0200 -Subject: gdb-libexec-add-index.patch - -;; Fix gdb-headless /usr/bin/ executables (BZ 1390251). -;; -;; Also, make /usr/bin/gdb.minimal be the default GDB used, if it's -;; present. For rationale, see: -;; -;; https://fedoraproject.org/wiki/Changes/Minimal_GDB_in_buildroot -;;=fedora - -diff --git a/gdb/contrib/gdb-add-index.sh b/gdb/contrib/gdb-add-index.sh ---- a/gdb/contrib/gdb-add-index.sh -+++ b/gdb/contrib/gdb-add-index.sh -@@ -22,6 +22,20 @@ GDB=${GDB:=gdb} - OBJCOPY=${OBJCOPY:=objcopy} - READELF=${READELF:=readelf} - -+GDB2=/usr/libexec/gdb -+if test -x $GDB2 && ! which $GDB &>/dev/null; then -+ GDB=$GDB2 -+fi -+ -+# We default to using /usr/bin/gdb.minimal if it's present. See -+# https://bugzilla.redhat.com/show_bug.cgi?id=1695015 and -+# https://fedoraproject.org/wiki/Changes/Minimal_GDB_in_buildroot for -+# explanations. -+GDB3=/usr/bin/gdb.minimal -+if test -x $GDB3; then -+ GDB=$GDB3 -+fi -+ - myname="${0##*/}" - - dwarf5="" diff --git a/gdb.spec b/gdb.spec index 3fb8247..2d4e04c 100644 --- a/gdb.spec +++ b/gdb.spec @@ -1192,6 +1192,11 @@ fi %endif %changelog +* Thu May 4 2023 Andrew Burgess +- Rewrite the changes to gdb-add-index.sh. If the user has set the + GDB environment variable then use that value, otherwise find a + suitable GDB executable by looking in various places. + * Wed May 3 2023 Kevin Buettner - 13.1-4 - Backport "Pass const frame_info_ptr reference for skip_[language_]trampoline". (Mark Wielaard, RHBZ 2192105, build/30413)