Skip to content

Commit 1722b79

Browse files
ivanivanov884jeffmahoney
authored andcommitted
gdb-6.6-buildid-locate-misleading-warning-missing-debuginfo-rhbz981154.patch
;; Fix 'gdb gives highly misleading error when debuginfo pkg is present, ;; but not corresponding binary pkg' (RH BZ 981154). ;;=push+jan Comments by Sergio Durigan Junior <[email protected]>: 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 dc294be Author: Tom Tromey <[email protected]> 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 ...").
1 parent 2c8c283 commit 1722b79

File tree

2 files changed

+101
-1
lines changed

2 files changed

+101
-1
lines changed

gdb/build-id.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -581,7 +581,10 @@ build_id_to_debug_bfd (size_t build_id_len, const bfd_byte *build_id,
581581
do_cleanups (inner);
582582

583583
if (abfd == NULL)
584-
continue;
584+
{
585+
filename = NULL;
586+
continue;
587+
}
585588

586589
if (build_id_verify (abfd.get(), build_id_len, build_id))
587590
break;
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
# Copyright (C) 2014 Free Software Foundation, Inc.
2+
3+
# This program is free software; you can redistribute it and/or modify
4+
# it under the terms of the GNU General Public License as published by
5+
# the Free Software Foundation; either version 3 of the License, or
6+
# (at your option) any later version.
7+
#
8+
# This program is distributed in the hope that it will be useful,
9+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+
# GNU General Public License for more details.
12+
#
13+
# You should have received a copy of the GNU General Public License
14+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
15+
16+
standard_testfile "normal.c"
17+
18+
if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile}] } {
19+
return -1
20+
}
21+
22+
# Get the build-id of the file
23+
set build_id_debug_file [build_id_debug_filename_get $binfile]
24+
regsub -all ".debug$" $build_id_debug_file "" build_id_without_debug
25+
26+
# Run to main
27+
if { ![runto_main] } {
28+
return -1
29+
}
30+
31+
# We first need to generate a corefile
32+
set escapedfilename [string_to_regexp [standard_output_file gcore.test]]
33+
set core_supported 0
34+
gdb_test_multiple "gcore [standard_output_file gcore.test]" \
35+
"save a corefile" \
36+
{
37+
-re "Saved corefile ${escapedfilename}\[\r\n\]+$gdb_prompt $" {
38+
pass "save a corefile"
39+
global core_supported
40+
set core_supported 1
41+
}
42+
-re "Can't create a corefile\[\r\n\]+$gdb_prompt $" {
43+
unsupported "save a corefile"
44+
global core_supported
45+
set core_supported 0
46+
}
47+
}
48+
49+
if {!$core_supported} {
50+
return -1
51+
}
52+
53+
# Move the binfile to a temporary name
54+
remote_exec build "mv $binfile ${binfile}.old"
55+
56+
# Reinitialize GDB and see if we get a yum/dnf warning
57+
gdb_exit
58+
gdb_start
59+
gdb_reinitialize_dir $srcdir/$subdir
60+
61+
with_test_prefix "first run:" {
62+
gdb_test "set build-id-verbose 1" "" \
63+
"set build-id-verbose"
64+
65+
gdb_test "set debug-file-directory [file dirname [standard_output_file gcore.test]]" "" \
66+
"set debug-file-directory"
67+
68+
gdb_test "core-file [standard_output_file gcore.test]" \
69+
"Missing separate debuginfo for the main executable file\r\nTry: (yum|dnf) --enablerepo='\\*debug\\*' install [standard_output_file $build_id_without_debug]\r\n.*" \
70+
"test first yum/dnf warning"
71+
}
72+
73+
# Now we define and create our .build-id
74+
file mkdir [file dirname [standard_output_file ${build_id_without_debug}]]
75+
# Cannot use "file link" (from TCL) because it requires the target file to
76+
# exist.
77+
remote_exec build "ln -s $binfile [standard_output_file ${build_id_without_debug}]"
78+
79+
# Reinitialize GDB to get the second yum/dnf warning
80+
gdb_exit
81+
gdb_start
82+
gdb_reinitialize_dir $srcdir/$subdir
83+
84+
with_test_prefix "second run:" {
85+
gdb_test "set build-id-verbose 1" "" \
86+
"set build-id-verbose"
87+
88+
gdb_test "set debug-file-directory [file dirname [standard_output_file gcore.test]]" "" \
89+
"set debug-file-directory"
90+
91+
gdb_test "core-file [standard_output_file gcore.test]" \
92+
"Missing separate debuginfo for the main executable file\r\nTry: (yum|dnf) --enablerepo='\\*debug\\*' install $binfile\r\n.*" \
93+
"test second yum/dnf warning"
94+
}
95+
96+
# Leaving the link there will cause breakage in the next run.
97+
remote_exec build "rm -f [standard_output_file ${build_id_without_debug}]"

0 commit comments

Comments
 (0)