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

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