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

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