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

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