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

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