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

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