Commit | Line | Data |
---|---|---|
c906108c SS |
1 | # Copyright (C) 1997, 1998 |
2 | # Free Software Foundation, Inc. | |
3 | ||
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. | |
8 | # | |
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. | |
13 | # | |
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. | |
17 | ||
18 | # Please email any bugs, comments, and/or additions to this file to: | |
19 | # bug-gdb@prep.ai.mit.edu | |
20 | ||
21 | # This file was written by Elena Zannoni. (ezannoni@cygnus.com) | |
22 | ||
23 | ||
24 | # This file is part of the gdb testsuite | |
25 | # | |
26 | # tests for pointers | |
27 | # with elementary type variables and pointers. | |
28 | # | |
29 | ||
30 | ||
31 | if $tracelevel then { | |
32 | strace $tracelevel | |
33 | } | |
34 | ||
35 | # | |
36 | # test running programs | |
37 | # | |
38 | set prms_id 0 | |
39 | set bug_id 0 | |
40 | ||
41 | set testfile "pointers2" | |
42 | set srcfile ${testfile}.c | |
43 | set binfile ${objdir}/${subdir}/${testfile} | |
44 | ||
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." | |
47 | } | |
48 | ||
49 | ||
50 | gdb_exit | |
51 | gdb_start | |
52 | gdb_reinitialize_dir $srcdir/$subdir | |
53 | gdb_load ${binfile} | |
54 | ||
55 | ||
56 | # | |
57 | # set it up at a breakpoint so we can play with the variable values | |
58 | # | |
59 | if ![runto_main] then { | |
60 | perror "couldn't run to breakpoint" | |
61 | continue | |
62 | } | |
63 | ||
64 | send_gdb "break marker1\n" ; gdb_expect -re ".*$gdb_prompt $" | |
65 | ||
66 | send_gdb "cont\n" | |
67 | gdb_expect { | |
68 | -re "Break.* marker1 \\(\\) at .*:$decimal.*$gdb_prompt $" { | |
69 | send_gdb "up\n" | |
70 | gdb_expect { | |
71 | -re ".*$gdb_prompt $" {} | |
72 | timeout { fail "up from marker1" } | |
73 | } | |
74 | } | |
75 | -re "$gdb_prompt $" { fail "continue to marker1" } | |
76 | timeout { fail "(timeout) continue to marker1" } | |
77 | } | |
78 | ||
79 | ||
80 | send_gdb "print *pUC\n" | |
81 | gdb_expect { | |
82 | -re ".\[0-9\]* = 21 \'.025\'.*$gdb_prompt $" { | |
83 | pass "print value of *pUC" | |
84 | } | |
85 | -re ".*$gdb_prompt $" { fail "print value of *pUC" } | |
86 | timeout { fail "(timeout) print value of *pUC" } | |
87 | } | |
88 | ||
89 | ||
90 | send_gdb "ptype pUC\n" | |
91 | gdb_expect { | |
92 | -re "type = unsigned char \\*.*$gdb_prompt $" { pass "ptype pUC" } | |
93 | -re ".*$gdb_prompt $" { fail "ptype pUC" } | |
94 | timeout { fail "(timeout) ptype pUC" } | |
95 | } | |
96 | ||
97 | send_gdb "print *pS\n" | |
98 | gdb_expect { | |
99 | -re ".\[0-9\]* = -14.*$gdb_prompt $" { | |
100 | pass "print value of *pS" | |
101 | } | |
102 | -re ".*$gdb_prompt $" { fail "print value of *pS" } | |
103 | timeout { fail "(timeout) print value of *pS" } | |
104 | } | |
105 | ||
106 | ||
107 | send_gdb "ptype pS\n" | |
108 | gdb_expect { | |
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" } | |
113 | } | |
114 | ||
115 | send_gdb "print *pUS\n" | |
116 | gdb_expect { | |
117 | -re ".\[0-9\]* = 7.*$gdb_prompt $" { | |
118 | pass "print value of *pUS" | |
119 | } | |
120 | -re ".*$gdb_prompt $" { fail "print value of *pUS" } | |
121 | timeout { fail "(timeout) print value of *pUS" } | |
122 | } | |
123 | ||
124 | ||
125 | send_gdb "ptype pUS\n" | |
126 | gdb_expect { | |
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" } | |
131 | } | |
132 | ||
133 | send_gdb "print *pI\n" | |
134 | gdb_expect { | |
135 | -re ".\[0-9\]* = 102.*$gdb_prompt $" { | |
136 | pass "print value of *pI" | |
137 | } | |
138 | -re ".*$gdb_prompt $" { fail "print value of *pI" } | |
139 | timeout { fail "(timeout) print value of *pI" } | |
140 | } | |
141 | ||
142 | ||
143 | send_gdb "ptype pI\n" | |
144 | gdb_expect { | |
145 | -re "type = int \\*.*$gdb_prompt $" { pass "ptype pI" } | |
146 | -re ".*$gdb_prompt $" { fail "ptype pI" } | |
147 | timeout { fail "(timeout) ptype pI" } | |
148 | } | |
149 | ||
150 | send_gdb "print *pUI\n" | |
151 | gdb_expect { | |
152 | -re ".\[0-9\]* = 1002.*$gdb_prompt $" { | |
153 | pass "print value of *pUI" | |
154 | } | |
155 | -re ".*$gdb_prompt $" { fail "print value of *pUI" } | |
156 | timeout { fail "(timeout) print value of *pUI" } | |
157 | } | |
158 | ||
159 | ||
160 | send_gdb "ptype pUI\n" | |
161 | gdb_expect { | |
162 | -re "type = unsigned int \\*.*$gdb_prompt $" { pass "ptype pUI" } | |
163 | -re ".*$gdb_prompt $" { fail "ptype pUI" } | |
164 | timeout { fail "(timeout) ptype pUI" } | |
165 | } | |
166 | ||
167 | send_gdb "print *pL\n" | |
168 | gdb_expect { | |
169 | -re ".\[0-9\]* = -234.*$gdb_prompt $" { | |
170 | pass "print value of *pL" | |
171 | } | |
172 | -re ".*$gdb_prompt $" { fail "print value of *pL" } | |
173 | timeout { fail "(timeout) print value of *pL" } | |
174 | } | |
175 | ||
176 | ||
177 | send_gdb "ptype pL\n" | |
178 | gdb_expect { | |
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" } | |
183 | } | |
184 | ||
185 | send_gdb "print *pUL\n" | |
186 | gdb_expect { | |
187 | -re ".\[0-9\]* = 234.*$gdb_prompt $" { | |
188 | pass "print value of *pUL" | |
189 | } | |
190 | -re ".*$gdb_prompt $" { fail "print value of *pUL" } | |
191 | timeout { fail "(timeout) print value of *pUL" } | |
192 | } | |
193 | ||
194 | ||
195 | send_gdb "ptype pUL\n" | |
196 | gdb_expect { | |
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" } | |
201 | } | |
202 | ||
203 | send_gdb "print *pF\n" | |
204 | gdb_expect { | |
205 | -re ".\[0-9\]* = 1.2\[0-9\]*e\\+10.*$gdb_prompt $" { | |
206 | pass "print value of *pF" | |
207 | } | |
208 | -re ".*$gdb_prompt $" { fail "print value of *pF" } | |
209 | timeout { fail "(timeout) print value of *pF" } | |
210 | } | |
211 | ||
212 | ||
213 | send_gdb "ptype pF\n" | |
214 | gdb_expect { | |
215 | -re "type = float \\*.*$gdb_prompt $" { pass "ptype pF" } | |
216 | -re ".*$gdb_prompt $" { fail "ptype pF" } | |
217 | timeout { fail "(timeout) ptype pF" } | |
218 | } | |
219 | ||
220 | send_gdb "print *pD\n" | |
221 | gdb_expect { | |
222 | -re ".\[0-9\]* = -1.375e-123.*$gdb_prompt $" { | |
223 | pass "print value of *pD" | |
224 | } | |
225 | -re ".*$gdb_prompt $" { fail "print value of *pD" } | |
226 | timeout { fail "(timeout) print value of *pD" } | |
227 | } | |
228 | ||
229 | ||
230 | send_gdb "ptype pD\n" | |
231 | gdb_expect { | |
232 | -re "type = double \\*.*$gdb_prompt $" { pass "ptype pD" } | |
233 | -re ".*$gdb_prompt $" { fail "ptype pD" } | |
234 | timeout { fail "(timeout) ptype pD" } | |
235 | } | |
236 | ||
237 | send_gdb "print ******ppppppC\n" | |
238 | gdb_expect { | |
239 | -re ".\[0-9\]* = 65 \'A\'.*$gdb_prompt $" { | |
240 | pass "print value of ******ppppppC" | |
241 | } | |
242 | -re ".*$gdb_prompt $" { fail "print value of ******ppppppC" } | |
243 | timeout { fail "(timeout) print value of ******ppppppC" } | |
244 | } | |
245 | ||
246 | ||
247 | send_gdb "ptype pC\n" | |
248 | gdb_expect { | |
249 | -re "type = char \\*.*$gdb_prompt $" { pass "ptype pC" } | |
250 | -re ".*$gdb_prompt $" { fail "ptype pC" } | |
251 | timeout { fail "(timeout) ptype pC" } | |
252 | } | |
253 | ||
254 | send_gdb "ptype ppC\n" | |
255 | gdb_expect { | |
256 | -re "type = char \\*\\*.*$gdb_prompt $" { pass "ptype ppC" } | |
257 | -re ".*$gdb_prompt $" { fail "ptype ppC" } | |
258 | timeout { fail "(timeout) ptype ppC" } | |
259 | } | |
260 | ||
261 | send_gdb "ptype pppC\n" | |
262 | gdb_expect { | |
263 | -re "type = char \\*\\*\\*.*$gdb_prompt $" { pass "ptype pppC" } | |
264 | -re ".*$gdb_prompt $" { fail "ptype pppC" } | |
265 | timeout { fail "(timeout) ptype pppC" } | |
266 | } | |
267 | ||
268 | send_gdb "ptype ppppC\n" | |
269 | gdb_expect { | |
270 | -re "type = char \\*\\*\\*\\*.*$gdb_prompt $" { pass "ptype ppppC" } | |
271 | -re ".*$gdb_prompt $" { fail "ptype ppppC" } | |
272 | timeout { fail "(timeout) ptype ppppC" } | |
273 | } | |
274 | ||
275 | send_gdb "ptype pppppC\n" | |
276 | gdb_expect { | |
277 | -re "type = char \\*\\*\\*\\*\\*.*$gdb_prompt $" { pass "ptype pppppC" } | |
278 | -re ".*$gdb_prompt $" { fail "ptype pppppC" } | |
279 | timeout { fail "(timeout) ptype pppppC" } | |
280 | } | |
281 | ||
282 | send_gdb "ptype ppppppC\n" | |
283 | gdb_expect { | |
284 | -re "type = char \\*\\*\\*\\*\\*\\*.*$gdb_prompt $" { pass "ptype ppppppC" } | |
285 | -re ".*$gdb_prompt $" { fail "ptype ppppppC" } | |
286 | timeout { fail "(timeout) ptype ppppppC" } | |
287 | } | |
288 |