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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [gdb-7.1/] [gdb/] [testsuite/] [gdb.base/] [store.exp] - Blame information for rev 828

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

Line No. Rev Author Line
1 227 jeremybenn
# This testcase is part of GDB, the GNU debugger.
2
 
3
# Copyright 2002, 2003, 2004, 2007, 2008, 2009, 2010
4
# Free Software Foundation, Inc.
5
 
6
# This program is free software; you can redistribute it and/or modify
7
# it under the terms of the GNU General Public License as published by
8
# the Free Software Foundation; either version 3 of the License, or
9
# (at your option) any later version.
10
#
11
# This program is distributed in the hope that it will be useful,
12
# but WITHOUT ANY WARRANTY; without even the implied warranty of
13
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
# GNU General Public License for more details.
15
#
16
# You should have received a copy of the GNU General Public License
17
# along with this program.  If not, see .
18
 
19
if $tracelevel {
20
    strace $tracelevel
21
}
22
 
23
#
24
# test running programs
25
#
26
set prms_id 0
27
set bug_id 0
28
 
29
set testfile "store"
30
set srcfile ${testfile}.c
31
set binfile ${objdir}/${subdir}/${testfile}
32
if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
33
    untested store.exp
34
    return -1
35
}
36
 
37
if [get_compiler_info ${binfile}] {
38
    return -1;
39
}
40
 
41
gdb_exit
42
gdb_start
43
gdb_reinitialize_dir $srcdir/$subdir
44
gdb_load ${binfile}
45
 
46
#
47
# set it up at a breakpoint so we can play with the variable values
48
#
49
 
50
if ![runto_main] then {
51
    perror "couldn't run to breakpoint"
52
    continue
53
}
54
 
55
#
56
 
57
proc check_set { t l r new add } {
58
    set prefix "var ${t} l"
59
    gdb_test "tbreak wack_${t}"
60
    gdb_test "continue" "register ${t} l = u, r = v;" \
61
        "continue to wack_${t}"
62
    gdb_test "next" "l = add_${t} .l, r.;" \
63
        "${prefix}; next ${t}"
64
    gdb_test "print l" " = ${l}" \
65
        "${prefix}; print old l, expecting ${l}"
66
    gdb_test "print r" " = ${r}" \
67
        "${prefix}; print old r, expecting ${r}"
68
    gdb_test "set variable l = 4" "" \
69
        "${prefix}; setting l to 4"
70
    gdb_test "print l" " = ${new}" \
71
        "${prefix}; print new l, expecting ${new}"
72
    gdb_test "next" "return l \\+ r;" \
73
        "${prefix}; next over add call"
74
    gdb_test "print l" " = ${add}" \
75
        "${prefix}; print incremented l, expecting ${add}"
76
}
77
 
78
check_set "charest" "-1 .*" "-2 .*" "4 ..004." "2 ..002."
79
check_set "short" "-1" "-2" "4" "2"
80
check_set "int" "-1" "-2" "4" "2"
81
check_set "long" "-1" "-2" "4" "2"
82
check_set "longest" "-1" "-2" "4" "2"
83
check_set "float" "-1" "-2" "4" "2"
84
check_set "double" "-1" "-2" "4" "2"
85
check_set "doublest" "-1" "-2" "4" "2"
86
 
87
#
88
 
89
proc up_set { t l r new } {
90
    set prefix "upvar ${t} l"
91
    gdb_test "tbreak add_${t}"
92
    gdb_test "continue" "return u . v;" \
93
        "continue to add_${t}"
94
    gdb_test "up" "l = add_${t} .l, r.;" \
95
        "${prefix}; up"
96
    gdb_test "print l" " = ${l}" \
97
        "${prefix}; print old l, expecting ${l}"
98
    gdb_test "print r" " = ${r}" \
99
        "${prefix}; print old r, expecting ${r}"
100
    gdb_test "set variable l = 4" "" \
101
        "${prefix}; set l to 4"
102
    gdb_test "print l" " = ${new}" \
103
        "${prefix}; print new l, expecting ${new}"
104
}
105
 
106
up_set "charest" "-1 .*" "-2 .*" "4 ..004."
107
up_set "short" "-1" "-2" "4"
108
up_set "int" "-1" "-2" "4"
109
up_set "long" "-1" "-2" "4"
110
up_set "longest" "-1" "-2" "4"
111
up_set "float" "-1" "-2" "4"
112
up_set "double" "-1" "-2" "4"
113
up_set "doublest" "-1" "-2" "4"
114
 
115
#
116
 
117
proc check_struct { t old new } {
118
    set prefix "var struct ${t} u"
119
    gdb_test "tbreak wack_struct_${t}"
120
    gdb_test "continue" "int i; register struct s_${t} u = z_${t};" \
121
        "continue to wack_struct_${t}"
122
    gdb_test "next 2" "add_struct_${t} .u.;" \
123
        "${prefix}; next to add_struct_${t} call"
124
    gdb_test "print u" " = ${old}" \
125
        "${prefix}; print old u, expecting ${old}"
126
    gdb_test "set variable u = s_${t}" "" \
127
        "${prefix}; set u to s_${t}"
128
    gdb_test "print u" " = ${new}" \
129
        "${prefix}; print new u, expecting ${new}"
130
}
131
 
132
check_struct "1" "{s = \\{0}}" "{s = \\{1}}"
133
check_struct "2" "{s = \\{0, 0}}" "{s = \\{1, 2}}"
134
check_struct "3" "{s = \\{0, 0, 0}}" "{s = \\{1, 2, 3}}"
135
check_struct "4" "{s = \\{0, 0, 0, 0}}" "{s = \\{1, 2, 3, 4}}"
136
 
137
proc up_struct { t old new } {
138
    set prefix "up struct ${t} u"
139
    gdb_test "tbreak add_struct_${t}"
140
    gdb_test "continue" "for .i = 0; i < sizeof .s. / sizeof .s.s.0..; i..." \
141
        "continue to add_struct_${t}"
142
    gdb_test "up" "u = add_struct_${t} .u.;" \
143
        "${prefix}; up"
144
    gdb_test "print u" " = ${old}" \
145
        "${prefix}; print old u, expecting ${old}"
146
    gdb_test "set variable u = s_${t}" "" \
147
        "${prefix}; set u to s_${t}"
148
    gdb_test "print u" " = ${new}" \
149
        "${prefix}; print new u, expecting ${new}"
150
}
151
 
152
up_struct "1" "{s = \\{0}}" "{s = \\{1}}"
153
up_struct "2" "{s = \\{0, 0}}" "{s = \\{1, 2}}"
154
up_struct "3" "{s = \\{0, 0, 0}}" "{s = \\{1, 2, 3}}"
155
up_struct "4" "{s = \\{0, 0, 0, 0}}" "{s = \\{1, 2, 3, 4}}"
156
 
157
#
158
 
159
proc check_field { t } {
160
    global gdb_prompt
161
    gdb_test "tbreak wack_field_${t}"
162
    gdb_test "continue" "register struct f_${t} u = f_${t};" \
163
            "continue field ${t}"
164
 
165
    # Match either the return statement, or the line immediatly after
166
    # it.  The compiler can end up merging the return statement into
167
    # the return instruction.
168
    gdb_test "next" "(return u;|\})" "next field ${t}"
169
 
170
    gdb_test "print u" " = {i = 1, j = 1, k = 1}" "old field ${t}"
171
    gdb_test "set variable u = F_${t}"
172
    gdb_test "print u" " = {i = 0, j = 0, k = 0}" "new field ${t}"
173
 
174
    gdb_test "set variable u = F_${t}, u.i = f_${t}.i"
175
    gdb_test "print u" " = {i = 1, j = 0, k = 0}" "f_${t}.i"
176
 
177
    gdb_test "set variable u = F_${t}, u.j = f_${t}.j"
178
    gdb_test "print u" " = {i = 0, j = 1, k = 0}" "f_${t}.j"
179
 
180
    gdb_test "set variable u = F_${t}, u.k = f_${t}.k"
181
    gdb_test "print u" " = {i = 0, j = 0, k = 1}" "f_${t}.k"
182
 
183
    gdb_test "set variable u = f_${t}, u.i = F_${t}.i"
184
    gdb_test "print u" " = {i = 0, j = 1, k = 1}" "F_${t}.i"
185
 
186
    gdb_test "set variable u = f_${t}, u.j = F_${t}.j"
187
    gdb_test "print u" " = {i = 1, j = 0, k = 1}" "F_${t}.j"
188
 
189
    gdb_test "set variable u = f_${t}, u.k = F_${t}.k"
190
    gdb_test "print u" " = {i = 1, j = 1, k = 0}" "F_${t}.k"
191
 
192
}
193
 
194
check_field 1
195
check_field 2
196
check_field 3
197
check_field 4
198
 
199
#
200
 
201
# WANTED: A fairly portable way of convincing the compiler to split a
202
# value across memory and registers.
203
 

powered by: WebSVN 2.1.0

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