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

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