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