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

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