]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.cell/sizeof.exp
Update copyright year range in all GDB files.
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.cell / sizeof.exp
CommitLineData
42a4f53d 1# Copyright 2009-2019 Free Software Foundation, Inc.
1ea34204
UW
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# Check size of data types both on PPU and SPU.
20
21load_lib cell.exp
22
23set ppu_file "size"
24set ppu_src ${srcdir}/${subdir}/${ppu_file}.c
617cd4bc 25set ppu_bin [standard_output_file ${ppu_file}]
1ea34204
UW
26set spu_file "size-spu"
27set spu_src ${srcdir}/${subdir}/${spu_file}.c
617cd4bc 28set spu_bin [standard_output_file ${spu_file}]
1ea34204
UW
29
30if {[skip_cell_tests]} {
31 return 0
32}
33
34# Compile SPU binary.
35if { [gdb_compile_cell_spu $spu_src $spu_bin executable {debug}] != "" } {
bc6c7af4 36 unsupported "compiling spu binary failed."
1ea34204
UW
37 return -1
38}
39# Compile PPU binary.
40if { [gdb_cell_embedspu $spu_bin $spu_bin-embed.o {debug}] != "" } {
bc6c7af4 41 unsupported "embedding spu binary failed."
1ea34204
UW
42 return -1
43}
44if { [gdb_compile_cell_ppu [list $ppu_src $spu_bin-embed.o] $ppu_bin executable {debug}] != "" } {
bc6c7af4 45 unsupported "compiling ppu binary failed."
1ea34204
UW
46 return -1
47}
48
4c93b1db 49if [get_compiler_info] {
1ea34204
UW
50 return -1
51}
52
53
54# Ask GDB about the sizes of data types. This has
55# to be done in PPU thread and SPU thread.
56proc get_gdb_size { type } {
57 global gdb_prompt
58
59 set val "0"
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"
64 }
65 }
66 return ${val}
67}
68
69# Compare sizes from GDB and sizeof().
70proc size_compare { type gdb_size } {
71 set expr [string_to_regexp "sizeof(${type})=${gdb_size}"]
72 gdb_test "next" \
73 ".*" \
74 "next"
75 # Checks against string_to_regexp fails in remote testing.
76 if ![is_remote target] {
77 gdb_test "next" \
78 "${expr}.*" \
79 "check sizeof \"$type\" \"$gdb_size\" "
80 } else {
81 gdb_test "next" ".*" "check sizeof deactivate in remote testing"
82 }
83}
84
85gdb_exit
86gdb_start
87gdb_reinitialize_dir $srcdir/$subdir
88gdb_load ${ppu_bin}
89
90if ![runto_main] then {
bc6c7af4 91 fail "can't run to main"
1ea34204
UW
92 return 0
93}
94
95# Compare sizes.
96size_compare "char" [get_gdb_size "char"]
97size_compare "short" [get_gdb_size "short"]
98size_compare "int" [get_gdb_size "int"]
99size_compare "long" [get_gdb_size "long"]
100size_compare "long long" [get_gdb_size "long long"]
101size_compare "float" [get_gdb_size "float"]
102size_compare "double" [get_gdb_size "double"]
103size_compare "long double" [get_gdb_size "long double"]
104
105# Continue to SPU thread.
106cont_spu_main
107check_spu_arch ""
108
109# Compare sizes in SPU thread.
110size_compare "char" [get_gdb_size "char"]
111size_compare "short" [get_gdb_size "short"]
112size_compare "int" [get_gdb_size "int"]
113size_compare "long" [get_gdb_size "long"]
114size_compare "long long" [get_gdb_size "long long"]
115size_compare "float" [get_gdb_size "float"]
116size_compare "double" [get_gdb_size "double"]
117size_compare "long double" [get_gdb_size "long double"]
118
119gdb_exit
120return 0