Blame SOURCES/gdb-rhbz1480496-power-atomic-step-1of5.patch

dc7ef9
commit 62f7182c14492421b8d59ba5c6640d6c27ad6ea2
dc7ef9
Author: Anton Blanchard <anton@samba.org>
dc7ef9
Date:   Fri Mar 28 12:37:37 2014 +1100
dc7ef9
dc7ef9
    Fix ppc64 single step over atomic sequence testcase.
dc7ef9
    
dc7ef9
    The current ppc64 single step over atomic sequence testcase is written
dc7ef9
    in C and breaks with some versions of gcc. Convert the test to
dc7ef9
    assembly and use stepi to step through it.
dc7ef9
    
dc7ef9
    gdb/testsuite/
dc7ef9
    2014-04-01  Anton Blanchard  <anton@samba.org>
dc7ef9
    
dc7ef9
            * gdb.arch/ppc64-atomic-inst.c: Remove.
dc7ef9
            * gdb.arch/ppc64-atomic-inst.S: New file.
dc7ef9
            * gdb.arch/ppc64-atomic-inst.exp: Adapt for asm based testcase.
dc7ef9
dc7ef9
### a/gdb/testsuite/ChangeLog
dc7ef9
### b/gdb/testsuite/ChangeLog
dc7ef9
## -1,3 +1,9 @@
dc7ef9
+2014-04-01  Anton Blanchard  <anton@samba.org>
dc7ef9
+
dc7ef9
+	* gdb.arch/ppc64-atomic-inst.c: Remove.
dc7ef9
+	* gdb.arch/ppc64-atomic-inst.S: New file.
dc7ef9
+	* gdb.arch/ppc64-atomic-inst.exp: Adapt for asm based testcase.
dc7ef9
+
dc7ef9
 2014-03-31  Doug Evans  <dje@google.com>
dc7ef9
 
dc7ef9
 	* gdb.base/print-symbol-loading-lib.c: New file.
dc7ef9
--- /dev/null
dc7ef9
+++ b/gdb/testsuite/gdb.arch/ppc64-atomic-inst.S
dc7ef9
@@ -0,0 +1,61 @@
dc7ef9
+/* This file is part of GDB, the GNU debugger.
dc7ef9
+
dc7ef9
+   Copyright 2008-2014 Free Software Foundation, Inc.
dc7ef9
+
dc7ef9
+   This program is free software; you can redistribute it and/or modify
dc7ef9
+   it under the terms of the GNU General Public License as published by
dc7ef9
+   the Free Software Foundation; either version 3 of the License, or
dc7ef9
+   (at your option) any later version.
dc7ef9
+
dc7ef9
+   This program is distributed in the hope that it will be useful,
dc7ef9
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
dc7ef9
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
dc7ef9
+   GNU General Public License for more details.
dc7ef9
+
dc7ef9
+   You should have received a copy of the GNU General Public License
dc7ef9
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
dc7ef9
+
dc7ef9
+	.align 2
dc7ef9
+	.globl main
dc7ef9
+#if _CALL_ELF == 2
dc7ef9
+	.type main,@function
dc7ef9
+main:
dc7ef9
+#else
dc7ef9
+	.section ".opd","aw"
dc7ef9
+	.align 3
dc7ef9
+main:
dc7ef9
+	.quad .main,.TOC.@tocbase,0
dc7ef9
+	.size main,.-main
dc7ef9
+	.previous
dc7ef9
+	.globl .main
dc7ef9
+	.type .main,@function
dc7ef9
+.main:
dc7ef9
+#endif
dc7ef9
+
dc7ef9
+	li	0,0
dc7ef9
+	addi	4,1,-8
dc7ef9
+
dc7ef9
+	stw	0,0(4)
dc7ef9
+1:	lwarx	5,0,4
dc7ef9
+	cmpwi	5,0
dc7ef9
+	bne	2f
dc7ef9
+	addi	5,5,1
dc7ef9
+	stwcx.	5,0,4
dc7ef9
+	bne	1b
dc7ef9
+
dc7ef9
+	std	0,0(4)
dc7ef9
+2:	ldarx	5,0,4
dc7ef9
+	cmpdi	5,0
dc7ef9
+	bne	3f
dc7ef9
+	addi	5,5,1
dc7ef9
+	stdcx.	5,0,4
dc7ef9
+	bne	1b
dc7ef9
+
dc7ef9
+3:	li	3,0
dc7ef9
+	blr
dc7ef9
+
dc7ef9
+#if _CALL_ELF == 2
dc7ef9
+	.size main,.-main
dc7ef9
+#else
dc7ef9
+	.size .main,.-.main
dc7ef9
+#endif
dc7ef9
--- a/gdb/testsuite/gdb.arch/ppc64-atomic-inst.c
dc7ef9
+++ /dev/null
dc7ef9
@@ -1,44 +0,0 @@
dc7ef9
-/* This file is part of GDB, the GNU debugger.
dc7ef9
-
dc7ef9
-   Copyright 2008-2013 Free Software Foundation, Inc.
dc7ef9
-
dc7ef9
-   This program is free software; you can redistribute it and/or modify
dc7ef9
-   it under the terms of the GNU General Public License as published by
dc7ef9
-   the Free Software Foundation; either version 3 of the License, or
dc7ef9
-   (at your option) any later version.
dc7ef9
-
dc7ef9
-   This program is distributed in the hope that it will be useful,
dc7ef9
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
dc7ef9
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
dc7ef9
-   GNU General Public License for more details.
dc7ef9
-
dc7ef9
-   You should have received a copy of the GNU General Public License
dc7ef9
-   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
dc7ef9
-
dc7ef9
-#include <stdio.h>
dc7ef9
-
dc7ef9
-int main()
dc7ef9
-{
dc7ef9
-  unsigned int word = 0;
dc7ef9
-  unsigned int *word_addr = &wor;;
dc7ef9
-  unsigned long dword = 0;
dc7ef9
-  unsigned long *dword_addr = &dword;
dc7ef9
-
dc7ef9
-  __asm __volatile ("1:     lwarx   %0,0,%2\n"              \
dc7ef9
-                    "       addi    %0,%0,1\n"              \
dc7ef9
-                    "       stwcx.  %0,0,%2\n"              \
dc7ef9
-                    "       bne-    1b"			    \
dc7ef9
-                    : "=&b" (word), "=m" (*word_addr)       \
dc7ef9
-                    : "b" (word_addr), "m" (*word_addr)     \
dc7ef9
-                    : "cr0", "memory");			    \
dc7ef9
-
dc7ef9
-  __asm __volatile ("1:     ldarx   %0,0,%2\n"              \
dc7ef9
-                    "       addi    %0,%0,1\n"              \
dc7ef9
-                    "       stdcx.  %0,0,%2\n"              \
dc7ef9
-                    "       bne-    1b"                     \
dc7ef9
-                    : "=&b" (dword), "=m" (*dword_addr)     \
dc7ef9
-                    : "b" (dword_addr), "m" (*dword_addr)   \
dc7ef9
-                    : "cr0", "memory");                     \
dc7ef9
-
dc7ef9
-  return 0;
dc7ef9
-}
dc7ef9
--- a/gdb/testsuite/gdb.arch/ppc64-atomic-inst.exp
dc7ef9
+++ b/gdb/testsuite/gdb.arch/ppc64-atomic-inst.exp
dc7ef9
@@ -27,7 +27,7 @@ if {![istarget "powerpc*"] || ![is_lp64_target]} {
dc7ef9
 }
dc7ef9
 
dc7ef9
 set testfile "ppc64-atomic-inst"
dc7ef9
-set srcfile ${testfile}.c
dc7ef9
+set srcfile ${testfile}.S
dc7ef9
 set binfile ${objdir}/${subdir}/${testfile}
dc7ef9
 set compile_flags {debug quiet}
dc7ef9
 
dc7ef9
@@ -50,11 +50,18 @@ set bp1 [gdb_get_line_number "lwarx"]
dc7ef9
 gdb_breakpoint "$bp1" "Breakpoint $decimal at $hex" \
dc7ef9
   "Set the breakpoint at the start of the sequence"
dc7ef9
 
dc7ef9
+set bp2 [gdb_get_line_number "ldarx"]
dc7ef9
+gdb_breakpoint "$bp2" "Breakpoint $decimal at $hex" \
dc7ef9
+  "Set the breakpoint at the start of the sequence"
dc7ef9
+
dc7ef9
 gdb_test continue "Continuing.*Breakpoint $decimal.*" \
dc7ef9
   "Continue until breakpoint"
dc7ef9
 
dc7ef9
-gdb_test next ".*__asm __volatile.*" \
dc7ef9
+gdb_test nexti "bne.*1b" \
dc7ef9
   "Step through the lwarx/stwcx sequence"
dc7ef9
 
dc7ef9
-gdb_test next ".*return 0.*" \
dc7ef9
-  "Step through the ldarx/stdcx sequence"
dc7ef9
+gdb_test continue "Continuing.*Breakpoint $decimal.*" \
dc7ef9
+  "Continue until breakpoint"
dc7ef9
+
dc7ef9
+gdb_test nexti "bne.*1b" \
dc7ef9
+  "Step through the lwarx/stwcx sequence"