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