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