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

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