OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [gdb-5.0/] [gdb/] [testsuite/] [gdb.base/] [setvar.exp] - Blame information for rev 107

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 106 markom
#   Copyright (C) 1997 Free Software Foundation, Inc.
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 2 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, write to the Free Software
15
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
16
 
17
# Please email any bugs, comments, and/or additions to this file to:
18
# bug-gdb@prep.ai.mit.edu
19
 
20
#   Copyright (C) 1988, 1990, 1991, 1992, 1994, 1995
21
#   Free Software Foundation, Inc.
22
 
23
# This program is free software; you can redistribute it and/or modify
24
# it under the terms of the GNU General Public License as published by
25
# the Free Software Foundation; either version 2 of the License, or
26
# (at your option) any later version.
27
#
28
# This program is distributed in the hope that it will be useful,
29
# but WITHOUT ANY WARRANTY; without even the implied warranty of
30
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
31
# GNU General Public License for more details.
32
#
33
# You should have received a copy of the GNU General Public License
34
# along with this program; if not, write to the Free Software
35
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
36
 
37
# Please email any bugs, comments, and/or additions to this file to:
38
# bug-gdb@prep.ai.mit.edu
39
 
40
# This file was written by Rob Savoye. (rob@cygnus.com)
41
 
42
if $tracelevel then {
43
        strace $tracelevel
44
        }
45
 
46
#
47
# test running programs
48
#
49
set prms_id 0
50
set bug_id 0
51
 
52
set testfile "setvar"
53
set srcfile ${testfile}.c
54
set binfile ${objdir}/${subdir}/${testfile}
55
if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
56
     gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
57
}
58
 
59
# Create and source the file that provides information about the compiler
60
# used to compile the test case.
61
if [get_compiler_info ${binfile}] {
62
    return -1;
63
}
64
 
65
gdb_exit
66
gdb_start
67
gdb_reinitialize_dir $srcdir/$subdir
68
gdb_load $binfile
69
 
70
#
71
# set it up at a breakpoint so we canplay with the variable values
72
#
73
send_gdb "set print sevenbit-strings\n" ; gdb_expect -re "$gdb_prompt $"
74
 
75
if ![runto_main] then {
76
    perror "couldn't run to breakpoint"
77
    continue
78
}
79
 
80
# Determine expected output for unsigned long variables,
81
# the output varies with sizeof (unsigned long).
82
 
83
set ulong_minus_1 4294967295
84
set ulong_minus_456 4294966840
85
send_gdb "print sizeof (unsigned long)\n"
86
gdb_expect {
87
    -re ".\[0-9\]* = 4.*$gdb_prompt $" {}
88
    -re ".\[0-9\]* = 8.*$gdb_prompt $" {
89
        set ulong_minus_1 18446744073709551615
90
        set ulong_minus_456 18446744073709551160
91
    }
92
    -re ".*$gdb_prompt $" {
93
         fail "getting sizeof unsigned long"
94
    }
95
    default     { fail "(timeout) getting sizeof unsigned long" }
96
}
97
 
98
proc test_set { args } {
99
    global gdb_prompt
100
 
101
    set length [expr [llength $args] - 1];
102
    set message "[lindex $args $length]";
103
    set final [expr $length - 2];
104
    set count 1;
105
 
106
    # Set up the variables.
107
    for {set x 0;} {$x < $length} {incr x;} {
108
        if { "[lindex $args $x]" != "" } {
109
            set arg [lindex $args $x];
110
            if { ($x == $final) || ([string first ".*" [lindex $args [expr $x + 1]]] >= 0) } {
111
                set match [lindex $args [expr $x + 1]];
112
                if { $count == 1 } {
113
                    set mess "$message"
114
                } else {
115
                    set mess "$message (#$count)";
116
                }
117
                incr count;
118
                incr x;
119
            } else {
120
                set mess "";
121
                set match ""
122
            }
123
            verbose "doing $arg $match"
124
            if [gdb_test "$arg" "$match" "$mess"] {
125
                fail "$message -- $match";
126
                return 1;
127
            }
128
        }
129
    }
130
    return 0;
131
}
132
 
133
#
134
# test "set variable" for type "char"
135
#
136
# Because bare char types can be either signed or unsigned, we just test the
137
# range of values that are common to both (0-127).
138
#
139
 
140
test_set "set variable v_char=0" "print v_char" ".\[0-9\]* = 0 \'.000\'"        "set variable char=0"
141
test_set "set variable v_char=1" "print v_char" ".\[0-9\]* = 1 \'.001\'"        "set variable char=1"
142
test_set "set variable v_char=27" "print v_char" ".\[0-9\]* = 27 \'.e\'"        "set variable char=27 (Esc)"
143
test_set "set variable v_char=32" "print v_char" ".\[0-9\]* = 32 \' \'"        "set variable char=32 (SPC)"
144
test_set "set variable v_char=65" "print v_char" ".\[0-9\]* = 65 \'A\'"        "set variable char=65 ('A')"
145
test_set "set variable v_char=97" "print v_char" ".\[0-9\]* = 97 \'a\'"        "set variable char=97 ('a')"
146
test_set "set variable v_char=126" "print v_char" ".\[0-9\]* = 126 \'~\'"        "set variable char=126 ('~')"
147
test_set "set variable v_char=127" "print v_char" ".\[0-9\]* = 127 \'.177\'"        "set variable char=127 (8-bit)"
148
#
149
# test "set variable" for type "signed char"
150
#
151
test_set "set variable v_char=0" "print v_signed_char" ".\[0-9\]* = 0 \'.000\'"        "set variable signed char=0"
152
test_set "set variable v_signed_char=1" "print v_signed_char" ".\[0-9\]* = 1 \'.001\'"        "set variable signed char=1"
153
test_set "set variable v_signed_char=27" "print v_signed_char" ".\[0-9\]* = 27 \'.e\'"        "set variable signed char=27 (Esc)"
154
test_set "set variable v_signed_char=32" "print v_signed_char" ".\[0-9\]* = 32 \' \'"        "set variable signed char=32 (SPC)"
155
test_set "set variable v_signed_char=65" "print v_signed_char" ".\[0-9\]* = 65 \'A\'"        "set variable signed char=65 ('A')"
156
test_set "set variable v_signed_char=97" "print v_signed_char" ".\[0-9\]* = 97 \'a\'"        "set variable signed char=97 ('a')"
157
test_set "set variable v_signed_char=126" "print v_signed_char" ".\[0-9\]* = 126 \'~\'"        "set variable signed char=126 ('~')"
158
test_set "set variable v_signed_char=127" "print v_signed_char" ".\[0-9\]* = 127 \'.177\'"        "set variable signed char=127 (8-bit)"
159
gdb_test "set variable v_signed_char=-1" ""
160
if {!$gcc_compiled} then { setup_xfail "mips-sgi-irix4*" }
161
gdb_test "print v_signed_char" ".\[0-9\]* = -1 \'.377\'" \
162
    "set variable signed char=-1 (-1)"
163
gdb_test "set variable v_signed_char=0xFF" ""
164
if {!$gcc_compiled} then { setup_xfail "mips-sgi-irix4*" }
165
gdb_test "print v_signed_char" ".\[0-9\]* = -1 \'.377\'" \
166
    "set variable signed char=0xFF (0xFF)"
167
#
168
# test "set variable" for type "unsigned char"
169
#
170
test_set "set variable v_unsigned_char=0" "print v_unsigned_char" ".\[0-9\]* = 0 \'.000\'"        "set variable unsigned char=0"
171
test_set "set variable v_unsigned_char=1" "print v_unsigned_char" ".\[0-9\]* = 1 \'.001\'"        "set variable unsigned char=1"
172
test_set "set variable v_unsigned_char=27" "print v_unsigned_char" ".\[0-9\]* = 27 \'.e\'"        "set variable unsigned char=27 (Esc)"
173
test_set "set variable v_unsigned_char=32" "print v_unsigned_char" ".\[0-9\]* = 32 \' \'"        "set variable unsigned char=32 (SPC)"
174
test_set "set variable v_unsigned_char=65" "print v_unsigned_char" ".\[0-9\]* = 65 \'A\'"        "set variable unsigned char=65 ('A')"
175
test_set "set variable v_unsigned_char=97" "print v_unsigned_char" ".\[0-9\]* = 97 \'a\'"        "set variable unsigned char=97 ('a')"
176
test_set "set variable v_unsigned_char=126" "print v_unsigned_char" ".\[0-9\]* = 126 \'~\'"        "set variable unsigned char=126 ('~')"
177
test_set "set variable v_unsigned_char=~0" "print v_unsigned_char" ".\[0-9\]* = 255 \'.377\'"        "set variable unsigned char=255 (8-bit)"
178
#
179
# test "set variable" for type "short"
180
#
181
test_set "set variable v_short=0" "print v_short" ".\[0-9\]* = 0"        "set variable short=0"
182
test_set "set variable v_short=1" "print v_short" ".\[0-9\]* = 1"        "set variable short=1"
183
test_set "set variable v_short=-1" "print v_short" ".\[0-9\]* = -1"        "set variable short=-1 (minus)"
184
#
185
# test "set variable" for type "signed short"
186
#
187
test_set "set variable v_signed_short=0" "print v_signed_short" ".\[0-9\]* = 0"        "set variable signed short=0"
188
test_set "set variable v_signed_short=1" "print v_signed_short" ".\[0-9\]* = 1"        "set variable signed short=1"
189
test_set "set variable v_signed_short=-1" "print v_signed_short" ".\[0-9\]* = -1"        "set variable signed short=-1 (minus)"
190
#
191
# test "set variable" for type "unsigned short"
192
#
193
test_set "set variable v_unsigned_short=0" "print v_unsigned_short" ".\[0-9\]* = 0"        "set variable unsigned short=0"
194
test_set "set variable v_unsigned_short=1" "print v_unsigned_short" ".\[0-9\]* = 1"        "set variable unsigned short=1"
195
test_set "set variable v_unsigned_short=~0" "print v_unsigned_short" ".\[0-9\]* = 65535"        "set variable unsigned short=~0 (minus)"
196
#
197
# test "set variable" for type "int"
198
#
199
test_set "set variable v_int=0" "print v_int" ".\[0-9\]* = 0"        "set variable int=0"
200
test_set "set variable v_int=1" "print v_int" ".\[0-9\]* = 1"        "set variable int=1"
201
test_set "set variable v_int=-1" "print v_int" ".\[0-9\]* = -1"        "set variable int=-1 (minus)"
202
#
203
# test "set variable" for type "signed int"
204
#
205
test_set "set variable v_signed_int=0" "print v_signed_int" ".\[0-9\]* = 0"        "set variable signed int=0"
206
test_set "set variable v_signed_int=1" "print v_signed_int" ".\[0-9\]* = 1"        "set variable signed int=1"
207
test_set "set variable v_signed_int=-1" "print v_signed_int" ".\[0-9\]* = -1"        "set variable signed int=-1 (minus)"
208
#
209
# test "set variable" for type "unsigned int"
210
#
211
test_set "set variable v_unsigned_int=0" "print v_unsigned_int" ".\[0-9\]* = 0"        "set variable unsigned int=0"
212
test_set "set variable v_unsigned_int=1" "print v_unsigned_int" ".\[0-9\]* = 1"        "set variable unsigned int=1"
213
test_set "set variable v_unsigned_int=~0" "print v_unsigned_int" ".\[0-9\]* = (4294967295|65535)"        "set variable unsigned int=~0 (minus)"
214
#test_set ".\[0-9\]* = 65535"        "set variable unsigned int=~0 (minus)"
215
#
216
# test "set variable" for type "long"
217
#
218
test_set "set variable v_long=0" "print v_long" ".\[0-9\]* = 0"        "set variable long=0"
219
test_set "set variable v_long=1" "print v_long" ".\[0-9\]* = 1"        "set variable long=1"
220
test_set "set variable v_long=-1" "print v_long" ".\[0-9\]* = -1"        "set variable long=-1 (minus)"
221
#
222
# test "set variable" for type "signed long"
223
#
224
test_set "set variable v_signed_long=0" "print v_signed_long" ".\[0-9\]* = 0"        "set variable signed long=0"
225
test_set "set variable v_signed_long=1" "print v_signed_long" ".\[0-9\]* = 1"        "set variable signed long=1"
226
test_set "set variable v_signed_long=-1" "print v_signed_long" ".\[0-9\]* = -1"        "set variable signed long=-1 (minus)"
227
#
228
# test "set variable" for type "unsigned long"
229
#
230
test_set "set variable v_unsigned_long=0" "print v_unsigned_long" ".\[0-9\]* = 0"        "set variable unsigned long=0"
231
test_set "set variable v_unsigned_long=1" "print v_unsigned_long" ".\[0-9\]* = 1"        "set variable unsigned long=1"
232
test_set "set variable v_unsigned_long=~0" "print v_unsigned_long" ".\[0-9\]* = $ulong_minus_1"        "set variable unsigned long=~0 (minus)"
233
#
234
# test "set variable" for type "float"
235
#
236
test_set "set variable v_float=0.0" "print v_float" ".\[0-9\]* = 0"        "set variable float=0"
237
test_set "set variable v_float=1.0" "print v_float" ".\[0-9\]* = 1"        "set variable float=1"
238
test_set "set variable v_float=-1.0" "print v_float" ".\[0-9\]* = -1"        "set variable float=-1 (minus)"
239
#
240
# test "set variable" for type "double"
241
#
242
test_set "set variable v_double=0.0" "print v_double" ".\[0-9\]* = 0"        "set variable double=0"
243
test_set "set variable v_double=1.0" "print v_double" ".\[0-9\]* = 1"        "set variable double=1"
244
test_set "set variable v_double=-1.0" "print v_double" ".*.\[0-9\]* = -1"        "set variable double=-1 (minus)"
245
#
246
# test "set variable" for "char array[2]"
247
#
248
test_set "set variable v_char_array\[0\]='h'" "set variable v_char_array\[1\]='i'" "print v_char_array" ".*.\[0-9\]* =.*\"hi\""        "set variable char array=\"hi\" (string)"
249
#
250
# test "set variable" for "signed char array[2]"
251
#
252
test_set "set variable v_signed_char_array\[0\]='h'" "set variable v_signed_char_array\[1\]='i'" "print v_signed_char_array" ".*.\[0-9\]* =.*\"hi\""        "set variable signed char array=\"hi\" (string)"
253
#
254
# test "set variable" for "unsigned char array[2]"
255
#
256
test_set "set variable v_unsigned_char_array\[0\]='h'" "set variable v_unsigned_char_array\[1\]='i'" "print v_unsigned_char_array" ".*.\[0-9\]* =.*\"hi\""        "set variable unsigned char array=\"hi\" (string)"
257
#
258
# test "set variable" for "short array[2]"
259
#
260
test_set "set variable v_short_array\[0\]=123" "set variable v_short_array\[1\]=-456" "print v_short_array" ".*.\[0-9\]* =.*\{123,.*-456\}"        "set variable short array"
261
#
262
# test "set variable" for "signed short array[2]"
263
#
264
test_set "set variable v_signed_short_array\[0\]=123" "set variable v_signed_short_array\[1\]=-456" "print v_signed_short_array" ".*.\[0-9\]* =.*\{123,.*-456\}"        "set variable signed short array"
265
#
266
# test "set variable" for "unsigned short array[2]"
267
#
268
test_set "set variable v_unsigned_short_array\[0\]=123" "set variable v_unsigned_short_array\[1\]=-456" "print v_unsigned_short_array" ".*.\[0-9\]* =.*\{123,.*65080\}"        "set variable unsigned short array"
269
#
270
# test "set variable" for "int array[2]"
271
#
272
test_set "set variable v_int_array\[0\]=123" "set variable v_int_array\[1\]=-456" "print v_int_array" ".*.\[0-9\]* =.*\{123,.*-456\}"        "set variable int array"
273
#
274
# test "set variable" for "signed int array[2]"
275
#
276
test_set "set variable v_signed_int_array\[0\]=123" "set variable v_signed_int_array\[1\]=-456" "print v_signed_int_array" ".*.\[0-9\]* =.*\{123,.*-456\}"        "set variable signed int array"
277
#
278
# test "set variable" for "unsigned int array[2]"
279
#
280
test_set "set variable v_unsigned_int_array\[0\]=123" "set variable v_unsigned_int_array\[1\]=-456" "print v_unsigned_int_array" ".*.\[0-9\]* =.*\{123,.*(4294966840|65080)\}"        "set variable unsigned int array"
281
#
282
# test "set variable" for "long array[2]"
283
#
284
test_set "set variable v_long_array\[0\]=123" "set variable v_long_array\[1\]=-456" "print v_long_array" ".*.\[0-9\]* =.*\{123,.*-456\}"        "set variable long array"
285
#
286
# test "set variable" for "signed long array[2]"
287
#
288
test_set "set variable v_signed_long_array\[0\]=123" "set variable v_signed_long_array\[1\]=-456" "print v_signed_long_array" ".*.\[0-9\]* =.*\{123,.*-456\}"        "set variable signed long array"
289
#
290
# test "set variable" for "unsigned long array[2]"
291
#
292
test_set "set variable v_unsigned_long_array\[0\]=123" "set variable v_unsigned_long_array\[1\]=-456" "print v_unsigned_long_array" ".*.\[0-9\]* =.*\{123,.*$ulong_minus_456\}"        "set variable unsigned long array"
293
#
294
# test "set variable" for "float array[2]"
295
#
296
test_set "set variable v_float_array\[0\]=123.0" "set variable v_float_array\[1\]=-456.0" "print v_float_array" ".*.\[0-9\]* =.*\{123,.*-456\}"        "set variable float array"
297
#
298
# test "set variable" for "double array[2]"
299
#
300
test_set "set variable v_double_array\[0\]=123.0" "set variable v_double_array\[1\]=-456.0" "print v_double_array" ".*.\[0-9\]* =.*\{123,.*-456\}"        "set variable double array"
301
#
302
# test "set variable" for type "char *"
303
#
304
test_set "set v_char_pointer=v_char_array" "set variable *(v_char_pointer)='h'" "set variable *(v_char_pointer+1)='i'" "print v_char_array" ".*.\[0-9\]* =.*\"hi\""  "print *(v_char_pointer+1)" ".*.\[0-9\]* = 105 \'i\'"     "set variable char pointer=\"hi\" (string)"
305
#
306
# test "set variable" for type "signed char *"
307
#
308
test_set "set v_signed_char_pointer=v_signed_char_array" "set variable *(v_signed_char_pointer)='h'" "set variable *(v_signed_char_pointer+1)='i'" "print v_signed_char_array" ".*.\[0-9\]* =.*\"hi\""  "print *(v_signed_char_pointer+1)" ".*.\[0-9\]* = 105 \'i\'"     "set variable signed char pointer=\"hi\" (string)"
309
#
310
# test "set variable" for type "unsigned char *"
311
#
312
test_set "set v_unsigned_char_pointer=v_unsigned_char_array" "set variable *(v_unsigned_char_pointer)='h'" "set variable *(v_unsigned_char_pointer+1)='i'" "print v_unsigned_char_array" ".*.\[0-9\]* =.*\"hi\""  "print *(v_unsigned_char_pointer+1)" ".*.\[0-9\]* = 105 \'i\'"     "set variable unsigned char pointer=\"hi\" (string)"
313
#
314
# test "set variable" for type "short *"
315
#
316
test_set "set v_short_pointer=v_short_array" "set variable *(v_short_pointer)=123" "set variable *(v_short_pointer+1)=-456" "print v_short_array" ".*.\[0-9\]* =.*\{123,.*-456\}"  "print *(v_short_pointer+1)" ".*.\[0-9\]* = -456"     "set variable short pointer"
317
#
318
# test "set variable" for type "signed short *"
319
#
320
gdb_test "set v_signed_short_pointer=v_signed_short_array" ""
321
gdb_test "set variable *(v_signed_short_pointer)=123" ""
322
gdb_test "set variable *(v_signed_short_pointer+1)=-456" ""
323
gdb_test "print v_signed_short_array" ".\[0-9\]* =.*\{123,.*-456\}" \
324
    "set variable signed short pointer"
325
gdb_test "print *(v_signed_short_pointer+1)" ".\[0-9\]*.*=.*-456"
326
#
327
# test "set variable" for type "unsigned short *"
328
#
329
gdb_test "set v_unsigned_short_pointer=v_unsigned_short_array" ""
330
gdb_test "set variable *(v_unsigned_short_pointer)=123" ""
331
gdb_test "set variable *(v_unsigned_short_pointer+1)=-456" ""
332
# DTS 10060CLLbs - bad type info from cc
333
if {$hp_cc_compiler} {setup_xfail hppa*-*-*11* 10060CLLbs}
334
gdb_test "print v_unsigned_short_array" ".\[0-9\]* =.*\{123,.*65080\}" \
335
    "set variable unsigned short pointer"
336
# DTS 10060CLLbs - bad type info from cc
337
if {$hp_cc_compiler} {setup_xfail hppa*-*-*11* 10060CLLbs}
338
gdb_test "print *(v_unsigned_short_pointer+1)" ".\[0-9\]* = 65080"
339
#
340
# test "set variable" for type "int *"
341
#
342
test_set "set v_int_pointer=v_int_array" "set variable *(v_int_pointer)=123" "set variable *(v_int_pointer+1)=-456" "print v_int_array" ".*.\[0-9\]* =.*\{123,.*-456\}"  "print *(v_int_pointer+1)" ".*.\[0-9\]* = -456"     "set variable int pointer"
343
#
344
# test "set variable" for type "signed int *"
345
#
346
test_set "set v_signed_int_pointer=v_signed_int_array" "set variable *(v_signed_int_pointer)=123" "set variable *(v_signed_int_pointer+1)=-456" "print v_signed_int_array" ".*.\[0-9\]* =.*\{123,.*-456\}"  "print *(v_signed_int_pointer+1)" ".*.\[0-9\]* = -456"     "set variable signed int pointer"
347
#
348
# test "set variable" for type "unsigned int *"
349
#
350
test_set "set v_unsigned_int_pointer=v_unsigned_int_array" "set variable *(v_unsigned_int_pointer)=123" "set variable *(v_unsigned_int_pointer+1)=-456" "print v_unsigned_int_array" ".*.\[0-9\]* =.*\{123,.*(4294966840|65080)\}" "set variable unsigned int pointer"
351
test_set "" "print *(v_unsigned_int_pointer+1)" ".*.\[0-9\]* = (4294966840|65080)"     "print variable unsigned int pointer+1"
352
#
353
# test "set variable" for type "long *"
354
#
355
test_set "set v_long_pointer=v_long_array" "set variable *(v_long_pointer)=123" "set variable *(v_long_pointer+1)=-456" "print v_long_array" ".*.\[0-9\]* =.*\{123,.*-456\}"  "print *(v_long_pointer+1)" ".*.\[0-9\]* = -456"     "set variable long pointer"
356
#
357
# test "set variable" for type "signed long *"
358
#
359
test_set "set v_signed_long_pointer=v_signed_long_array" "set variable *(v_signed_long_pointer)=123" "set variable *(v_signed_long_pointer+1)=-456" "print v_signed_long_array" ".*.\[0-9\]* =.*\{123,.*-456\}"  "print *(v_signed_long_pointer+1)" ".*.\[0-9\]* = -456"     "set variable signed long pointer"
360
#
361
# test "set variable" for type "unsigned long *"
362
#
363
test_set "set v_unsigned_long_pointer=v_unsigned_long_array" "set variable *(v_unsigned_long_pointer)=123" "set variable *(v_unsigned_long_pointer+1)=-456" "print v_unsigned_long_array" ".*.\[0-9\]* =.*\{123,.*$ulong_minus_456\}"  "print *(v_unsigned_long_pointer+1)" ".*.\[0-9\]* = $ulong_minus_456"     "set variable unsigned long pointer"
364
#
365
# test "set variable" for type "float *"
366
#
367
test_set "set v_float_pointer=v_float_array" "set variable *(v_float_pointer)=123.0" "set variable *(v_float_pointer+1)=-456.0" "print v_float_array" ".*.\[0-9\]* =.*\{123,.*-456\}"  "print *(v_float_pointer+1)" ".*.\[0-9\]* = -456"     "set variable float pointer"
368
#
369
# test "set variable" for type "double *"
370
#
371
test_set "set v_double_pointer=v_double_array" "set variable *(v_double_pointer)=123.0" "set variable *(v_double_pointer+1)=-456.0" "print v_double_array" ".*.\[0-9\]* =.*\{123,.*-456\}"  "print *(v_double_pointer+1)" ".*.\[0-9\]* = -456"     "set variable double pointer"
372
#
373
# test "set variable" for struct members
374
#
375
test_set "set variable v_struct1.v_char_member='h'" "print v_struct1.v_char_member" ".*.\[0-9\]* = 104 \'h\'"        "set variable structure char member"
376
test_set "set variable v_struct1.v_short_member=1" "print v_struct1.v_short_member" ".*.\[0-9\]* = 1"        "set variable structure short member"
377
test_set "set variable v_struct1.v_int_member=2" "print v_struct1.v_int_member" ".*.\[0-9\]* = 2"        "set variable structure int member"
378
test_set "set variable v_struct1.v_long_member=3" "print v_struct1.v_long_member" ".*.\[0-9\]* = 3"        "set variable structure long member"
379
test_set "set variable v_struct1.v_float_member=4.0" "print v_struct1.v_float_member" ".*.\[0-9\]* = 4"        "set variable structure float member"
380
test_set "set variable v_struct1.v_double_member=5.0" "print v_struct1.v_double_member" ".*.\[0-9\]* = 5"        "set variable structure double member"
381
 
382
gdb_test "print v_struct1" \
383
  ".*.\[0-9\]* = \{.*v_char_member = 104 \'h\',.*v_short_member = 1,\
384
.*v_int_member = 2,.*\
385
v_long_member = 3,.*v_float_member = 4,.*v_double_member = 5.*\}" \
386
  "set print structure #1"
387
 
388
# Some believe that the following  should be an error.  GCC extensions for
389
# structure constants require the type of the structure to be specified, as in
390
# v_struct1 = (struct t_struct) {32, 33, 34, 35, 36, 37}
391
# The argument is that GDB should do the same if it wants to provide this
392
# feature, i.e., require the cast.
393
# We decided that we don't want the debugger to be as picky as a
394
# compiler and make us type complex casts.
395
 
396
# We need to up this because this can be really slow on some boards.
397
# (malloc() is called as part of the test).
398
set timeout 60;
399
 
400
# Change the values
401
test_set "set variable v_struct1 = {32, 33, 34, 35, 36, 37}" \
402
  "print v_struct1" \
403
  ".*.\[0-9\]* = \{.*v_char_member = 32 \' \',.*v_short_member = 33,\
404
.*v_int_member = 34,.*\
405
v_long_member = 35,.*v_float_member = 36,.*v_double_member = 37.*\}" \
406
  "set print structure #2"
407
 
408
# Change them back
409
test_set "set variable v_struct1 = {'h', 1, 2, 3, 4.0, 5.0}" \
410
  "print v_struct1" \
411
  ".*.\[0-9\]* = \{.*v_char_member = 104 \'h\',.*v_short_member = 1,\
412
.*v_int_member = 2,.*\
413
v_long_member = 3,.*v_float_member = 4,.*v_double_member = 5.*\}" \
414
  "set print structure #3"
415
 
416
# Test printing of enumeration bitfields.
417
# GNU C supports them, some other compilers don't.
418
 
419
if {$gcc_compiled} then {
420
    gdb_test "print sef.field=sm1" ".*.\[0-9\]* = sm1"
421
    gdb_test "print sef.field" ".*.\[0-9\]* = sm1" "print sef.field (sm1)"
422
    gdb_test "print sef.field=s1" ".*.\[0-9\]* = s1"
423
    gdb_test "print sef.field" ".*.\[0-9\]* = s1" "print sef.field (s1)"
424
    gdb_test "print uef.field=u2" ".*.\[0-9\]* = u2"
425
    gdb_test "print uef.field" ".*.\[0-9\]* = u2" "print uef.field (u2)"
426
    gdb_test "print uef.field=u1" ".*.\[0-9\]* = u1"
427
    gdb_test "print uef.field" ".*.\[0-9\]* = u1" "print uef.field (u1)"
428
 
429
    # Test for truncation when assigning invalid values to bitfields.
430
    gdb_test "print sef.field=7" \
431
        ".*warning: Value does not fit in 2 bits.*\[0-9\]* = sm1"
432
    gdb_test "print uef.field=6" \
433
        ".*warning: Value does not fit in 2 bits.*\[0-9\]* = u2"
434
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.