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

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