Blame SOURCES/gdb-6.6-buildid-locate-misleading-warning-missing-debuginfo-rhbz981154.patch

b2f73e
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
b2f73e
From: Fedora GDB patches <invalid@email.com>
b2f73e
Date: Fri, 27 Oct 2017 21:07:50 +0200
b2f73e
Subject: 
b2f73e
 gdb-6.6-buildid-locate-misleading-warning-missing-debuginfo-rhbz981154.patch
b2f73e
b2f73e
;; Fix 'gdb gives highly misleading error when debuginfo pkg is present,
b2f73e
;; but not corresponding binary pkg' (RH BZ 981154).
b2f73e
;;=push+jan
b2f73e
b2f73e
Comments by Sergio Durigan Junior <sergiodj@redhat.com>:
b2f73e
b2f73e
  This is the fix for RH BZ #981154
b2f73e
b2f73e
  It is mainly a testcase addition, but a minor fix in the gdb/build-id.c
b2f73e
  file was also needed.
b2f73e
b2f73e
  gdb/build-id.c was added by:
b2f73e
b2f73e
  commit dc294be54c96414035eed7d53dafdea0a6f31a72
b2f73e
  Author: Tom Tromey <tromey@redhat.com>
b2f73e
  Date:   Tue Oct 8 19:56:15 2013 +0000
b2f73e
b2f73e
  and had a little thinko there.  The variable 'filename' needs to be set to
b2f73e
  NULL after it is free'd, otherwise the code below thinks that it is still
b2f73e
  valid and doesn't print the necessary warning ("Try: yum install ...").
b2f73e
b2f73e
diff --git a/gdb/testsuite/gdb.base/rhbz981154-misleading-yum-install-warning.exp b/gdb/testsuite/gdb.base/rhbz981154-misleading-yum-install-warning.exp
b2f73e
new file mode 100644
b2f73e
--- /dev/null
b2f73e
+++ b/gdb/testsuite/gdb.base/rhbz981154-misleading-yum-install-warning.exp
b2f73e
@@ -0,0 +1,97 @@
b2f73e
+#   Copyright (C) 2014  Free Software Foundation, Inc.
b2f73e
+
b2f73e
+# This program is free software; you can redistribute it and/or modify
b2f73e
+# it under the terms of the GNU General Public License as published by
b2f73e
+# the Free Software Foundation; either version 3 of the License, or
b2f73e
+# (at your option) any later version.
b2f73e
+#
b2f73e
+# This program is distributed in the hope that it will be useful,
b2f73e
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
b2f73e
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
b2f73e
+# GNU General Public License for more details.
b2f73e
+#
b2f73e
+# You should have received a copy of the GNU General Public License
b2f73e
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
b2f73e
+
b2f73e
+standard_testfile "normal.c"
b2f73e
+
b2f73e
+if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile}] } {
b2f73e
+    return -1
b2f73e
+}
b2f73e
+
b2f73e
+# Get the build-id of the file
b2f73e
+set build_id_debug_file [build_id_debug_filename_get $binfile]
b2f73e
+regsub -all ".debug$" $build_id_debug_file "" build_id_without_debug
b2f73e
+
b2f73e
+# Run to main
b2f73e
+if { ![runto_main] } {
b2f73e
+    return -1
b2f73e
+}
b2f73e
+
b2f73e
+# We first need to generate a corefile
b2f73e
+set escapedfilename [string_to_regexp [standard_output_file gcore.test]]
b2f73e
+set core_supported 0
b2f73e
+gdb_test_multiple "gcore [standard_output_file gcore.test]" \
b2f73e
+	"save a corefile" \
b2f73e
+{
b2f73e
+  -re "Saved corefile ${escapedfilename}\[\r\n\]+$gdb_prompt $" {
b2f73e
+    pass "save a corefile"
b2f73e
+    global core_supported
b2f73e
+    set core_supported 1
b2f73e
+  }
b2f73e
+  -re "Can't create a corefile\[\r\n\]+$gdb_prompt $" {
b2f73e
+    unsupported "save a corefile"
b2f73e
+    global core_supported
b2f73e
+    set core_supported 0
b2f73e
+  }
b2f73e
+}
b2f73e
+
b2f73e
+if {!$core_supported} {
b2f73e
+  return -1
b2f73e
+}
b2f73e
+
b2f73e
+# Move the binfile to a temporary name
b2f73e
+remote_exec build "mv $binfile ${binfile}.old"
b2f73e
+
b2f73e
+# Reinitialize GDB and see if we get a yum/dnf warning
b2f73e
+gdb_exit
b2f73e
+gdb_start
b2f73e
+gdb_reinitialize_dir $srcdir/$subdir
b2f73e
+
b2f73e
+with_test_prefix "first run:" {
b2f73e
+    gdb_test "set build-id-verbose 1" "" \
b2f73e
+	"set build-id-verbose"
b2f73e
+
b2f73e
+    gdb_test "set debug-file-directory [file dirname [standard_output_file gcore.test]]" "" \
b2f73e
+	"set debug-file-directory"
b2f73e
+
b2f73e
+    gdb_test "core-file [standard_output_file gcore.test]" \
b2f73e
+	"Missing separate debuginfo for the main executable file\r\nTry: (yum|dnf) --enablerepo='\\*debug\\*' install [standard_output_file $build_id_without_debug]\r\n.*" \
b2f73e
+	"test first yum/dnf warning"
b2f73e
+}
b2f73e
+
b2f73e
+# Now we define and create our .build-id
b2f73e
+file mkdir [file dirname [standard_output_file ${build_id_without_debug}]]
b2f73e
+# Cannot use "file link" (from TCL) because it requires the target file to
b2f73e
+# exist.
b2f73e
+remote_exec build "ln -s $binfile [standard_output_file ${build_id_without_debug}]"
b2f73e
+
b2f73e
+# Reinitialize GDB to get the second yum/dnf warning
b2f73e
+gdb_exit
b2f73e
+gdb_start
b2f73e
+gdb_reinitialize_dir $srcdir/$subdir
b2f73e
+
b2f73e
+with_test_prefix "second run:" {
b2f73e
+    gdb_test "set build-id-verbose 1" "" \
b2f73e
+	"set build-id-verbose"
b2f73e
+
b2f73e
+    gdb_test "set debug-file-directory [file dirname [standard_output_file gcore.test]]" "" \
b2f73e
+	"set debug-file-directory"
b2f73e
+
b2f73e
+    gdb_test "core-file [standard_output_file gcore.test]" \
b2f73e
+	"Missing separate debuginfo for the main executable file\r\nTry: (yum|dnf) --enablerepo='\\*debug\\*' install $binfile\r\n.*" \
b2f73e
+	"test second yum/dnf warning"
b2f73e
+}
b2f73e
+
b2f73e
+# Leaving the link there will cause breakage in the next run.
b2f73e
+remote_exec build "rm -f [standard_output_file ${build_id_without_debug}]"