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

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