]> git.pld-linux.org Git - packages/gdb.git/blame - gdb-test-bt-cfi-without-die.patch
- typo
[packages/gdb.git] / gdb-test-bt-cfi-without-die.patch
CommitLineData
6ed6bacf
AM
1http://sourceware.org/ml/archer/2010-q3/msg00028.html
2Subject: [delayed-symfile] [commit] Fix a regression on CFI without DIE [Re:
3
4On Wed, 25 Feb 2009 00:14:29 +0100, Jan Kratochvil wrote:
5> commit 6a37c2b9962258ecf9299cc34a650e64a06acaa5
6>
7> There was a regression on gdb.base/savedregs.exp.
8>
9> quick_addrmap/require_partial_symbols should be used even for the unwind debug
10> info checking as its load has been also delayed by this branch.
11[...]
12> --- a/gdb/dwarf2-frame.c
13> +++ b/gdb/dwarf2-frame.c
14[...]
15> @@ -1499,6 +1500,14 @@ dwarf2_frame_find_fde (CORE_ADDR *pc)
16> struct dwarf2_fde *fde;
17> CORE_ADDR offset;
18>
19> + if (objfile->quick_addrmap)
20> + {
21> + if (!addrmap_find (objfile->quick_addrmap, *pc))
22> + continue;
23> + }
24> + /* FIXME: Read-in only .debug_frame/.eh_frame without .debug_info? */
25> + require_partial_symbols (objfile);
26> +
27
28but this has caused a different regression (as discussed in the confcall).
29
30QUICK_ADDRMAP is built only from .debug_aranges. But we can have existing
31built .debug_aranges for CUs in OBJFILE but still some CUs do not need to have
32DWARF at all while they can feature CFIs (.eh_frame or .debug_frame).
33It has been described by Daniel Jacobowitz at:
34 Re: [2/4] RFC: check psymtabs_addrmap before reading FDEs
35 http://sourceware.org/ml/gdb-patches/2010-07/msg00012.html
36
37Sorry for this regression by me (in that fix of a different regression).
38
39Fixed it the "slow way" as this branch is now obsoleted by .gdb-index.
40
41No regressions on {x86_64,x86_64-m32,i686}-fedora13-linux-gnu.
42
43Checked-in.
44
45
46Thanks,
47Jan
48
49
50eb8df8566acc1ed963e3e9b77c13b9c2c3db03fb
51
52Test CFI is parsed even for range (function) not described by any DIE.
53
54https://bugzilla.redhat.com/show_bug.cgi?id=614028
55
56gdb/
57 * dwarf2-frame.c (dwarf2_frame_find_fde): Remove the
58 OBJFILE->QUICK_ADDRMAP check. New comment why.
59
60gdb/testsuite/
61 * gdb.base/cfi-without-die.exp, gdb.base/cfi-without-die-main.c,
62 gdb.base/cfi-without-die-caller.c: New files.
63---
64 gdb/dwarf2-frame.c | 8 +--
65 gdb/testsuite/gdb.base/cfi-without-die-caller.c | 28 ++++++++++
66 gdb/testsuite/gdb.base/cfi-without-die-main.c | 32 +++++++++++
67 gdb/testsuite/gdb.base/cfi-without-die.exp | 67 +++++++++++++++++++++++
68 4 files changed, 130 insertions(+), 5 deletions(-)
69 create mode 100644 gdb/testsuite/gdb.base/cfi-without-die-caller.c
70 create mode 100644 gdb/testsuite/gdb.base/cfi-without-die-main.c
71 create mode 100644 gdb/testsuite/gdb.base/cfi-without-die.exp
72
73diff --git a/gdb/testsuite/gdb.base/cfi-without-die-caller.c b/gdb/testsuite/gdb.base/cfi-without-die-caller.c
74new file mode 100644
75index 0000000..afdfd53
76--- /dev/null
77+++ b/gdb/testsuite/gdb.base/cfi-without-die-caller.c
78@@ -0,0 +1,28 @@
79+/* This testcase is part of GDB, the GNU debugger.
80+
81+ Copyright 2005, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
82+
83+ This program is free software; you can redistribute it and/or modify
84+ it under the terms of the GNU General Public License as published by
85+ the Free Software Foundation; either version 3 of the License, or
86+ (at your option) any later version.
87+
88+ This program is distributed in the hope that it will be useful,
89+ but WITHOUT ANY WARRANTY; without even the implied warranty of
90+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
91+ GNU General Public License for more details.
92+
93+ You should have received a copy of the GNU General Public License
94+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
95+
96+typedef int (*callback_t) (void);
97+
98+int
99+caller (callback_t callback)
100+{
101+ /* Ensure some frame content to push away the return address. */
102+ volatile const long one = 1;
103+
104+ /* Modify the return value to prevent any tail-call optimization. */
105+ return (*callback) () - one;
106+}
107diff --git a/gdb/testsuite/gdb.base/cfi-without-die-main.c b/gdb/testsuite/gdb.base/cfi-without-die-main.c
108new file mode 100644
109index 0000000..8451c4b
110--- /dev/null
111+++ b/gdb/testsuite/gdb.base/cfi-without-die-main.c
112@@ -0,0 +1,32 @@
113+/* This testcase is part of GDB, the GNU debugger.
114+
115+ Copyright 2005, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
116+
117+ This program is free software; you can redistribute it and/or modify
118+ it under the terms of the GNU General Public License as published by
119+ the Free Software Foundation; either version 3 of the License, or
120+ (at your option) any later version.
121+
122+ This program is distributed in the hope that it will be useful,
123+ but WITHOUT ANY WARRANTY; without even the implied warranty of
124+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
125+ GNU General Public License for more details.
126+
127+ You should have received a copy of the GNU General Public License
128+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
129+
130+typedef int (*callback_t) (void);
131+
132+extern int caller (callback_t callback);
133+
134+int
135+callback (void)
136+{
137+ return 1;
138+}
139+
140+int
141+main (void)
142+{
143+ return caller (callback);
144+}
145diff --git a/gdb/testsuite/gdb.base/cfi-without-die.exp b/gdb/testsuite/gdb.base/cfi-without-die.exp
146new file mode 100644
147index 0000000..db6d248
148--- /dev/null
149+++ b/gdb/testsuite/gdb.base/cfi-without-die.exp
150@@ -0,0 +1,67 @@
151+# Copyright 2010 Free Software Foundation, Inc.
152+
153+# This program is free software; you can redistribute it and/or modify
154+# it under the terms of the GNU General Public License as published by
155+# the Free Software Foundation; either version 3 of the License, or
156+# (at your option) any later version.
157+#
158+# This program is distributed in the hope that it will be useful,
159+# but WITHOUT ANY WARRANTY; without even the implied warranty of
160+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
161+# GNU General Public License for more details.
162+#
163+# You should have received a copy of the GNU General Public License
164+# along with this program. If not, see <http://www.gnu.org/licenses/>.
165+
166+# Test CFI is parsed even for range (function) not described by any DIE.
167+
168+set testfile cfi-without-die
169+set srcmainfile ${testfile}-main.c
170+set srccallerfile ${testfile}-caller.c
171+set executable ${testfile}
172+set objmainfile ${objdir}/${subdir}/${testfile}-main.o
173+set objcallerfile ${objdir}/${subdir}/${testfile}-caller.o
174+set binfile ${objdir}/${subdir}/${executable}
175+
176+if { [gdb_compile "${srcdir}/${subdir}/${srccallerfile}" ${objcallerfile} \
177+ object [list {additional_flags=-fomit-frame-pointer -fno-unwind-tables -fno-asynchronous-unwind-tables}]] != ""
178+ || [gdb_compile "${srcdir}/${subdir}/${srcmainfile}" ${objmainfile} object {debug}] != ""
179+ || [gdb_compile "${objmainfile} ${objcallerfile}" ${binfile} executable {}] != "" } {
180+ untested ${testfile}.exp
181+ return -1
182+}
183+
184+clean_restart $executable
185+
186+if ![runto callback] then {
187+ fail "verify unwinding: Can't run to callback"
188+ return 0
189+}
190+set test "verify unwinding breaks without CFI"
191+gdb_test_multiple "bt" $test {
192+ -re " in main .*\r\n$gdb_prompt $" {
193+ fail $test
194+ }
195+ -re "\r\n$gdb_prompt $" {
196+ pass $test
197+ }
198+}
199+
200+if { [gdb_compile "${srcdir}/${subdir}/${srccallerfile}" ${objcallerfile} \
201+ object [list {additional_flags=-fomit-frame-pointer -funwind-tables -fasynchronous-unwind-tables}]] != ""
202+ || [gdb_compile "${srcdir}/${subdir}/${srcmainfile}" ${objmainfile} object {debug}] != ""
203+ || [gdb_compile "${objmainfile} ${objcallerfile}" ${binfile} executable {}] != "" } {
204+ untested ${testfile}.exp
205+ return -1
206+}
207+
208+clean_restart $executable
209+
210+if ![runto callback] then {
211+ fail "test CFI without DIEs: Can't run to callback"
212+ return 0
213+}
214+# #0 callback () at ...
215+# #1 0x00000000004004e9 in caller ()
216+# #2 0x00000000004004cd in main () at ...
217+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"
218--
2191.7.1.1
220
This page took 2.274277 seconds and 4 git commands to generate.