Skip to content

Commit 29164e2

Browse files
ivanivanov884jeffmahoney
authored andcommitted
gdb-test-bt-cfi-without-die.patch
;; [delayed-symfile] Test a backtrace regression on CFIs without DIE (BZ 614604). ;;=fedoratest http://sourceware.org/ml/archer/2010-q3/msg00028.html On Wed, 25 Feb 2009 00:14:29 +0100, Jan Kratochvil wrote: > commit 6a37c2b9962258ecf9299cc34a650e64a06acaa5 > > There was a regression on gdb.base/savedregs.exp. > > quick_addrmap/require_partial_symbols should be used even for the unwind debug > info checking as its load has been also delayed by this branch. [...] > --- a/gdb/dwarf2-frame.c > +++ b/gdb/dwarf2-frame.c [...] > @@ -1499,6 +1500,14 @@ dwarf2_frame_find_fde (CORE_ADDR *pc) > struct dwarf2_fde *fde; > CORE_ADDR offset; > > + if (objfile->quick_addrmap) > + { > + if (!addrmap_find (objfile->quick_addrmap, *pc)) > + continue; > + } > + /* FIXME: Read-in only .debug_frame/.eh_frame without .debug_info? */ > + require_partial_symbols (objfile); > + but this has caused a different regression (as discussed in the confcall). QUICK_ADDRMAP is built only from .debug_aranges. But we can have existing built .debug_aranges for CUs in OBJFILE but still some CUs do not need to have DWARF at all while they can feature CFIs (.eh_frame or .debug_frame). It has been described by Daniel Jacobowitz at: Re: [2/4] RFC: check psymtabs_addrmap before reading FDEs http://sourceware.org/ml/gdb-patches/2010-07/msg00012.html Sorry for this regression by me (in that fix of a different regression). Fixed it the "slow way" as this branch is now obsoleted by .gdb-index. No regressions on {x86_64,x86_64-m32,i686}-fedora13-linux-gnu. Checked-in. Thanks, Jan eb8df8566acc1ed963e3e9b77c13b9c2c3db03fb Test CFI is parsed even for range (function) not described by any DIE. https://bugzilla.redhat.com/show_bug.cgi?id=614028 gdb/ * dwarf2-frame.c (dwarf2_frame_find_fde): Remove the OBJFILE->QUICK_ADDRMAP check. New comment why. gdb/testsuite/ * gdb.base/cfi-without-die.exp, gdb.base/cfi-without-die-main.c, gdb.base/cfi-without-die-caller.c: New files.
1 parent 9a07169 commit 29164e2

File tree

3 files changed

+131
-0
lines changed

3 files changed

+131
-0
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/* This testcase is part of GDB, the GNU debugger.
2+
3+
Copyright 2005, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
4+
5+
This program is free software; you can redistribute it and/or modify
6+
it under the terms of the GNU General Public License as published by
7+
the Free Software Foundation; either version 3 of the License, or
8+
(at your option) any later version.
9+
10+
This program is distributed in the hope that it will be useful,
11+
but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
GNU General Public License for more details.
14+
15+
You should have received a copy of the GNU General Public License
16+
along with this program. If not, see <http://www.gnu.org/licenses/>. */
17+
18+
typedef int (*callback_t) (void);
19+
20+
int
21+
caller (callback_t callback)
22+
{
23+
/* Ensure some frame content to push away the return address. */
24+
volatile const long one = 1;
25+
26+
/* Modify the return value to prevent any tail-call optimization. */
27+
return (*callback) () - one;
28+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/* This testcase is part of GDB, the GNU debugger.
2+
3+
Copyright 2005, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
4+
5+
This program is free software; you can redistribute it and/or modify
6+
it under the terms of the GNU General Public License as published by
7+
the Free Software Foundation; either version 3 of the License, or
8+
(at your option) any later version.
9+
10+
This program is distributed in the hope that it will be useful,
11+
but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
GNU General Public License for more details.
14+
15+
You should have received a copy of the GNU General Public License
16+
along with this program. If not, see <http://www.gnu.org/licenses/>. */
17+
18+
typedef int (*callback_t) (void);
19+
20+
extern int caller (callback_t callback);
21+
22+
int
23+
callback (void)
24+
{
25+
return 1;
26+
}
27+
28+
int
29+
main (void)
30+
{
31+
return caller (callback);
32+
}
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
# Copyright 2010 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+
# Test CFI is parsed even for range (function) not described by any DIE.
17+
18+
set testfile cfi-without-die
19+
set srcmainfile ${testfile}-main.c
20+
set srccallerfile ${testfile}-caller.c
21+
set executable ${testfile}
22+
set objmainfile [standard_output_file ${testfile}-main.o]
23+
set objcallerfile [standard_output_file ${testfile}-caller.o]
24+
set binfile [standard_output_file ${executable}]
25+
26+
if { [gdb_compile "${srcdir}/${subdir}/${srccallerfile}" ${objcallerfile} \
27+
object [list {additional_flags=-fomit-frame-pointer -fno-unwind-tables -fno-asynchronous-unwind-tables}]] != ""
28+
|| [gdb_compile "${srcdir}/${subdir}/${srcmainfile}" ${objmainfile} object {debug}] != ""
29+
|| [gdb_compile "${objmainfile} ${objcallerfile}" ${binfile} executable {}] != "" } {
30+
untested ${testfile}.exp
31+
return -1
32+
}
33+
34+
clean_restart $executable
35+
36+
if ![runto callback] then {
37+
fail "verify unwinding: Can't run to callback"
38+
return 0
39+
}
40+
set test "verify unwinding breaks without CFI"
41+
gdb_test_multiple "bt" $test {
42+
-re " in \[?\]\[?\] .*\r\n$gdb_prompt $" {
43+
# It may backtrace through some random frames even to main().
44+
pass $test
45+
}
46+
-re " in main .*\r\n$gdb_prompt $" {
47+
fail $test
48+
}
49+
-re "\r\n$gdb_prompt $" {
50+
pass $test
51+
}
52+
}
53+
54+
if { [gdb_compile "${srcdir}/${subdir}/${srccallerfile}" ${objcallerfile} \
55+
object [list {additional_flags=-fomit-frame-pointer -funwind-tables -fasynchronous-unwind-tables}]] != ""
56+
|| [gdb_compile "${srcdir}/${subdir}/${srcmainfile}" ${objmainfile} object {debug}] != ""
57+
|| [gdb_compile "${objmainfile} ${objcallerfile}" ${binfile} executable {}] != "" } {
58+
untested ${testfile}.exp
59+
return -1
60+
}
61+
62+
clean_restart $executable
63+
64+
if ![runto callback] then {
65+
fail "test CFI without DIEs: Can't run to callback"
66+
return 0
67+
}
68+
# #0 callback () at ...
69+
# #1 0x00000000004004e9 in caller ()
70+
# #2 0x00000000004004cd in main () at ...
71+
gdb_test "bt" "#0 +callback \[^\r\n\]+\r\n#1 \[^\r\n\]+ in caller \[^\r\n\]+\r\n#2 \[^\r\n\]+ in main \[^\r\n\]+" "verify unwindin works for CFI without DIEs"

0 commit comments

Comments
 (0)