1 # Copyright 2009 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 # Check size of data types both on PPU and SPU.
24 set ppu_src ${srcdir}/${subdir}/${ppu_file}.c
25 set ppu_bin ${objdir}/${subdir}/${ppu_file}
26 set spu_file "size-spu"
27 set spu_src ${srcdir}/${subdir}/${spu_file}.c
28 set spu_bin ${objdir}/${subdir}/${spu_file}
30 if {[skip_cell_tests]} {
35 if { [gdb_compile_cell_spu $spu_src $spu_bin executable {debug}] != "" } {
36 unsupported "Compiling spu binary failed."
40 if { [gdb_cell_embedspu $spu_bin $spu_bin-embed.o {debug}] != "" } {
41 unsupported "Embedding spu binary failed."
44 if { [gdb_compile_cell_ppu [list $ppu_src $spu_bin-embed.o] $ppu_bin executable {debug}] != "" } {
45 unsupported "Compiling ppu binary failed."
49 if [get_compiler_info ${ppu_bin}] {
54 # Ask GDB about the sizes of data types. This has
55 # to be done in PPU thread and SPU thread.
56 proc get_gdb_size { type } {
60 gdb_test_multiple "print/d sizeof(${type})" "get sizeof(${type})" {
61 -re "\\$\[0-9\]* = (\[-\]*\[0-9\]*).*$gdb_prompt $" {
62 set val $expect_out(1,string)
63 pass "get sizeof ($type) = $val"
69 # Compare sizes from GDB and sizeof().
70 proc size_compare { type gdb_size } {
71 set expr [string_to_regexp "sizeof(${type})=${gdb_size}"]
75 # Checks against string_to_regexp fails in remote testing.
76 if ![is_remote target] {
79 "check sizeof \"$type\" \"$gdb_size\" "
81 gdb_test "next" ".*" "check sizeof deactivate in remote testing"
87 gdb_reinitialize_dir $srcdir/$subdir
90 if ![runto_main] then {
91 fail "Can't run to main"
96 size_compare "char" [get_gdb_size "char"]
97 size_compare "short" [get_gdb_size "short"]
98 size_compare "int" [get_gdb_size "int"]
99 size_compare "long" [get_gdb_size "long"]
100 size_compare "long long" [get_gdb_size "long long"]
101 size_compare "float" [get_gdb_size "float"]
102 size_compare "double" [get_gdb_size "double"]
103 size_compare "long double" [get_gdb_size "long double"]
105 # Continue to SPU thread.
109 # Compare sizes in SPU thread.
110 size_compare "char" [get_gdb_size "char"]
111 size_compare "short" [get_gdb_size "short"]
112 size_compare "int" [get_gdb_size "int"]
113 size_compare "long" [get_gdb_size "long"]
114 size_compare "long long" [get_gdb_size "long long"]
115 size_compare "float" [get_gdb_size "float"]
116 size_compare "double" [get_gdb_size "double"]
117 size_compare "long double" [get_gdb_size "long double"]