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

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