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

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