gdb/gdb-6.5-bz140532-ppc-debug_frame-return_address-test.patch
Jan Kratochvil 2a21fb50ae - Fix a race during attaching to dying threads; backport (BZ 209445).
- Testcase of unwinding has now marked its unsolvable cases (for BZ
    140532).
- Resolves: rhbz#209445
- Related: rhbz#140532
2007-02-05 08:28:49 +00:00

154 lines
5.0 KiB
Diff

2007-01-13 Jan Kratochvil <jan.kratochvil@redhat.com>
* gdb.base/bt-ppc.c, gdb.base/bt-ppc.exp: New files.
diff -u -rupN gdb-6.5-ppc/gdb/testsuite/gdb.base/bt-ppc.c gdb-6.5/gdb/testsuite/gdb.base/bt-ppc.c
--- gdb-6.5-ppc/gdb/testsuite/gdb.base/bt-ppc.c 1969-12-31 19:00:00.000000000 -0500
+++ gdb-6.5/gdb/testsuite/gdb.base/bt-ppc.c 2007-01-12 21:34:55.000000000 -0500
@@ -0,0 +1,41 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+ Copyright 2007 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#include <stdlib.h>
+
+/* Force `-fpie' double jump bl->blrl. */
+volatile int var;
+
+int func0 (void) __attribute__((__noinline__));
+int func0 (void)
+{
+ abort ();
+ return var;
+}
+
+int func1 (void) __attribute__((__noinline__));
+int func1 (void)
+{
+ return func0 () + var;
+}
+
+int main (void)
+{
+ func1 ();
+ return 0;
+}
diff -u -rupN gdb-6.5-ppc/gdb/testsuite/gdb.base/bt-ppc.exp gdb-6.5/gdb/testsuite/gdb.base/bt-ppc.exp
--- gdb-6.5-ppc/gdb/testsuite/gdb.base/bt-ppc.exp 1969-12-31 19:00:00.000000000 -0500
+++ gdb-6.5/gdb/testsuite/gdb.base/bt-ppc.exp 2007-01-12 21:27:25.000000000 -0500
@@ -0,0 +1,99 @@
+# Copyright 2006, 2007 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+# Test multiple unwinding fixes of PPC platform.
+# As the tests are platform independent we can run it everywhere.
+
+if $tracelevel then {
+ strace $tracelevel
+}
+
+set prms_id 0
+set bug_id 0
+
+# This test uses GCC-specific syntax.
+if [get_compiler_info not-used] {
+ return -1
+}
+
+if {![test_compiler_info "gcc-*"]} {
+ return 0
+}
+
+proc do_test { opts addons } {
+ global objdir srcdir subdir gdb_prompt
+
+ set testfile "bt-ppc"
+ set srcfile ${testfile}.c
+ set binfile ${objdir}/${subdir}/${testfile}
+
+ # `additional_flags' should be last as it eats arguments till eol.
+ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" ${binfile} executable [list $opts additional_flags=$addons]] != ""} {
+ return -1
+ }
+
+ gdb_exit
+ gdb_start
+ gdb_reinitialize_dir $srcdir/$subdir
+ gdb_load ${binfile}
+
+ # We should stop in abort(3).
+
+ gdb_run_cmd
+
+ gdb_test_multiple {} "continue to abort()" {
+ -re ".*Program received signal SIGABRT,.*$gdb_prompt $" {
+ pass "continue to abort()"
+ }
+ }
+
+ # Check backtrace:
+ # #3 0x0804835f in func0 ()
+ # #4 0x0804836a in func1 ()
+ # #5 0x0804838c in main ()
+ # (gdb)
+ # `\\.?' prefixes are needed for ppc64 without `debug' (another bug).
+
+ set show [concat $opts $addons]
+ if [regexp {^-fno-asynchronous-unwind-tables (-fpie -pie )?-O2$} $show] {
+ # We get correct unwind but with two excessive "??" entries
+ # due to undetectable inserted alignment entry.
+ # With -fa-u-t we have correct FDE, without -O2 we have frame pointer.
+ # 1 0x0000003acb631980 in abort () from /lib64/libc.so.6
+ # 2 0x0000000000400489 in func0 ()
+ # 3 0x00000000004004d0 in ?? ()
+ # 4 0x0000000000400499 in func1 ()
+ # 5 0x00007fffc5442410 in ?? ()
+ # 6 0x00000000004004b9 in main ()
+ setup_xfail "x86_64-*-*"
+ }
+ gdb_test_multiple "bt" "Correct unwind for: $show" {
+ -re "\r\n#\[0-9\]\[^\r\n\]* in \\.?func0 \\(\[^\r\n\]*\r\n#\[0-9\]\[^\r\n\]* in \\.?func1 \\(\[^\r\n\]*\r\n#\[0-9\]\[^\r\n\]* in \\.?main \\(\[^\r\n\]*\r\n$gdb_prompt $" {
+ pass "Correct unwind for: $show"
+ }
+ }
+}
+
+foreach eh_frame {{-fno-asynchronous-unwind-tables}
+ {-fasynchronous-unwind-tables}} {
+ foreach pie {{} {-fpie -pie}} {
+ foreach optim {{} {-O2}} {
+ foreach is_debug {{} {debug}} {
+ do_test $is_debug [concat $eh_frame $pie $optim]
+ }
+ }
+ }
+}