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

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