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

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