|
|
79b363 |
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
|
|
|
79b363 |
From: Fedora GDB patches <invalid@email.com>
|
|
|
79b363 |
Date: Fri, 27 Oct 2017 21:07:50 +0200
|
|
|
79b363 |
Subject: gdb-test-bt-cfi-without-die.patch
|
|
|
79b363 |
|
|
|
79b363 |
;; [delayed-symfile] Test a backtrace regression on CFIs without DIE (BZ 614604).
|
|
|
79b363 |
;;=fedoratest
|
|
|
79b363 |
|
|
|
79b363 |
http://sourceware.org/ml/archer/2010-q3/msg00028.html
|
|
|
79b363 |
|
|
|
79b363 |
On Wed, 25 Feb 2009 00:14:29 +0100, Jan Kratochvil wrote:
|
|
|
79b363 |
> commit 6a37c2b9962258ecf9299cc34a650e64a06acaa5
|
|
|
79b363 |
>
|
|
|
79b363 |
> There was a regression on gdb.base/savedregs.exp.
|
|
|
79b363 |
>
|
|
|
79b363 |
> quick_addrmap/require_partial_symbols should be used even for the unwind debug
|
|
|
79b363 |
> info checking as its load has been also delayed by this branch.
|
|
|
79b363 |
[...]
|
|
|
79b363 |
> --- a/gdb/dwarf2-frame.c
|
|
|
79b363 |
> +++ b/gdb/dwarf2-frame.c
|
|
|
79b363 |
[...]
|
|
|
79b363 |
> @@ -1499,6 +1500,14 @@ dwarf2_frame_find_fde (CORE_ADDR *pc)
|
|
|
79b363 |
> struct dwarf2_fde *fde;
|
|
|
79b363 |
> CORE_ADDR offset;
|
|
|
79b363 |
>
|
|
|
79b363 |
> + if (objfile->quick_addrmap)
|
|
|
79b363 |
> + {
|
|
|
79b363 |
> + if (!addrmap_find (objfile->quick_addrmap, *pc))
|
|
|
79b363 |
> + continue;
|
|
|
79b363 |
> + }
|
|
|
79b363 |
> + /* FIXME: Read-in only .debug_frame/.eh_frame without .debug_info? */
|
|
|
79b363 |
> + require_partial_symbols (objfile);
|
|
|
79b363 |
> +
|
|
|
79b363 |
|
|
|
79b363 |
but this has caused a different regression (as discussed in the confcall).
|
|
|
79b363 |
|
|
|
79b363 |
QUICK_ADDRMAP is built only from .debug_aranges. But we can have existing
|
|
|
79b363 |
built .debug_aranges for CUs in OBJFILE but still some CUs do not need to have
|
|
|
79b363 |
DWARF at all while they can feature CFIs (.eh_frame or .debug_frame).
|
|
|
79b363 |
It has been described by Daniel Jacobowitz at:
|
|
|
79b363 |
Re: [2/4] RFC: check psymtabs_addrmap before reading FDEs
|
|
|
79b363 |
http://sourceware.org/ml/gdb-patches/2010-07/msg00012.html
|
|
|
79b363 |
|
|
|
79b363 |
Sorry for this regression by me (in that fix of a different regression).
|
|
|
79b363 |
|
|
|
79b363 |
Fixed it the "slow way" as this branch is now obsoleted by .gdb-index.
|
|
|
79b363 |
|
|
|
79b363 |
No regressions on {x86_64,x86_64-m32,i686}-fedora13-linux-gnu.
|
|
|
79b363 |
|
|
|
79b363 |
Checked-in.
|
|
|
79b363 |
|
|
|
79b363 |
Thanks,
|
|
|
79b363 |
Jan
|
|
|
79b363 |
|
|
|
79b363 |
eb8df8566acc1ed963e3e9b77c13b9c2c3db03fb
|
|
|
79b363 |
|
|
|
79b363 |
Test CFI is parsed even for range (function) not described by any DIE.
|
|
|
79b363 |
|
|
|
79b363 |
https://bugzilla.redhat.com/show_bug.cgi?id=614028
|
|
|
79b363 |
|
|
|
79b363 |
gdb/
|
|
|
79b363 |
* dwarf2-frame.c (dwarf2_frame_find_fde): Remove the
|
|
|
79b363 |
OBJFILE->QUICK_ADDRMAP check. New comment why.
|
|
|
79b363 |
|
|
|
79b363 |
gdb/testsuite/
|
|
|
79b363 |
* gdb.base/cfi-without-die.exp, gdb.base/cfi-without-die-main.c,
|
|
|
79b363 |
gdb.base/cfi-without-die-caller.c: New files.
|
|
|
79b363 |
|
|
|
79b363 |
diff --git a/gdb/testsuite/gdb.base/cfi-without-die-caller.c b/gdb/testsuite/gdb.base/cfi-without-die-caller.c
|
|
|
79b363 |
new file mode 100644
|
|
|
79b363 |
--- /dev/null
|
|
|
79b363 |
+++ b/gdb/testsuite/gdb.base/cfi-without-die-caller.c
|
|
|
79b363 |
@@ -0,0 +1,28 @@
|
|
|
79b363 |
+/* This testcase is part of GDB, the GNU debugger.
|
|
|
79b363 |
+
|
|
|
79b363 |
+ Copyright 2005, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
|
|
|
79b363 |
+
|
|
|
79b363 |
+ This program is free software; you can redistribute it and/or modify
|
|
|
79b363 |
+ it under the terms of the GNU General Public License as published by
|
|
|
79b363 |
+ the Free Software Foundation; either version 3 of the License, or
|
|
|
79b363 |
+ (at your option) any later version.
|
|
|
79b363 |
+
|
|
|
79b363 |
+ This program is distributed in the hope that it will be useful,
|
|
|
79b363 |
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
79b363 |
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
79b363 |
+ GNU General Public License for more details.
|
|
|
79b363 |
+
|
|
|
79b363 |
+ You should have received a copy of the GNU General Public License
|
|
|
79b363 |
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
|
|
79b363 |
+
|
|
|
79b363 |
+typedef int (*callback_t) (void);
|
|
|
79b363 |
+
|
|
|
79b363 |
+int
|
|
|
79b363 |
+caller (callback_t callback)
|
|
|
79b363 |
+{
|
|
|
79b363 |
+ /* Ensure some frame content to push away the return address. */
|
|
|
79b363 |
+ volatile const long one = 1;
|
|
|
79b363 |
+
|
|
|
79b363 |
+ /* Modify the return value to prevent any tail-call optimization. */
|
|
|
79b363 |
+ return (*callback) () - one;
|
|
|
79b363 |
+}
|
|
|
79b363 |
diff --git a/gdb/testsuite/gdb.base/cfi-without-die-main.c b/gdb/testsuite/gdb.base/cfi-without-die-main.c
|
|
|
79b363 |
new file mode 100644
|
|
|
79b363 |
--- /dev/null
|
|
|
79b363 |
+++ b/gdb/testsuite/gdb.base/cfi-without-die-main.c
|
|
|
79b363 |
@@ -0,0 +1,32 @@
|
|
|
79b363 |
+/* This testcase is part of GDB, the GNU debugger.
|
|
|
79b363 |
+
|
|
|
79b363 |
+ Copyright 2005, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
|
|
|
79b363 |
+
|
|
|
79b363 |
+ This program is free software; you can redistribute it and/or modify
|
|
|
79b363 |
+ it under the terms of the GNU General Public License as published by
|
|
|
79b363 |
+ the Free Software Foundation; either version 3 of the License, or
|
|
|
79b363 |
+ (at your option) any later version.
|
|
|
79b363 |
+
|
|
|
79b363 |
+ This program is distributed in the hope that it will be useful,
|
|
|
79b363 |
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
79b363 |
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
79b363 |
+ GNU General Public License for more details.
|
|
|
79b363 |
+
|
|
|
79b363 |
+ You should have received a copy of the GNU General Public License
|
|
|
79b363 |
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
|
|
79b363 |
+
|
|
|
79b363 |
+typedef int (*callback_t) (void);
|
|
|
79b363 |
+
|
|
|
79b363 |
+extern int caller (callback_t callback);
|
|
|
79b363 |
+
|
|
|
79b363 |
+int
|
|
|
79b363 |
+callback (void)
|
|
|
79b363 |
+{
|
|
|
79b363 |
+ return 1;
|
|
|
79b363 |
+}
|
|
|
79b363 |
+
|
|
|
79b363 |
+int
|
|
|
79b363 |
+main (void)
|
|
|
79b363 |
+{
|
|
|
79b363 |
+ return caller (callback);
|
|
|
79b363 |
+}
|
|
|
79b363 |
diff --git a/gdb/testsuite/gdb.base/cfi-without-die.exp b/gdb/testsuite/gdb.base/cfi-without-die.exp
|
|
|
79b363 |
new file mode 100644
|
|
|
79b363 |
--- /dev/null
|
|
|
79b363 |
+++ b/gdb/testsuite/gdb.base/cfi-without-die.exp
|
|
|
79b363 |
@@ -0,0 +1,71 @@
|
|
|
79b363 |
+# Copyright 2010 Free Software Foundation, Inc.
|
|
|
79b363 |
+
|
|
|
79b363 |
+# This program is free software; you can redistribute it and/or modify
|
|
|
79b363 |
+# it under the terms of the GNU General Public License as published by
|
|
|
79b363 |
+# the Free Software Foundation; either version 3 of the License, or
|
|
|
79b363 |
+# (at your option) any later version.
|
|
|
79b363 |
+#
|
|
|
79b363 |
+# This program is distributed in the hope that it will be useful,
|
|
|
79b363 |
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
79b363 |
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
79b363 |
+# GNU General Public License for more details.
|
|
|
79b363 |
+#
|
|
|
79b363 |
+# You should have received a copy of the GNU General Public License
|
|
|
79b363 |
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
79b363 |
+
|
|
|
79b363 |
+# Test CFI is parsed even for range (function) not described by any DIE.
|
|
|
79b363 |
+
|
|
|
79b363 |
+set testfile cfi-without-die
|
|
|
79b363 |
+set srcmainfile ${testfile}-main.c
|
|
|
79b363 |
+set srccallerfile ${testfile}-caller.c
|
|
|
79b363 |
+set executable ${testfile}
|
|
|
79b363 |
+set objmainfile [standard_output_file ${testfile}-main.o]
|
|
|
79b363 |
+set objcallerfile [standard_output_file ${testfile}-caller.o]
|
|
|
79b363 |
+set binfile [standard_output_file ${executable}]
|
|
|
79b363 |
+
|
|
|
79b363 |
+if { [gdb_compile "${srcdir}/${subdir}/${srccallerfile}" ${objcallerfile} \
|
|
|
79b363 |
+ object [list {additional_flags=-fomit-frame-pointer -fno-unwind-tables -fno-asynchronous-unwind-tables}]] != ""
|
|
|
79b363 |
+ || [gdb_compile "${srcdir}/${subdir}/${srcmainfile}" ${objmainfile} object {debug}] != ""
|
|
|
79b363 |
+ || [gdb_compile "${objmainfile} ${objcallerfile}" ${binfile} executable {}] != "" } {
|
|
|
79b363 |
+ untested ${testfile}.exp
|
|
|
79b363 |
+ return -1
|
|
|
79b363 |
+}
|
|
|
79b363 |
+
|
|
|
79b363 |
+clean_restart $executable
|
|
|
79b363 |
+
|
|
|
79b363 |
+if ![runto callback] then {
|
|
|
79b363 |
+ fail "verify unwinding: Can't run to callback"
|
|
|
79b363 |
+ return 0
|
|
|
79b363 |
+}
|
|
|
79b363 |
+set test "verify unwinding breaks without CFI"
|
|
|
79b363 |
+gdb_test_multiple "bt" $test {
|
|
|
79b363 |
+ -re " in \[?\]\[?\] .*\r\n$gdb_prompt $" {
|
|
|
79b363 |
+ # It may backtrace through some random frames even to main().
|
|
|
79b363 |
+ pass $test
|
|
|
79b363 |
+ }
|
|
|
79b363 |
+ -re " in main .*\r\n$gdb_prompt $" {
|
|
|
79b363 |
+ fail $test
|
|
|
79b363 |
+ }
|
|
|
79b363 |
+ -re "\r\n$gdb_prompt $" {
|
|
|
79b363 |
+ pass $test
|
|
|
79b363 |
+ }
|
|
|
79b363 |
+}
|
|
|
79b363 |
+
|
|
|
79b363 |
+if { [gdb_compile "${srcdir}/${subdir}/${srccallerfile}" ${objcallerfile} \
|
|
|
79b363 |
+ object [list {additional_flags=-fomit-frame-pointer -funwind-tables -fasynchronous-unwind-tables}]] != ""
|
|
|
79b363 |
+ || [gdb_compile "${srcdir}/${subdir}/${srcmainfile}" ${objmainfile} object {debug}] != ""
|
|
|
79b363 |
+ || [gdb_compile "${objmainfile} ${objcallerfile}" ${binfile} executable {}] != "" } {
|
|
|
79b363 |
+ untested ${testfile}.exp
|
|
|
79b363 |
+ return -1
|
|
|
79b363 |
+}
|
|
|
79b363 |
+
|
|
|
79b363 |
+clean_restart $executable
|
|
|
79b363 |
+
|
|
|
79b363 |
+if ![runto callback] then {
|
|
|
79b363 |
+ fail "test CFI without DIEs: Can't run to callback"
|
|
|
79b363 |
+ return 0
|
|
|
79b363 |
+}
|
|
|
79b363 |
+# #0 callback () at ...
|
|
|
79b363 |
+# #1 0x00000000004004e9 in caller ()
|
|
|
79b363 |
+# #2 0x00000000004004cd in main () at ...
|
|
|
79b363 |
+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"
|