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

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