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

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