Blame SOURCES/gdb-test-bt-cfi-without-die.patch

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