1 # Copyright 2009-2016 Free Software Foundation, Inc.
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.
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.
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/>.
16 # Contributed by Markus Deuling <deuling@de.ibm.com>.
18 # Testsuite for Cell Broadband Engine combined debugger
19 # This testcases tests on PPU and SPU if variables and registers are accessible
20 # via print and set by using names and adresses.
24 set ppu_file "mem-access"
25 set ppu_src ${srcdir}/${subdir}/${ppu_file}.c
26 set ppu_bin ${objdir}/${subdir}/${ppu_file}
27 set spu_file "mem-access-spu"
28 set spu_src ${srcdir}/${subdir}/${spu_file}.c
29 set spu_bin ${objdir}/${subdir}/${spu_file}
31 if {[skip_cell_tests]} {
36 if { [gdb_compile_cell_spu $spu_src $spu_bin executable {debug}] != "" } {
37 unsupported "Compiling spu binary failed."
41 if { [gdb_cell_embedspu $spu_bin $spu_bin-embed.o {debug}] != "" } {
42 unsupported "Embedding spu binary failed."
45 if { [gdb_compile_cell_ppu [list $ppu_src $spu_bin-embed.o] $ppu_bin executable {debug}] != "" } {
46 unsupported "Compiling ppu binary failed."
50 if [get_compiler_info] {
54 # Get the adress to symbol name. If $reg
55 # is set to 1, get address from a register.
56 proc get_adress_from_name { name reg } {
66 gdb_test_multiple $q "get address from $name" {
67 -re "(0x.....):.*$gdb_prompt $" { # Registers.
68 set adr $expect_out(1,string)
69 pass "get adress from $name = $adr"
71 -re "(0x........) <.*$gdb_prompt $" { # PPU address.
72 set adr $expect_out(1,string)
73 pass "get adress from $name = $adr"
75 -re "(0x....) <.*$gdb_prompt $" { # SPU address.
76 set adr $expect_out(1,string)
77 pass "get adress from $name = $adr"
79 -re "(0x...) <.*$gdb_prompt $" { # SPU address.
80 set adr $expect_out(1,string)
81 pass "get adress from $name = $adr"
88 # Try to set a $value at adress $adr.
89 proc set_adr_content { adr value } {
90 gdb_test "set *$adr=$value" \
95 # Try to set a $value for $symbol.
96 proc set_symbol_content { symbol value } {
97 gdb_test "set $symbol=$value" \
102 # Check if $value is at *adr
103 proc test_adr_content { adr value } {
106 "(ptr) *$adr==$value"
109 proc test_symbol_content { symbol value } {
110 gdb_test "p $symbol" \
112 "(symbol) $symbol==$value"
115 # Check VARNAME. Check if it has the inital
116 # value INITIALVALUE. Set it to NEWVALUE.
117 # Check if set properly. Do it via symbols and
119 proc check_var { varname initalvalue newvalue } {
121 # Initial value should be $initalvalue.
122 test_symbol_content $varname $initalvalue
124 # Get pointer to symbol and check if the
125 # initial value is found.
126 set adr [get_adress_from_name $varname 0]
127 test_adr_content $adr $initalvalue
129 # Re-set value using the pointer.
130 set_adr_content $adr $newvalue
132 # Test values by pointer and by symbol.
133 test_adr_content $adr $newvalue
134 test_symbol_content $varname $newvalue
136 # Set value back to initalvalue using symbol
138 set_symbol_content $varname $initalvalue
139 test_adr_content $adr $initalvalue
140 test_symbol_content $varname $initalvalue
145 gdb_reinitialize_dir $srcdir/$subdir
148 if ![runto_main] then {
149 fail "Can't run to main"
153 # Check in PPU thread.
154 c_to "Marker PPUEA" $ppu_file.c
155 check_var "test_var" 5 7
159 c_to "Marker SPUEA" $spu_file.c
162 # Check in SPU thread.
163 check_var "test_var" 5 7
164 # Check $sp register.
165 set adr [get_adress_from_name "\$sp" 1]
166 set_adr_content $adr 8
167 test_adr_content $adr 8