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