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