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

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