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

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