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

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