Imported Upstream version 7.5
[platform/upstream/gdb.git] / gdb / testsuite / gdb.cell / data.exp
1 # Copyright 2009, 2011-2012 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 3 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, see <http://www.gnu.org/licenses/>.
15 #
16 # Contributed by Markus Deuling <deuling@de.ibm.com>.
17 #
18 # Testsuite for Cell Broadband Engine combined debugger
19 # This testcases tries to read variables of each kind both on PPU and SPU.
20
21 load_lib cell.exp
22
23 set testfile "data"
24 set ppu_file "data"
25 set ppu_src ${srcdir}/${subdir}/${ppu_file}.c
26 set ppu_bin ${objdir}/${subdir}/${ppu_file}
27 set spu_file "data-spu"
28 set spu_src ${srcdir}/${subdir}/${spu_file}.c
29 set spu_bin ${objdir}/${subdir}/${spu_file}
30
31 if {[skip_cell_tests]} {
32     return 0
33 }
34
35 # Compile SPU binary.
36 if { [gdb_compile_cell_spu $spu_src $spu_bin executable {debug}]  != "" } {
37   unsupported "Compiling spu binary failed."
38   return -1
39 }
40 # Compile PPU binary.
41 if { [gdb_cell_embedspu $spu_bin $spu_bin-embed.o {debug}]  != "" } {
42   unsupported "Embedding spu binary failed."
43   return -1
44 }
45 if { [gdb_compile_cell_ppu [list $ppu_src $spu_bin-embed.o] $ppu_bin executable {debug}] != "" } {
46   unsupported "Compiling ppu binary failed."
47   return -1
48 }
49
50 if [get_compiler_info] {
51   return -1
52 }
53
54 proc check_var { name value } {
55   gdb_test "print $name" \
56            ".*=.*$value" \
57            "check_var $name = $value"
58 }
59
60 proc set_var { name value } {
61   gdb_test "set var $name = $value" \
62            "" \
63            "set var $name = $value"
64 }
65
66 proc dotest { name value } {
67   set_var $name $value
68   check_var $name $value
69 }
70
71 gdb_exit
72 gdb_start
73 gdb_reinitialize_dir $srcdir/$subdir
74 gdb_load ${ppu_bin}
75
76 if ![runto_main] then {
77   fail "Can't run to main"
78   return 0
79 }
80
81 # Set values.
82 dotest var_char 'z'
83 dotest var_short 8
84 dotest var_int 321
85 dotest var_long 523442
86 dotest var_longlong 235354533
87 xfail "dotest var_float 33.2113"
88 xfail "dotest var_double 2.3456"
89 xfail "dotest var_longdouble 3.456789"
90
91 gdb_test "break 55" \
92          "Breakpoint.*at.*file.*$testfile.c, line 55.*" \
93          "set breakpoint"
94 gdb_test "continue" \
95          "Breakpoint.*at.*$testfile.c.*55.*" \
96          "continue to bp at line 55"
97
98 # Lookup variables.
99 check_var var_char 'c'
100 check_var var_short 7
101 check_var var_int 1337
102 check_var var_long 123456
103 check_var var_longlong 123456789
104 xfail "check_var var_float 1.23"
105 xfail "check_var var_double 2.3456"
106 xfail "check_var var_longdouble 3.456789"
107
108 cont_spu_main
109 c_to "Marker SPU End" $spu_file.c
110
111 # In SPU Thread, arch should now be spu:256K.
112 check_spu_arch ""
113
114 # Lookup variables.
115 check_var var_char 'c'
116 check_var var_short 7
117 check_var var_int 1337
118 check_var var_long 123456
119 check_var var_longlong 123456789
120 xfail "check_var var_float 1.23"
121 xfail "check_var var_double 2.3456"
122 xfail "check_var var_longdouble 3.456789"
123
124 gdb_exit
125 return 0