]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.arch/altivec-abi.exp
* gdb.arch/altivec-abi.exp: Fix a typo.
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.arch / altivec-abi.exp
1 # Copyright (C) 2002, 2003, 2005, 2007, 2008, 2009, 2010
2 # Free Software Foundation, Inc.
3 #
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 3 of the License, or
7 # (at your option) any later version.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
16 #
17
18 # Tests for Powerpc AltiVec ABI
19
20
21 if $tracelevel then {
22 strace $tracelevel
23 }
24
25 #
26 # This file uses altivec-abi.c for input.
27 #
28
29 if {![istarget "powerpc*"] || [skip_altivec_tests]} then {
30 verbose "Skipping altivec abi tests."
31 return
32 }
33
34 set testfile "altivec-abi"
35 set binfile ${objdir}/${subdir}/${testfile}
36 set srcfile ${testfile}.c
37
38 if [get_compiler_info $binfile] {
39 warning "get_compiler failed"
40 return -1
41 }
42
43 proc altivec_abi_tests { extra_flags force_abi } {
44 global testfile binfile srcfile srcdir subdir
45 global gdb_prompt
46
47 set compile_flags "debug nowarnings $extra_flags"
48
49 if { [gdb_compile ${srcdir}/${subdir}/${srcfile} ${binfile} executable $compile_flags] != "" } {
50 untested altivec-abi.exp
51 return -1
52 }
53
54 if { "$force_abi" == "auto" } {
55 # If the toolchain does not record attributes, skip auto-ABI tests.
56 set readelf_program [transform readelf]
57 set result [catch "exec $readelf_program -A $binfile" output]
58
59 if {$result == 0 && ![regexp Tag_GNU_Power_ABI_Vector $output]} {
60 untested "ABI not marked"
61 return
62 }
63 }
64
65 gdb_exit
66 gdb_start
67 gdb_reinitialize_dir $srcdir/$subdir
68 gdb_load ${binfile}
69
70 # Run to `main' where we begin our tests.
71 if ![runto_main] then {
72 untested altivec-abi.exp
73 return -1
74 }
75
76 gdb_test "set print frame-arguments all"
77 gdb_test "set powerpc vector-abi $force_abi"
78
79 gdb_test "b marker" "Breakpoint 2 at.*file.*altivec-abi.c, line \[0-9\]+." "break marker"
80 gdb_test "continue" "Breakpoint 2.*marker.*altivec-abi.c.*" "continue to marker"
81 gdb_test "finish" "Run till exit from .0.*marker.*at.*altivec-abi.c.*main \\(\\) at.*altivec-abi.c.*result = vec_func \\(vshort,.*goes in v2.*" "back to main (1)"
82
83 # now all the arguments of vec_fun are initialized
84
85 set pattern "vec_func .vshort_f=.111, 222, 333, 444, 555, 666, 777, 888., vushort_f=.100, 200, 300, 400, 500, 600, 700, 800., vint_f=.-10, -20, -30, -40., vuint_f=.1111, 2222, 3333, 4444., vchar_f=.97 'a', 98 'b', 99 'c', 100 'd', 101 'e', 102 'f', 103 'g', 104 'h', 105 'i', 108 'l', 109 'm', 110 'n', 111 'o', 112 'p', 113 'q', 114 'r'., vuchar_f=.65 'A', 66 'B', 67 'C', 68 'D', 69 'E', 70 'F', 71 'G', 72 'H', 73 'I', 76 'L', 77 'M', 78 'N', 79 'O', 80 'P', 81 'Q', 82 'R'., vfloat_f=.1.25, 3.75, 5.5, 1.25., x_f=.1, 2, 3, 4, 5, 6, 7, 8., y_f=.12, 22, 32, 42., a_f=.118 'v', 101 'e', 99 'c', 116 't', 111 'o', 114 'r', 32 ' ', 111 'o', 102 'f', 32 ' ', 99 'c', 104 'h', 97 'a', 114 'r', 115 's', 46 '.'., b_f=.5.5, 4.5, 3.75, 2.25., c_f=.1.25, 3.5, 5.5, 7.75., intv_on_stack_f=.12, 34, 56, 78.."
86
87 set pattern1 $pattern
88 append pattern1 " at.*altivec-abi.c.*vint_res = vec_add.*vint_f, intv_on_stack_f.;"
89
90 # Now let's call the function. This function has > 12 args,
91 # the last one will go on the stack.
92 set msg "call inferior function with vectors (1)"
93 gdb_test "p vec_func(vshort,vushort,vint,vuint,vchar,vuchar,vfloat,x,y,a,b,c,intv_on_stack)" \
94 ".\[0-9\]+ = .2, 2, 2, 2." "call inferior function with vectors (1)"
95
96 # Let's call the function again with dummy arguments. This is to clean
97 # up the contents of the vector registers before the next call.
98 gdb_test "p vec_func(vshort_d,vushort_d,vint_d,vuint_d,vchar_d,vuchar_d,vfloat_d,x_d,y_d,a_d,b_d,c_d,intv_on_stack_d)" \
99 ".\[0-9\]+ = .0, 0, 0, 0." "call inferior function with vectors (2)"
100
101 # Attempt to take address of the return value of vec_func.
102 gdb_test "p &vec_func(vshort,vushort,vint,vuint,vchar,vuchar,vfloat,x,y,a,b,c,intv_on_stack)" \
103 "Attempt to take address of value not located in memory." \
104 "Attempt to take address of the return value of vec_func"
105
106 # Attempt to assign a value to the return value of vec_func.
107 gdb_test "set variable vec_func(vshort,vushort,vint,vuint,vchar,vuchar,vfloat,x,y,a,b,c,intv_on_stack) = {0,1,2,3}" \
108 "Left operand of assignment is not an lvalue." \
109 "Attempt to assign a value to the return value of vec_func"
110
111 # Let's step into the function, to see if the args are printed correctly.
112 gdb_test "step" \
113 $pattern1 \
114 "step into vec_fun"
115
116 set pattern2 $pattern
117 append pattern2 " at.*altivec-abi.c.*main.*result = vec_func .vshort,.*goes in v2.*Value returned is.*= .2, 2, 2, 2."
118
119 # Let's see if the result is returned correctly.
120 gdb_test "finish" "Run till exit from .0.*$pattern2" \
121 "vector value returned correctly"
122
123 # can we print the args correctly for this function?
124 gdb_test "break struct_of_vector_func" "" ""
125
126 set pattern "struct_of_vector_func .vector_struct=.vshort1 = .1, 2, 3, 4, 5, 6, 7, 8., vshort2 = .11, 12, 13, 14, 15, 16, 17, 18., vshort3 = .21, 22, 23, 24, 25, 26, 27, 28., vshort4 = .31, 32, 33, 34, 35, 36, 37, 38... at.*altivec-abi.c.*"
127
128 gdb_test "continue" \
129 "Breakpoint 3, $pattern.*vector_struct.vshort1 = vec_add .vector_struct.vshort1, vector_struct.vshort2.;" \
130 "continue to struct_of_vector_func"
131
132 gdb_test "finish" \
133 "Run till exit from .0 $pattern\[ \r\n\]+main.*altivec-abi.c.*array_of_vector_func.*" \
134 "back to main (2)"
135
136 gdb_test "step" "" "step into array_of_vector_func"
137 gdb_test "p matrix\[0\]" ".*= .1, 2, 3, 4, 5, 6, 7, 8." "print first vector"
138 gdb_test "p matrix\[1\]" ".*= .11, 12, 13, 14, 15, 16, 17, 18." "print second vector"
139 gdb_test "p matrix\[2\]" ".*= .21, 22, 23, 24, 25, 26, 27, 28." "print third vector"
140 gdb_test "p matrix\[3\]" ".*= .31, 32, 33, 34, 35, 36, 37, 38." "print fourth vector"
141 }
142
143 if [test_compiler_info gcc*] {
144 set saved_prefix $pf_prefix
145
146 set pf_prefix "${saved_prefix} default ABI, auto:"
147 altivec_abi_tests "additional_flags=-maltivec" "auto"
148
149 # On GNU/Linux, we can mix -mabi=no-altivec and -mabi=altivec.
150 # So test some combinations.
151 if { [istarget "powerpc*-linux*"] } {
152 set binfile ${objdir}/${subdir}/${testfile}-ge-ge
153 set pf_prefix "${saved_prefix} generic ABI, forced:"
154 altivec_abi_tests "additional_flags=-maltivec additional_flags=-mabi=no-altivec" "generic"
155
156 set binfile ${objdir}/${subdir}/${testfile}-av-av
157 set pf_prefix "${saved_prefix} AltiVec ABI, forced:"
158 altivec_abi_tests "additional_flags=-maltivec additional_flags=-mabi=altivec" "altivec"
159
160 set binfile ${objdir}/${subdir}/${testfile}-av-auto
161 set pf_prefix "${saved_prefix} AltiVec ABI, auto:"
162 altivec_abi_tests "additional_flags=-maltivec additional_flags=-mabi=altivec" "auto"
163 }
164 } elseif [test_compiler_info xlc*] {
165 altivec_abi_tests "additional_flags=-qaltivec" "auto"
166 } else {
167 warning "unknown compiler"
168 return -1
169 }