2017-12-10 22:00:49 +00:00
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
2017-12-04 19:24:00 +00:00
From: Fedora GDB patches <invalid@email.com>
Date: Fri, 27 Oct 2017 21:07:50 +0200
2017-12-08 04:31:26 +00:00
Subject:
gdb-6.6-buildid-locate-misleading-warning-missing-debuginfo-rhbz981154.patch
2017-12-04 19:24:00 +00:00
FileName: gdb-6.6-buildid-locate-misleading-warning-missing-debuginfo-rhbz981154.patch
2017-12-08 04:31:26 +00:00
;; Fix 'gdb gives highly misleading error when debuginfo pkg is present,
;; but not corresponding binary pkg' (RH BZ 981154).
;;=push+jan
2014-04-24 20:31:03 +00:00
Comments by Sergio Durigan Junior <sergiodj@redhat.com>:
This is the fix for RH BZ #981154
It is mainly a testcase addition, but a minor fix in the gdb/build-id.c
file was also needed.
gdb/build-id.c was added by:
commit dc294be54c96414035eed7d53dafdea0a6f31a72
Author: Tom Tromey <tromey@redhat.com>
Date: Tue Oct 8 19:56:15 2013 +0000
and had a little thinko there. The variable 'filename' needs to be set to
NULL after it is free'd, otherwise the code below thinks that it is still
valid and doesn't print the necessary warning ("Try: yum install ...").
2017-12-08 04:31:26 +00:00
diff --git a/gdb/build-id.c b/gdb/build-id.c
2018-01-10 19:21:10 +00:00
index 409a5b8c54..e2c1e81266 100644
2017-12-08 04:31:26 +00:00
--- a/gdb/build-id.c
+++ b/gdb/build-id.c
@@ -592,7 +592,10 @@ build_id_to_debug_bfd (size_t build_id_len, const bfd_byte *build_id,
do_cleanups (inner);
if (abfd == NULL)
- continue;
+ {
+ filename = NULL;
+ continue;
+ }
if (build_id_verify (abfd.get(), build_id_len, build_id))
break;
diff --git a/gdb/testsuite/gdb.base/rhbz981154-misleading-yum-install-warning.exp b/gdb/testsuite/gdb.base/rhbz981154-misleading-yum-install-warning.exp
new file mode 100644
--- /dev/null
+++ b/gdb/testsuite/gdb.base/rhbz981154-misleading-yum-install-warning.exp
2014-05-05 21:44:10 +00:00
@@ -0,0 +1,97 @@
2014-04-24 20:31:03 +00:00
+# Copyright (C) 2014 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+standard_testfile "normal.c"
+
+if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile}] } {
+ return -1
+}
+
+# Get the build-id of the file
+set build_id_debug_file [build_id_debug_filename_get $binfile]
+regsub -all ".debug$" $build_id_debug_file "" build_id_without_debug
+
+# Run to main
+if { ![runto_main] } {
+ return -1
+}
+
+# We first need to generate a corefile
2016-02-16 09:54:56 +00:00
+set escapedfilename [string_to_regexp [standard_output_file gcore.test]]
2014-04-24 20:31:03 +00:00
+set core_supported 0
2016-02-16 09:54:56 +00:00
+gdb_test_multiple "gcore [standard_output_file gcore.test]" \
2014-04-24 20:31:03 +00:00
+ "save a corefile" \
+{
+ -re "Saved corefile ${escapedfilename}\[\r\n\]+$gdb_prompt $" {
+ pass "save a corefile"
+ global core_supported
+ set core_supported 1
+ }
+ -re "Can't create a corefile\[\r\n\]+$gdb_prompt $" {
+ unsupported "save a corefile"
+ global core_supported
+ set core_supported 0
+ }
+}
+
+if {!$core_supported} {
+ return -1
+}
+
+# Move the binfile to a temporary name
+remote_exec build "mv $binfile ${binfile}.old"
+
2015-08-01 18:12:51 +00:00
+# Reinitialize GDB and see if we get a yum/dnf warning
2014-04-24 20:31:03 +00:00
+gdb_exit
+gdb_start
+gdb_reinitialize_dir $srcdir/$subdir
+
2014-05-05 21:44:10 +00:00
+with_test_prefix "first run:" {
+ gdb_test "set build-id-verbose 1" "" \
+ "set build-id-verbose"
2014-04-24 20:31:03 +00:00
+
2016-02-16 09:54:56 +00:00
+ gdb_test "set debug-file-directory [file dirname [standard_output_file gcore.test]]" "" \
2014-05-05 21:44:10 +00:00
+ "set debug-file-directory"
2014-04-24 20:31:03 +00:00
+
2016-02-16 09:54:56 +00:00
+ gdb_test "core-file [standard_output_file gcore.test]" \
+ "Missing separate debuginfo for the main executable file\r\nTry: (yum|dnf) --enablerepo='\\*debug\\*' install [standard_output_file $build_id_without_debug]\r\n.*" \
2015-08-01 18:12:51 +00:00
+ "test first yum/dnf warning"
2014-05-05 21:44:10 +00:00
+}
2014-04-24 20:31:03 +00:00
+
+# Now we define and create our .build-id
2016-02-16 09:54:56 +00:00
+file mkdir [file dirname [standard_output_file ${build_id_without_debug}]]
2014-04-24 20:31:03 +00:00
+# Cannot use "file link" (from TCL) because it requires the target file to
+# exist.
2016-02-16 09:54:56 +00:00
+remote_exec build "ln -s $binfile [standard_output_file ${build_id_without_debug}]"
2014-04-24 20:31:03 +00:00
+
2015-08-01 18:12:51 +00:00
+# Reinitialize GDB to get the second yum/dnf warning
2014-04-24 20:31:03 +00:00
+gdb_exit
+gdb_start
+gdb_reinitialize_dir $srcdir/$subdir
+
2014-05-05 21:44:10 +00:00
+with_test_prefix "second run:" {
+ gdb_test "set build-id-verbose 1" "" \
+ "set build-id-verbose"
2014-04-24 20:31:03 +00:00
+
2016-02-16 09:54:56 +00:00
+ gdb_test "set debug-file-directory [file dirname [standard_output_file gcore.test]]" "" \
2014-05-05 21:44:10 +00:00
+ "set debug-file-directory"
2014-04-24 20:31:03 +00:00
+
2016-02-16 09:54:56 +00:00
+ gdb_test "core-file [standard_output_file gcore.test]" \
2015-08-01 18:12:51 +00:00
+ "Missing separate debuginfo for the main executable file\r\nTry: (yum|dnf) --enablerepo='\\*debug\\*' install $binfile\r\n.*" \
+ "test second yum/dnf warning"
2014-05-05 21:44:10 +00:00
+}
2014-04-24 20:31:03 +00:00
+
+# Leaving the link there will cause breakage in the next run.
2016-02-16 09:54:56 +00:00
+remote_exec build "rm -f [standard_output_file ${build_id_without_debug}]"