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

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