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

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