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

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