-# Copyright 2010-2015 Free Software Foundation, Inc.
+# Copyright 2010-2020 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
}
# Get endianess for the scalar->vector casts
-gdb_test_multiple "show endian" "show endian" {
- -re ".* (big|little) endian.*$gdb_prompt $" {
- set endian $expect_out(1,string)
- pass "endianness: $endian"
- }
-}
+set endian [get_endianness]
# Test printing of character vector types
gdb_test "print c4" "\\\$$decimal = \\{1, 2, 3, 4\\}"
gdb_test "print (char4) 0x01010101" "\\\$$decimal = \\{1, 1, 1, 1\\}"
gdb_test "print (int2) lla" "\\\$$decimal = \\{1, 1\\}"
+# Check that "whatis" doesn't peel off the destination type's typedef
+# by mistake, in expressions that involve a cast to typedef type.
+gdb_test "whatis (char4) 0x01010101" "type = char4"
+gdb_test "whatis (int2) lla" "type = int2"
+# Check that OTOH "ptype" does peel off the destination type's
+# typedef.
+gdb_test "ptype (char4) 0x01010101" \
+ "type = char __attribute__ \\(\\(vector_size\\(4\\)\\)\\)"
+gdb_test "ptype (int2) lla" \
+ "type = int __attribute__ \\(\\(vector_size\\(2\\)\\)\\)"
+
if { ![string compare $endian big] } then {
gdb_test "print (char4) ia" "\\\$$decimal = \\{0, 0, 0, 2\\}"
} else {
gdb_test "print (int4) c4" "Cannot convert between vector values of different sizes"
gdb_test "print (char4) i4a" "Cannot convert between vector values of different sizes"
-# Test ptype on vector types.
+# Test ptype/whatis on vector types/vars.
gdb_test "ptype c4" "type = char __attribute__ \\(\\(vector_size\\(4\\)\\)\\)"
+gdb_test "whatis c4" "type = char4"
+
gdb_test "ptype char4" "type = char __attribute__ \\(\\(vector_size\\(4\\)\\)\\)"
+gdb_test "whatis char4" "type = char __attribute__ \\(\\(vector_size\\(4\\)\\)\\)"
+
gdb_test "ptype i4a" "type = int __attribute__ \\(\\(vector_size\\(4\\)\\)\\)"
+gdb_test "whatis i4a" "type = int4"
+
gdb_test "ptype int4" "type = int __attribute__ \\(\\(vector_size\\(4\\)\\)\\)"
+gdb_test "whatis int4" "type = int __attribute__ \\(\\(vector_size\\(4\\)\\)\\)"
+
gdb_test "ptype f4b" "type = float __attribute__ \\(\\(vector_size\\(4\\)\\)\\)"
+gdb_test "whatis f4b" "type = float4"
+
gdb_test "ptype float4" "type = float __attribute__ \\(\\(vector_size\\(4\\)\\)\\)"
+gdb_test "whatis float4" "type = float __attribute__ \\(\\(vector_size\\(4\\)\\)\\)"
gdb_test "ptype union_with_vector_1" "type = union {\r\n\[\t \]+int i;\r\n\[\t \]+char cv __attribute__ \\(\\(vector_size\\(4\\)\\)\\);\r\n}"
+gdb_test "whatis union_with_vector_1" {type = union {...}}
+
gdb_test "ptype struct_with_vector_1" "type = struct {\r\n\[\t \]+int i;\r\n\[\t \]+char cv __attribute__ \\(\\(vector_size\\(4\\)\\)\\);\r\n\[\t \]+float4 f4;\r\n}"
+gdb_test "whatis struct_with_vector_1" {type = struct {...}}
# Test inferior function calls with vector arguments and/or vector
# return values.
}
}
-# Test "return" from vector-valued function.
gdb_continue "add_some_intvecs"
+gdb_test "up" ""
+gdb_test "p res" "\\{10, 20, 48, 72\\}.*"
+gdb_test "down" ""
+
+
+# Test "return" from vector-valued function.
set test "return from vector-valued function"
set should_kfail 0
gdb_test_multiple "return (int4) \{4, 2, 7, 6\}" $test {
pass $test
}
-re "The location .* is unknown.\r\n.* return value .* will be ignored.\r\n" {
+ # This happens, e.g., on s390x unless using the vector ABI.
set should_kfail 1
exp_continue
}
exp_continue
}
}
+
+gdb_test "next" ""
set test "verify vector return value"
-gdb_test_multiple "continue" $test {
- -re "4 2 7 6\r\n.*$gdb_prompt $" {
+gdb_test_multiple "p res" $test {
+ -re ".*= \\{4, 2, 7, 6\\}\r\n.*$gdb_prompt $" {
pass $test
}
- -re "10 20 48 72\r\n.*$gdb_prompt $" {
+ -re ".*= \\{.*\\}\r\n.*$gdb_prompt $" {
if { $should_kfail } {
+ # GDB had not actually set the return value, likely due to
+ # PR 8549. So accept any return value and emit a KFAIL.
kfail "gdb/8549" $test
} else {
fail $test