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

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