2002-05-14 Elena Zannoni <ezannoni@redhat.com>
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.arch / altivec-abi.exp
1 # Copyright (C) 2002 Free Software Foundation, Inc.
2 #
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 2 of the License, or
6 # (at your option) any later version.
7 #
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
12 #
13 # You should have received a copy of the GNU General Public License
14 # along with this program; if not, write to the Free Software
15 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
16 #
17 # Please email any bugs, comments, and/or additions to this file to:
18 # bug-gdb@prep.ai.mit.edu
19 #
20
21 # Tests for Powerpc AltiVec ABI
22
23
24 if $tracelevel then {
25 strace $tracelevel
26 }
27
28 #
29 # This file uses altivec.c for input.
30 #
31
32 set prms_id 0
33 set bug_id 0
34
35 if ![istarget "powerpc-*altivec"] then {
36 verbose "Skipping altivec abi tests."
37 return
38 }
39
40 set testfile "altivec"
41 set binfile ${objdir}/${subdir}/${testfile}
42
43 set src1 ${srcdir}/${subdir}/${testfile}.c
44
45 if { [gdb_compile ${src1} ${binfile} executable {debug additional_flags=-w}] != "" } {
46 gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
47 }
48
49 gdb_start
50 gdb_reinitialize_dir $srcdir/$subdir
51 gdb_load ${binfile}
52
53 #
54 # Run to `main' where we begin our tests.
55 #
56
57 if ![runto_main] then {
58 gdb_suppress_tests
59 }
60
61 gdb_test "b marker" "Breakpoint 2 at.*file.*altivec.c, line \[0-9\]+." "break marker"
62 gdb_test "continue" "Breakpoint 2.*marker.*altivec.c.*" "continue to marker"
63 gdb_test "finish" "Run till exit from .0.*in marker.*at.*altivec.c.*main \\(\\) at.*altivec.c.*result = vec_func \\(vshort,.*goes in v2.*" "back to main (1)"
64
65 # now all the arguments of vec_fun are initialized
66
67 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=.abcdefghilmnopqr., vuchar_f=.ABCDEFGHILMNOPQR., 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=.vector of chars.., 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.."
68
69 set pattern1 $pattern
70 append pattern1 " at.*altivec.c.*vint_res = vec_add.*vint_f, intv_on_stack_f.;"
71
72 # Now let's call the function. This function has > 12 args,
73 # the last one will go on the stack.
74 gdb_test "p vec_func(vshort,vushort,vint,vuint,vchar,vuchar,vfloat,x,y,a,b,c,intv_on_stack)" \
75 ".\[0-9\]+ = .2, 2, 2, 2." "call inferior function with vectors (1) "
76
77 # Let's call the function again with dummy arguments. This is to clean
78 # up the contents of the vector registers before the next call.
79 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)" \
80 ".\[0-9\]+ = .0, 0, 0, 0." "call inferior function with vectors (2) "
81
82 # Let's step into the function, to see if the args are printed correctly.
83 gdb_test "step" \
84 $pattern1 \
85 "step into vec_fun"
86
87 set pattern2 $pattern
88 append pattern2 " at.*altivec.c.*in main.*result = vec_func .vshort,.*goes in v2.*Value returned is.*= .2, 2, 2, 2."
89
90 # Let's see if the result is returned correctly.
91 gdb_test "finish" \
92 "Run till exit from .0.*$pattern2" \
93 "vector value returned correctly"
94
95 # can we print the args correctly for this function?
96 gdb_test "break struct_of_vector_func" "" ""
97
98 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.c.*"
99
100 gdb_test "continue" \
101 "Breakpoint 3, $pattern.*vector_struct.vshort1 = vec_add .vector_struct.vshort1, vector_struct.vshort2.;" \
102 "continue to struct_of_vector_func"
103
104 gdb_test "finish" \
105 "Run till exit from .0 $pattern\[ \r\n\]+main.*altivec.c.*array_of_vector_func.*" \
106 "back to main (2)"
107
108 gdb_test "step" "" "step into array_of_vector_func"
109 gdb_test "p matrix\[0\]" ".*= .1, 2, 3, 4, 5, 6, 7, 8." "print first vector"
110 gdb_test "p matrix\[1\]" ".*= .11, 12, 13, 14, 15, 16, 17, 18." "print second vector"
111 gdb_test "p matrix\[2\]" ".*= .21, 22, 23, 24, 25, 26, 27, 28." "print third vector"
112 gdb_test "p matrix\[3\]" ".*= .31, 32, 33, 34, 35, 36, 37, 38." "print fourth vector"
113
This page took 0.132123 seconds and 4 git commands to generate.