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

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