1 # Copyright (C) 1997, 1998
2 # Free Software Foundation, Inc.
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 2 of the License, or
7 # (at your option) any later version.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 # Please email any bugs, comments, and/or additions to this file to:
19 # bug-gdb@prep.ai.mit.edu
21 # This file was written by Elena Zannoni. (ezannoni@cygnus.com)
24 # This file is part of the gdb testsuite
27 # with elementary type variables and pointers.
36 # test running programs
41 set testfile "pointers2"
42 set srcfile ${testfile}.c
43 set binfile ${objdir}/${subdir}/${testfile}
45 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
46 gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
52 gdb_reinitialize_dir $srcdir/$subdir
57 # set it up at a breakpoint so we can play with the variable values
59 if ![runto_main] then {
60 perror "couldn't run to breakpoint"
64 send_gdb "break marker1\n" ; gdb_expect -re ".*$gdb_prompt $"
68 -re "Break.* marker1 \\(\\) at .*:$decimal.*$gdb_prompt $" {
71 -re ".*$gdb_prompt $" {}
72 timeout { fail "up from marker1" }
75 -re "$gdb_prompt $" { fail "continue to marker1" }
76 timeout { fail "(timeout) continue to marker1" }
80 send_gdb "print *pUC\n"
82 -re ".\[0-9\]* = 21 \'.025\'.*$gdb_prompt $" {
83 pass "print value of *pUC"
85 -re ".*$gdb_prompt $" { fail "print value of *pUC" }
86 timeout { fail "(timeout) print value of *pUC" }
90 send_gdb "ptype pUC\n"
92 -re "type = unsigned char \\*.*$gdb_prompt $" { pass "ptype pUC" }
93 -re ".*$gdb_prompt $" { fail "ptype pUC" }
94 timeout { fail "(timeout) ptype pUC" }
97 send_gdb "print *pS\n"
99 -re ".\[0-9\]* = -14.*$gdb_prompt $" {
100 pass "print value of *pS"
102 -re ".*$gdb_prompt $" { fail "print value of *pS" }
103 timeout { fail "(timeout) print value of *pS" }
107 send_gdb "ptype pS\n"
109 -re "type = short \\*.*$gdb_prompt $" { pass "ptype pS" }
110 -re "type = short int \\*.*$gdb_prompt $" { pass "ptype pS" }
111 -re ".*$gdb_prompt $" { fail "ptype pS" }
112 timeout { fail "(timeout) ptype pS" }
115 send_gdb "print *pUS\n"
117 -re ".\[0-9\]* = 7.*$gdb_prompt $" {
118 pass "print value of *pUS"
120 -re ".*$gdb_prompt $" { fail "print value of *pUS" }
121 timeout { fail "(timeout) print value of *pUS" }
125 send_gdb "ptype pUS\n"
127 -re "type = unsigned short \\*.*$gdb_prompt $" { pass "ptype pUS" }
128 -re "type = short unsigned int \\*.*$gdb_prompt $" { pass "ptype pUS" }
129 -re ".*$gdb_prompt $" { fail "ptype pUS" }
130 timeout { fail "(timeout) ptype pUS" }
133 send_gdb "print *pI\n"
135 -re ".\[0-9\]* = 102.*$gdb_prompt $" {
136 pass "print value of *pI"
138 -re ".*$gdb_prompt $" { fail "print value of *pI" }
139 timeout { fail "(timeout) print value of *pI" }
143 send_gdb "ptype pI\n"
145 -re "type = int \\*.*$gdb_prompt $" { pass "ptype pI" }
146 -re ".*$gdb_prompt $" { fail "ptype pI" }
147 timeout { fail "(timeout) ptype pI" }
150 send_gdb "print *pUI\n"
152 -re ".\[0-9\]* = 1002.*$gdb_prompt $" {
153 pass "print value of *pUI"
155 -re ".*$gdb_prompt $" { fail "print value of *pUI" }
156 timeout { fail "(timeout) print value of *pUI" }
160 send_gdb "ptype pUI\n"
162 -re "type = unsigned int \\*.*$gdb_prompt $" { pass "ptype pUI" }
163 -re ".*$gdb_prompt $" { fail "ptype pUI" }
164 timeout { fail "(timeout) ptype pUI" }
167 send_gdb "print *pL\n"
169 -re ".\[0-9\]* = -234.*$gdb_prompt $" {
170 pass "print value of *pL"
172 -re ".*$gdb_prompt $" { fail "print value of *pL" }
173 timeout { fail "(timeout) print value of *pL" }
177 send_gdb "ptype pL\n"
179 -re "type = long \\*.*$gdb_prompt $" { pass "ptype pL" }
180 -re "type = long int \\*.*$gdb_prompt $" { pass "ptype pL" }
181 -re ".*$gdb_prompt $" { fail "ptype pL" }
182 timeout { fail "(timeout) ptype pL" }
185 send_gdb "print *pUL\n"
187 -re ".\[0-9\]* = 234.*$gdb_prompt $" {
188 pass "print value of *pUL"
190 -re ".*$gdb_prompt $" { fail "print value of *pUL" }
191 timeout { fail "(timeout) print value of *pUL" }
195 send_gdb "ptype pUL\n"
197 -re "type = unsigned long \\*.*$gdb_prompt $" { pass "ptype pUL" }
198 -re "type = long unsigned int \\*.*$gdb_prompt $" { pass "ptype pUL" }
199 -re ".*$gdb_prompt $" { fail "ptype pUL" }
200 timeout { fail "(timeout) ptype pUL" }
203 send_gdb "print *pF\n"
205 -re ".\[0-9\]* = 1.2\[0-9\]*e\\+10.*$gdb_prompt $" {
206 pass "print value of *pF"
208 -re ".*$gdb_prompt $" { fail "print value of *pF" }
209 timeout { fail "(timeout) print value of *pF" }
213 send_gdb "ptype pF\n"
215 -re "type = float \\*.*$gdb_prompt $" { pass "ptype pF" }
216 -re ".*$gdb_prompt $" { fail "ptype pF" }
217 timeout { fail "(timeout) ptype pF" }
220 send_gdb "print *pD\n"
222 -re ".\[0-9\]* = -1.375e-123.*$gdb_prompt $" {
223 pass "print value of *pD"
225 -re ".*$gdb_prompt $" { fail "print value of *pD" }
226 timeout { fail "(timeout) print value of *pD" }
230 send_gdb "ptype pD\n"
232 -re "type = double \\*.*$gdb_prompt $" { pass "ptype pD" }
233 -re ".*$gdb_prompt $" { fail "ptype pD" }
234 timeout { fail "(timeout) ptype pD" }
237 send_gdb "print ******ppppppC\n"
239 -re ".\[0-9\]* = 65 \'A\'.*$gdb_prompt $" {
240 pass "print value of ******ppppppC"
242 -re ".*$gdb_prompt $" { fail "print value of ******ppppppC" }
243 timeout { fail "(timeout) print value of ******ppppppC" }
247 send_gdb "ptype pC\n"
249 -re "type = char \\*.*$gdb_prompt $" { pass "ptype pC" }
250 -re ".*$gdb_prompt $" { fail "ptype pC" }
251 timeout { fail "(timeout) ptype pC" }
254 send_gdb "ptype ppC\n"
256 -re "type = char \\*\\*.*$gdb_prompt $" { pass "ptype ppC" }
257 -re ".*$gdb_prompt $" { fail "ptype ppC" }
258 timeout { fail "(timeout) ptype ppC" }
261 send_gdb "ptype pppC\n"
263 -re "type = char \\*\\*\\*.*$gdb_prompt $" { pass "ptype pppC" }
264 -re ".*$gdb_prompt $" { fail "ptype pppC" }
265 timeout { fail "(timeout) ptype pppC" }
268 send_gdb "ptype ppppC\n"
270 -re "type = char \\*\\*\\*\\*.*$gdb_prompt $" { pass "ptype ppppC" }
271 -re ".*$gdb_prompt $" { fail "ptype ppppC" }
272 timeout { fail "(timeout) ptype ppppC" }
275 send_gdb "ptype pppppC\n"
277 -re "type = char \\*\\*\\*\\*\\*.*$gdb_prompt $" { pass "ptype pppppC" }
278 -re ".*$gdb_prompt $" { fail "ptype pppppC" }
279 timeout { fail "(timeout) ptype pppppC" }
282 send_gdb "ptype ppppppC\n"
284 -re "type = char \\*\\*\\*\\*\\*\\*.*$gdb_prompt $" { pass "ptype ppppppC" }
285 -re ".*$gdb_prompt $" { fail "ptype ppppppC" }
286 timeout { fail "(timeout) ptype ppppppC" }