Blame SOURCES/gdb-6.3-bz140532-ppc-unwinding-test.patch

01917d
diff -u -ruNp gdb-6.3-unpatched/gdb/testsuite/gdb.arch/powerpc-bcl-prologue-asm32.S gdb-6.3/gdb/testsuite/gdb.arch/powerpc-bcl-prologue-asm32.S
01917d
--- gdb-6.3-unpatched/gdb/testsuite/gdb.arch/powerpc-bcl-prologue-asm32.S	1969-12-31 19:00:00.000000000 -0500
01917d
+++ gdb-6.3/gdb/testsuite/gdb.arch/powerpc-bcl-prologue-asm32.S	2007-08-02 13:23:10.000000000 -0400
01917d
@@ -0,0 +1,78 @@
01917d
+/* This testcase is part of GDB, the GNU debugger.
01917d
+
01917d
+   Copyright 2007 Free Software Foundation, Inc.
01917d
+
01917d
+   This program is free software; you can redistribute it and/or modify
01917d
+   it under the terms of the GNU General Public License as published by
01917d
+   the Free Software Foundation; either version 2 of the License, or
01917d
+   (at your option) any later version.
01917d
+
01917d
+   This program is distributed in the hope that it will be useful,
01917d
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
01917d
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
01917d
+   GNU General Public License for more details.
01917d
+ 
01917d
+   You should have received a copy of the GNU General Public License
01917d
+   along with this program; if not, write to the Free Software
01917d
+   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
01917d
+
01917d
+	.section	".text"
01917d
+	.align 2
01917d
+	.globl func0
01917d
+	.type	func0, @function
01917d
+func0:
01917d
+	stwu 1,-16(1)
01917d
+	mflr 0
01917d
+	stw 31,12(1)
01917d
+	stw 0,20(1)
01917d
+	mr 31,1
01917d
+	bl abort
01917d
+	.size	func0, .-func0
01917d
+	.align 2
01917d
+	.globl func1
01917d
+	.type	func1, @function
01917d
+func1:
01917d
+	stwu 1,-16(1)
01917d
+	mflr 0
01917d
+/* 20 = BO = branch always
01917d
+   31 = BI = CR bit (ignored)  */
01917d
+	bcl 20,31,.Lpie
01917d
+.Lpie:	stw 31,12(1)
01917d
+	stw 0,20(1)
01917d
+	mr 31,1
01917d
+	bl func0
01917d
+	mr 0,3
01917d
+	lis 9,var@ha
01917d
+	lwz 9,var@l(9)
01917d
+	add 0,0,9
01917d
+	mr 3,0
01917d
+	lwz 11,0(1)
01917d
+	lwz 0,4(11)
01917d
+	mtlr 0
01917d
+	lwz 31,-4(11)
01917d
+	mr 1,11
01917d
+	blr
01917d
+	.size	func1, .-func1
01917d
+	.section	.note.GNU-stack,"",@progbits
01917d
+	.ident	"GCC: (GNU) 3.4.6 20060404 (Red Hat 3.4.6-8)"
01917d
+
01917d
+/* Original source file:
01917d
+
01917d
+#include <stdlib.h>
01917d
+
01917d
+extern volatile int var;
01917d
+
01917d
+int func0 (void) __attribute__((__noinline__));
01917d
+int func0 (void)
01917d
+{
01917d
+  abort ();
01917d
+  return var;
01917d
+}
01917d
+
01917d
+int func1 (void) __attribute__((__noinline__));
01917d
+int func1 (void)
01917d
+{
01917d
+  return func0 () + var;
01917d
+}
01917d
+
01917d
+*/
01917d
diff -u -ruNp gdb-6.3-unpatched/gdb/testsuite/gdb.arch/powerpc-bcl-prologue-asm64.S gdb-6.3/gdb/testsuite/gdb.arch/powerpc-bcl-prologue-asm64.S
01917d
--- gdb-6.3-unpatched/gdb/testsuite/gdb.arch/powerpc-bcl-prologue-asm64.S	1969-12-31 19:00:00.000000000 -0500
01917d
+++ gdb-6.3/gdb/testsuite/gdb.arch/powerpc-bcl-prologue-asm64.S	2007-08-02 14:28:56.000000000 -0400
01917d
@@ -0,0 +1,98 @@
01917d
+/* This testcase is part of GDB, the GNU debugger.
01917d
+
01917d
+   Copyright 2007 Free Software Foundation, Inc.
01917d
+
01917d
+   This program is free software; you can redistribute it and/or modify
01917d
+   it under the terms of the GNU General Public License as published by
01917d
+   the Free Software Foundation; either version 2 of the License, or
01917d
+   (at your option) any later version.
01917d
+
01917d
+   This program is distributed in the hope that it will be useful,
01917d
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
01917d
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
01917d
+   GNU General Public License for more details.
01917d
+ 
01917d
+   You should have received a copy of the GNU General Public License
01917d
+   along with this program; if not, write to the Free Software
01917d
+   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
01917d
+
01917d
+	.section	".toc","aw"
01917d
+	.section	".text"
01917d
+	.align 2
01917d
+	.globl func0
01917d
+	.section	".opd","aw"
01917d
+	.align 3
01917d
+func0:
01917d
+	.quad	.L.func0,.TOC.@tocbase
01917d
+	.previous
01917d
+	.type	func0, @function
01917d
+.L.func0:
01917d
+	mflr 0
01917d
+	std 31,-8(1)
01917d
+	std 0,16(1)
01917d
+	stdu 1,-128(1)
01917d
+	mr 31,1
01917d
+	bl abort
01917d
+	nop
01917d
+	.long 0
01917d
+	.byte 0,0,0,1,128,1,0,1
01917d
+	.size	func0,.-.L.func0
01917d
+	.section	".toc","aw"
01917d
+.LC1:
01917d
+	.tc var[TC],var
01917d
+	.section	".text"
01917d
+	.align 2
01917d
+	.globl func1
01917d
+	.section	".opd","aw"
01917d
+	.align 3
01917d
+func1:
01917d
+	.quad	.L.func1,.TOC.@tocbase
01917d
+	.previous
01917d
+	.type	func1, @function
01917d
+.L.func1:
01917d
+	mflr 0
01917d
+/* 20 = BO = branch always
01917d
+   31 = BI = CR bit (ignored)  */
01917d
+	bcl 20,31,.Lpie
01917d
+.Lpie:	std 31,-8(1)
01917d
+	std 0,16(1)
01917d
+	stdu 1,-128(1)
01917d
+	mr 31,1
01917d
+	bl func0
01917d
+	mr 11,3
01917d
+	ld 9,.LC1@toc(2)
01917d
+	lwz 0,0(9)
01917d
+	add 0,11,0
01917d
+	extsw 0,0
01917d
+	mr 3,0
01917d
+	ld 1,0(1)
01917d
+	ld 0,16(1)
01917d
+	mtlr 0
01917d
+	ld 31,-8(1)
01917d
+	blr
01917d
+	.long 0
01917d
+	.byte 0,0,0,1,128,1,0,1
01917d
+	.size	func1,.-.L.func1
01917d
+	.section	.note.GNU-stack,"",@progbits
01917d
+	.ident	"GCC: (GNU) 3.4.6 20060404 (Red Hat 3.4.6-8)"
01917d
+
01917d
+/* Original source file:
01917d
+
01917d
+#include <stdlib.h>
01917d
+
01917d
+extern volatile int var;
01917d
+
01917d
+int func0 (void) __attribute__((__noinline__));
01917d
+int func0 (void)
01917d
+{
01917d
+  abort ();
01917d
+  return var;
01917d
+}
01917d
+
01917d
+int func1 (void) __attribute__((__noinline__));
01917d
+int func1 (void)
01917d
+{
01917d
+  return func0 () + var;
01917d
+}
01917d
+
01917d
+*/
01917d
diff -u -ruNp gdb-6.3-unpatched/gdb/testsuite/gdb.arch/powerpc-bcl-prologue.c gdb-6.3/gdb/testsuite/gdb.arch/powerpc-bcl-prologue.c
01917d
--- gdb-6.3-unpatched/gdb/testsuite/gdb.arch/powerpc-bcl-prologue.c	1969-12-31 19:00:00.000000000 -0500
01917d
+++ gdb-6.3/gdb/testsuite/gdb.arch/powerpc-bcl-prologue.c	2007-08-02 13:25:10.000000000 -0400
01917d
@@ -0,0 +1,29 @@
01917d
+/* This testcase is part of GDB, the GNU debugger.
01917d
+
01917d
+   Copyright 2007 Free Software Foundation, Inc.
01917d
+
01917d
+   This program is free software; you can redistribute it and/or modify
01917d
+   it under the terms of the GNU General Public License as published by
01917d
+   the Free Software Foundation; either version 2 of the License, or
01917d
+   (at your option) any later version.
01917d
+
01917d
+   This program is distributed in the hope that it will be useful,
01917d
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
01917d
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
01917d
+   GNU General Public License for more details.
01917d
+ 
01917d
+   You should have received a copy of the GNU General Public License
01917d
+   along with this program; if not, write to the Free Software
01917d
+   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
01917d
+
01917d
+/* Force `-fpie' double jump bl->blrl.  */
01917d
+/* No longer used.  */
01917d
+volatile int var;
01917d
+
01917d
+extern int func1 (void);
01917d
+
01917d
+int main (void)
01917d
+{
01917d
+  func1 ();
01917d
+  return 0;
01917d
+}
01917d
diff -u -ruNp gdb-6.3-unpatched/gdb/testsuite/gdb.arch/powerpc-bcl-prologue.exp gdb-6.3/gdb/testsuite/gdb.arch/powerpc-bcl-prologue.exp
01917d
--- gdb-6.3-unpatched/gdb/testsuite/gdb.arch/powerpc-bcl-prologue.exp	1969-12-31 19:00:00.000000000 -0500
01917d
+++ gdb-6.3/gdb/testsuite/gdb.arch/powerpc-bcl-prologue.exp	2007-08-02 14:21:29.000000000 -0400
01917d
@@ -0,0 +1,72 @@
01917d
+#   Copyright 2006, 2007 Free Software Foundation, Inc.
01917d
+
01917d
+# This program is free software; you can redistribute it and/or modify
01917d
+# it under the terms of the GNU General Public License as published by
01917d
+# the Free Software Foundation; either version 2 of the License, or
01917d
+# (at your option) any later version.
01917d
+# 
01917d
+# This program is distributed in the hope that it will be useful,
01917d
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
01917d
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
01917d
+# GNU General Public License for more details.
01917d
+# 
01917d
+# You should have received a copy of the GNU General Public License
01917d
+# along with this program; if not, write to the Free Software
01917d
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  
01917d
+
01917d
+# Test unwinding fixes of the PPC platform, specifically on the coping with BCL
01917d
+# jump of the PIE code.
01917d
+
01917d
+if ![istarget "powerpc*-*-linux*"] then {
01917d
+    verbose "Skipping powerpc-linux prologue tests."
01917d
+    return
01917d
+}
01917d
+
01917d
+set testfile "powerpc-bcl-prologue"
01917d
+set srcfile1 ${testfile}.c
01917d
+set flags "debug"
01917d
+if [istarget "powerpc-*"] then {
01917d
+    set srcfile2 ${testfile}-asm32.S
01917d
+    set flags "$flags additional_flags=-m32"
01917d
+} elseif [istarget "powerpc64-*"] then {
01917d
+    set srcfile2 ${testfile}-asm64.S
01917d
+    set flags "$flags additional_flags=-m64"
01917d
+} else {
01917d
+   fail "powerpc arch test"
01917d
+   return
01917d
+}
01917d
+set objfile2 ${objdir}/${subdir}/${testfile}-asm.o
01917d
+set binfile ${objdir}/${subdir}/${testfile}
01917d
+
01917d
+if { [gdb_compile "${srcdir}/${subdir}/${srcfile1} ${srcdir}/${subdir}/${srcfile2}" ${binfile} executable $flags] != ""} {
01917d
+    return -1
01917d
+}
01917d
+
01917d
+gdb_exit
01917d
+gdb_start
01917d
+gdb_reinitialize_dir $srcdir/$subdir
01917d
+gdb_load ${binfile}
01917d
+
01917d
+# We should stop in abort(3).
01917d
+
01917d
+gdb_run_cmd
01917d
+
01917d
+gdb_test_multiple {} "continue to abort()" {
01917d
+    -re ".*Program received signal SIGABRT,.*$gdb_prompt $" {
01917d
+       pass "continue to abort()"
01917d
+    }
01917d
+}
01917d
+
01917d
+# Check backtrace:
01917d
+# #3  0x0804835f in func0 ()
01917d
+# #4  0x0804836a in func1 ()
01917d
+# #5  0x0804838c in main ()
01917d
+# (gdb)
01917d
+# `\\.?' prefixes are needed for ppc64 without `debug' (another bug).
01917d
+
01917d
+set test "matching unwind"
01917d
+gdb_test_multiple "backtrace" $test {
01917d
+    -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 $" {
01917d
+	pass $test
01917d
+    }
01917d
+}
01917d
01917d
Fixup the testcase for ppc64 biarch GDB.
01917d
01917d
--- ./gdb/testsuite/gdb.arch/powerpc-prologue.exp	2008-01-13 13:32:19.000000000 +0100
01917d
+++ ./gdb/testsuite/gdb.arch/powerpc-prologue.exp	2008-01-02 00:04:10.000000000 +0100
01917d
@@ -17,8 +17,9 @@
01917d
 # Test PowerPC prologue analyzer.
01917d
 
01917d
 # Do not run on AIX (where we won't be able to build the tests without
01917d
-# some surgery) or on PowerPC64 (ditto, dot symbols).
01917d
-if {[istarget *-*-aix*] || ![istarget "powerpc-*-*"]} then {
01917d
+# some surgery).  PowerPC64 target would break due to dot symbols but we build
01917d
+# there PowerPC32 inferior.
01917d
+if {[istarget *-*-aix*] || ![istarget "powerpc*-*-*"]} then {
01917d
     verbose "Skipping PowerPC prologue tests."
01917d
     return
01917d
 }