Blame SOURCES/gdb-rhbz1182151-ibm-z13-11of22.patch

2c2fa1
commit 4fa5d7b436815f58688ec9245f24fc83263364b9
2c2fa1
Author: Andreas Arnez <arnez@linux.vnet.ibm.com>
2c2fa1
Date:   Mon Mar 2 10:57:40 2015 +0100
2c2fa1
2c2fa1
    S390: Vector register test case
2c2fa1
    
2c2fa1
    Add a test case for S/390 vector registers support.
2c2fa1
    
2c2fa1
    gdb/testsuite/ChangeLog:
2c2fa1
    
2c2fa1
    	* gdb.arch/s390-vregs.exp: New test.
2c2fa1
    	* gdb.arch/s390-vregs.S: New file.
2c2fa1
2c2fa1
### a/gdb/testsuite/ChangeLog
2c2fa1
### b/gdb/testsuite/ChangeLog
2c2fa1
## -1,3 +1,8 @@
2c2fa1
+2015-03-02  Andreas Arnez  <arnez@linux.vnet.ibm.com>
2c2fa1
+
2c2fa1
+	* gdb.arch/s390-vregs.exp: New test.
2c2fa1
+	* gdb.arch/s390-vregs.S: New file.
2c2fa1
+
2c2fa1
 2015-02-27  Pedro Alves  <palves@redhat.com>
2c2fa1
 
2c2fa1
 	* gdb.gdb/python-interrupts.exp (test_python_interrupts): Adjust
2c2fa1
Index: gdb-7.6.1/gdb/testsuite/gdb.arch/s390-vregs.S
2c2fa1
===================================================================
2c2fa1
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
2c2fa1
+++ gdb-7.6.1/gdb/testsuite/gdb.arch/s390-vregs.S	2016-03-19 19:53:16.315003373 +0100
2c2fa1
@@ -0,0 +1,96 @@
2c2fa1
+/* Copyright 2015 Free Software Foundation, Inc.
2c2fa1
+
2c2fa1
+   This file is part of GDB.
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
+	.text
2c2fa1
+
2c2fa1
+	/* 'check_vx': Yield SIGILL unless vector support is
2c2fa1
+	available.  Have a "pit stop" breakpoint here.  */
2c2fa1
+
2c2fa1
+	.align	8
2c2fa1
+	.type	check_vx, @function
2c2fa1
+check_vx:
2c2fa1
+	.cfi_startproc
2c2fa1
+	/* vlr  %v0,%v0 */
2c2fa1
+	.byte 0xe7,0x00,0x00,0x00,0x00,0x56
2c2fa1
+	br	%r14
2c2fa1
+	.cfi_endproc
2c2fa1
+	.size	check_vx, .-check_vx
2c2fa1
+
2c2fa1
+
2c2fa1
+	/* 'store_vrs': Store vector registers in save_area.  */
2c2fa1
+
2c2fa1
+	.align 8
2c2fa1
+	.type	store_vrs, @function
2c2fa1
+store_vrs:
2c2fa1
+	.cfi_startproc
2c2fa1
+	larl	%r1,save_area
2c2fa1
+	/* vstm %v0,%v15,0(%r1) */
2c2fa1
+	.byte 0xe7,0x0f,0x10,0x00,0x00,0x3e
2c2fa1
+	/* vstm %v16,%v31,256(%r1) */
2c2fa1
+	.byte 0xe7,0x0f,0x11,0x00,0x0c,0x3e
2c2fa1
+	br	%r14
2c2fa1
+	.cfi_endproc
2c2fa1
+	.size	store_vrs, .-store_vrs
2c2fa1
+
2c2fa1
+
2c2fa1
+	/* 'change_vrs': Manipulate vector registers according to a
2c2fa1
+	simple algorithm.  */
2c2fa1
+
2c2fa1
+	.align 8
2c2fa1
+	.type	change_vrs, @function
2c2fa1
+change_vrs:
2c2fa1
+	.cfi_startproc
2c2fa1
+	lghi	%r1,16
2c2fa1
+	lghi	%r3,0xff
2c2fa1
+1:	.insn	ril,0xc60000000000,%r3,2f /* exrl */
2c2fa1
+	.insn	ril,0xc60000000000,%r3,1f /* exrl */
2c2fa1
+	aghi	%r3,-0x11
2c2fa1
+	brctg	%r1,1b
2c2fa1
+	br	%r14
2c2fa1
+	.cfi_endproc
2c2fa1
+	/* vmlf %v0,%v0,%v0 */
2c2fa1
+1:	.byte	0xe7,0x00,0x00,0x00,0x20,0xa2
2c2fa1
+	/* vmlf %v16,%v16,%v0 */
2c2fa1
+2:	.byte	0xe7,0x00,0x00,0x00,0x2c,0xa2
2c2fa1
+
2c2fa1
+
2c2fa1
+	/* 'main': Perform actions according to test case logic.
2c2fa1
+	Invoke check_vx whenever a pit stop is required.  */
2c2fa1
+
2c2fa1
+	.section	.text.startup,"ax",@progbits
2c2fa1
+	.align	8
2c2fa1
+.globl main
2c2fa1
+	.type	main, @function
2c2fa1
+main:
2c2fa1
+	.cfi_startproc
2c2fa1
+	stmg	%r14,%r15,112(%r15)
2c2fa1
+	aghi	%r15,-160
2c2fa1
+	bras	%r14,check_vx
2c2fa1
+	bras	%r14,store_vrs
2c2fa1
+	bras	%r14,check_vx
2c2fa1
+	bras	%r14,change_vrs
2c2fa1
+	bras	%r14,check_vx
2c2fa1
+	lmg	%r14,%r15,272(%r15)
2c2fa1
+	lghi	%r2,0
2c2fa1
+	br	%r14
2c2fa1
+	.cfi_endproc
2c2fa1
+	.size	main, .-main
2c2fa1
+
2c2fa1
+	.local	save_area
2c2fa1
+	.comm	save_area,512,16
2c2fa1
+
2c2fa1
+	.section	.note.GNU-stack,"",@progbits
2c2fa1
Index: gdb-7.6.1/gdb/testsuite/gdb.arch/s390-vregs.exp
2c2fa1
===================================================================
2c2fa1
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
2c2fa1
+++ gdb-7.6.1/gdb/testsuite/gdb.arch/s390-vregs.exp	2016-03-19 19:53:16.315003373 +0100
2c2fa1
@@ -0,0 +1,226 @@
2c2fa1
+# Copyright 2015 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
+# Test vector register access for s390 platforms.
2c2fa1
+
2c2fa1
+if { ![istarget s390-*-*] && ![istarget s390x-*-* ] } {
2c2fa1
+    verbose "Skipping s390 vector register tests."
2c2fa1
+    return
2c2fa1
+}
2c2fa1
+
2c2fa1
+# Capture the output of COMMAND in a string ignoring PREFIX (a regexp);
2c2fa1
+# return that string.
2c2fa1
+
2c2fa1
+proc capture_command_output { command prefix } {
2c2fa1
+    global gdb_prompt
2c2fa1
+    global expect_out
2c2fa1
+
2c2fa1
+    set output_string ""
2c2fa1
+    gdb_test_multiple "$command" "capture_command_output for $command" {
2c2fa1
+	-re "[string_to_regexp ${command}]\[\r\n\]+${prefix}(.*)\[\r\n\]+$gdb_prompt $" {
2c2fa1
+	    set output_string $expect_out(1,string)
2c2fa1
+	}
2c2fa1
+    }
2c2fa1
+    return $output_string
2c2fa1
+}
2c2fa1
+
2c2fa1
+standard_testfile .S
2c2fa1
+
2c2fa1
+if [isnative] {
2c2fa1
+    # Create a temporary directory, to take a core dump there later.
2c2fa1
+    set coredir [standard_output_file ${testfile}.d]
2c2fa1
+    remote_exec build "rm -rf $coredir"
2c2fa1
+    remote_exec build "mkdir $coredir"
2c2fa1
+}
2c2fa1
+
2c2fa1
+if { [prepare_for_testing ${testfile}.exp $testfile $srcfile \
2c2fa1
+	  [list "additional_flags=-mzarch"]] } {
2c2fa1
+    return -1
2c2fa1
+}
2c2fa1
+
2c2fa1
+if ![runto_main] {
2c2fa1
+    untested "could not run to main"
2c2fa1
+    return -1
2c2fa1
+}
2c2fa1
+
2c2fa1
+# Run to the first vector instruction and step it.  If the inferior
2c2fa1
+# doesn't crash, we have vector support.
2c2fa1
+
2c2fa1
+gdb_breakpoint "check_vx"
2c2fa1
+gdb_continue_to_breakpoint "first vector insn"
2c2fa1
+set before_pc 0
2c2fa1
+gdb_test_multiple "x/i \$pc" "get PC at vector insn" {
2c2fa1
+    -re "(0x\\S+)\\s+\\S+\\s+vlr\\s+.*$gdb_prompt $" {
2c2fa1
+	set before_pc $expect_out(1,string)
2c2fa1
+    }
2c2fa1
+}
2c2fa1
+
2c2fa1
+gdb_test_multiple "stepi" "check for vector support" {
2c2fa1
+    -re "Program received signal SIGILL,.*\r\n$gdb_prompt $" {
2c2fa1
+	unsupported "no vector support."
2c2fa1
+	return
2c2fa1
+    }
2c2fa1
+    -re "\[0-9\]+.*\r\n$gdb_prompt $" {
2c2fa1
+	pass "vector support available"
2c2fa1
+    }
2c2fa1
+    -re "$gdb_prompt $" {
2c2fa1
+	fail "no vector support (unknown error)"
2c2fa1
+	return
2c2fa1
+    }
2c2fa1
+}
2c2fa1
+
2c2fa1
+# Has the PC advanced by the expected amount?  The kernel may do
2c2fa1
+# something special for the first vector insn in the process.
2c2fa1
+
2c2fa1
+set after_pc 0
2c2fa1
+gdb_test_multiple "x/i \$pc" "get PC after vector insn" {
2c2fa1
+    -re "(0x\\S+)\\s+.*$gdb_prompt $" {
2c2fa1
+	set after_pc $expect_out(1,string)
2c2fa1
+    }
2c2fa1
+}
2c2fa1
+
2c2fa1
+if [expr $before_pc + 6 != $after_pc] {
2c2fa1
+    fail "stepping first vector insn"
2c2fa1
+}
2c2fa1
+
2c2fa1
+# Lift the core file limit, if possible, and change into the temporary
2c2fa1
+# directory.
2c2fa1
+
2c2fa1
+if { $coredir != "" } {
2c2fa1
+    gdb_test {print setrlimit (4, &(unsigned long [2]){~0UL, ~0UL})} \
2c2fa1
+	" = .*" "setrlimit"
2c2fa1
+    gdb_test "print chdir (\"${coredir}\")" " = 0" "chdir"
2c2fa1
+}
2c2fa1
+
2c2fa1
+# Initialize all vector registers with GDB "set" commands, using
2c2fa1
+# distinct values.  Handle left and right halves separately, in
2c2fa1
+# pseudo-random order.
2c2fa1
+
2c2fa1
+set a_high 1
2c2fa1
+set a_low 2
2c2fa1
+set b_high 3
2c2fa1
+set b_low 5
2c2fa1
+
2c2fa1
+set a [expr ($a_high << 32) | $a_low]
2c2fa1
+set b [expr ($b_high << 32) | $b_low]
2c2fa1
+
2c2fa1
+for {set j 0} {$j < 32} {incr j 1} {
2c2fa1
+    set i [expr 17 * $j % 32]
2c2fa1
+    gdb_test_no_output \
2c2fa1
+	"set \$v$i.v2_int64\[0\] = [expr $a * ($i + 1)]" \
2c2fa1
+	"set v$i left"
2c2fa1
+    set i [expr 19 * (31 - $j) % 32]
2c2fa1
+    gdb_test_no_output \
2c2fa1
+	"set \$v$i.v2_int64\[1\] = [expr $b * (32 - $i)]" \
2c2fa1
+	"set v$i right"
2c2fa1
+}
2c2fa1
+
2c2fa1
+# Verify a vector register's union members.
2c2fa1
+
2c2fa1
+gdb_test "info register v0 v31" \
2c2fa1
+    "v4_float .* v2_double .* v16_int8 .* v8_int16 .* v4_int32 .* v2_int64 .* uint128\
2c2fa1
+     .*v4_float .* v2_double .* v16_int8 .* v8_int16 .* v4_int32 .* v2_int64 .* uint128 .*"
2c2fa1
+
2c2fa1
+# Let the inferior store all vector registers in a buffer, then dump
2c2fa1
+# the buffer and check it.
2c2fa1
+
2c2fa1
+gdb_continue_to_breakpoint "store vrs"
2c2fa1
+set vregs [capture_command_output "x/64xg &save_area" ""]
2c2fa1
+
2c2fa1
+set i 0
2c2fa1
+foreach {- left right} [regexp -all -inline -line {^.*:\s+(\w+)\s+(\w+)} $vregs] {
2c2fa1
+    if [expr $left != $a * ($i + 1) || $right != $b * (32 - $i)] {
2c2fa1
+	fail "verify \$v$i after set"
2c2fa1
+    }
2c2fa1
+    if { $i < 16 } {
2c2fa1
+	# Check that the FP register was updated accordingly.
2c2fa1
+	gdb_test "info register f$i" "raw ${left}.*"
2c2fa1
+    }
2c2fa1
+    incr i 1
2c2fa1
+}
2c2fa1
+
2c2fa1
+if { $i != 32 } {
2c2fa1
+    fail "dump save area (bad output)"
2c2fa1
+}
2c2fa1
+
2c2fa1
+# Let the inferior change all VRs according to a simple algorithm,
2c2fa1
+# then print all VRs and compare their values with our result of the
2c2fa1
+# same algorithm.
2c2fa1
+
2c2fa1
+gdb_continue_to_breakpoint "change vrs"
2c2fa1
+set vregs [capture_command_output "info registers vector" ""]
2c2fa1
+
2c2fa1
+set j 1
2c2fa1
+foreach {- r i val} [regexp -all -inline -line \
2c2fa1
+			 {^(\D*)(\d+)\s+.*?uint128 = 0x([0-9a-f]+?)} $vregs] {
2c2fa1
+    if { $r ne "v" } {
2c2fa1
+	fail "info registers vector: bad line $j"
2c2fa1
+    } elseif { $val ne [format %08x%08x%08x%08x \
2c2fa1
+			    [expr $a_high * ($i + 1) * $a_high ] \
2c2fa1
+			    [expr $a_low * ($i + 1) * $a_low ] \
2c2fa1
+			    [expr $b_high * (32 - $i) * $b_high * 32] \
2c2fa1
+			    [expr $b_low * (32 - $i) * $b_low * 32] ] } {
2c2fa1
+	fail "compare \$v$i"
2c2fa1
+    }
2c2fa1
+    incr j 1
2c2fa1
+}
2c2fa1
+
2c2fa1
+if { $j != 33 } {
2c2fa1
+    fail "info registers vector"
2c2fa1
+}
2c2fa1
+
2c2fa1
+if { $coredir == "" } {
2c2fa1
+    return
2c2fa1
+}
2c2fa1
+
2c2fa1
+# Take a core dump.
2c2fa1
+
2c2fa1
+gdb_test "signal SIGABRT" "Program terminated with signal SIGABRT, .*"
2c2fa1
+gdb_exit
2c2fa1
+
2c2fa1
+# Find the core file and rename it (avoid accumulating core files).
2c2fa1
+
2c2fa1
+set cores [glob -nocomplain -directory $coredir *core*]
2c2fa1
+if {[llength $cores] != 1} {
2c2fa1
+    untested "core file not found"
2c2fa1
+    remote_exec build "rm -rf $coredir"
2c2fa1
+    return -1
2c2fa1
+}
2c2fa1
+set destcore [standard_output_file ${testfile}.core]
2c2fa1
+remote_exec build "mv [file join $coredir [lindex $cores 0]] $destcore"
2c2fa1
+remote_exec build "rm -rf $coredir"
2c2fa1
+
2c2fa1
+# Restart gdb and load the core file.  Compare the VRs.
2c2fa1
+
2c2fa1
+clean_restart ${testfile}
2c2fa1
+
2c2fa1
+with_test_prefix "core" {
2c2fa1
+    set core_loaded -1
2c2fa1
+    set test "load"
2c2fa1
+    gdb_test_multiple "core $destcore" "$test" {
2c2fa1
+	-re "Core was generated by .*\r\n$gdb_prompt $" {
2c2fa1
+	    pass "$test"
2c2fa1
+	    set core_loaded 1
2c2fa1
+	}
2c2fa1
+    }
2c2fa1
+    if { $core_loaded == 1 } {
2c2fa1
+	set vregs_from_core [capture_command_output "info registers vector" ""]
2c2fa1
+	if { $vregs_from_core eq $vregs } {
2c2fa1
+	    pass "compare vector registers"
2c2fa1
+	} else {
2c2fa1
+	    fail "vector registers mismatch"
2c2fa1
+	}
2c2fa1
+    }
2c2fa1
+}