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