OpenCores
URL https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk

Subversion Repositories openrisc_2011-10-31

[/] [openrisc/] [tags/] [gnu-src/] [gdb-7.2/] [gdb-7.2-or32-1.0rc1/] [gdb/] [testsuite/] [gdb.base/] [store.exp] - Blame information for rev 330

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

Line No. Rev Author Line
1 330 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
 
27
set testfile "store"
28
set srcfile ${testfile}.c
29
set binfile ${objdir}/${subdir}/${testfile}
30
if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
31
    untested store.exp
32
    return -1
33
}
34
 
35
if [get_compiler_info ${binfile}] {
36
    return -1;
37
}
38
 
39
gdb_exit
40
gdb_start
41
gdb_reinitialize_dir $srcdir/$subdir
42
gdb_load ${binfile}
43
 
44
#
45
# set it up at a breakpoint so we can play with the variable values
46
#
47
 
48
if ![runto_main] then {
49
    perror "couldn't run to breakpoint"
50
    continue
51
}
52
 
53
#
54
 
55
proc check_set { t l r new add } {
56
    set prefix "var ${t} l"
57
    gdb_test "tbreak wack_${t}"
58
    gdb_test "continue" "register ${t} l = u, r = v;" \
59
        "continue to wack_${t}"
60
    gdb_test "next" "l = add_${t} .l, r.;" \
61
        "${prefix}; next ${t}"
62
    gdb_test "print l" " = ${l}" \
63
        "${prefix}; print old l, expecting ${l}"
64
    gdb_test "print r" " = ${r}" \
65
        "${prefix}; print old r, expecting ${r}"
66
    gdb_test_no_output "set variable l = 4" \
67
        "${prefix}; setting l to 4"
68
    gdb_test "print l" " = ${new}" \
69
        "${prefix}; print new l, expecting ${new}"
70
    gdb_test "next" "return l \\+ r;" \
71
        "${prefix}; next over add call"
72
    gdb_test "print l" " = ${add}" \
73
        "${prefix}; print incremented l, expecting ${add}"
74
}
75
 
76
check_set "charest" "-1 .*" "-2 .*" "4 ..004." "2 ..002."
77
check_set "short" "-1" "-2" "4" "2"
78
check_set "int" "-1" "-2" "4" "2"
79
check_set "long" "-1" "-2" "4" "2"
80
check_set "longest" "-1" "-2" "4" "2"
81
check_set "float" "-1" "-2" "4" "2"
82
check_set "double" "-1" "-2" "4" "2"
83
check_set "doublest" "-1" "-2" "4" "2"
84
 
85
#
86
 
87
proc up_set { t l r new } {
88
    set prefix "upvar ${t} l"
89
    gdb_test "tbreak add_${t}"
90
    gdb_test "continue" "return u . v;" \
91
        "continue to add_${t}"
92
    gdb_test "up" "l = add_${t} .l, r.;" \
93
        "${prefix}; up"
94
    gdb_test "print l" " = ${l}" \
95
        "${prefix}; print old l, expecting ${l}"
96
    gdb_test "print r" " = ${r}" \
97
        "${prefix}; print old r, expecting ${r}"
98
    gdb_test_no_output "set variable l = 4" \
99
        "${prefix}; set l to 4"
100
    gdb_test "print l" " = ${new}" \
101
        "${prefix}; print new l, expecting ${new}"
102
}
103
 
104
up_set "charest" "-1 .*" "-2 .*" "4 ..004."
105
up_set "short" "-1" "-2" "4"
106
up_set "int" "-1" "-2" "4"
107
up_set "long" "-1" "-2" "4"
108
up_set "longest" "-1" "-2" "4"
109
up_set "float" "-1" "-2" "4"
110
up_set "double" "-1" "-2" "4"
111
up_set "doublest" "-1" "-2" "4"
112
 
113
#
114
 
115
proc check_struct { t old new } {
116
    set prefix "var struct ${t} u"
117
    gdb_test "tbreak wack_struct_${t}"
118
    gdb_test "continue" "int i; register struct s_${t} u = z_${t};" \
119
        "continue to wack_struct_${t}"
120
    gdb_test "next 2" "add_struct_${t} .u.;" \
121
        "${prefix}; next to add_struct_${t} call"
122
    gdb_test "print u" " = ${old}" \
123
        "${prefix}; print old u, expecting ${old}"
124
    gdb_test_no_output "set variable u = s_${t}" \
125
        "${prefix}; set u to s_${t}"
126
    gdb_test "print u" " = ${new}" \
127
        "${prefix}; print new u, expecting ${new}"
128
}
129
 
130
check_struct "1" "{s = \\{0}}" "{s = \\{1}}"
131
check_struct "2" "{s = \\{0, 0}}" "{s = \\{1, 2}}"
132
check_struct "3" "{s = \\{0, 0, 0}}" "{s = \\{1, 2, 3}}"
133
check_struct "4" "{s = \\{0, 0, 0, 0}}" "{s = \\{1, 2, 3, 4}}"
134
 
135
proc up_struct { t old new } {
136
    set prefix "up struct ${t} u"
137
    gdb_test "tbreak add_struct_${t}"
138
    gdb_test "continue" "for .i = 0; i < sizeof .s. / sizeof .s.s.0..; i..." \
139
        "continue to add_struct_${t}"
140
    gdb_test "up" "u = add_struct_${t} .u.;" \
141
        "${prefix}; up"
142
    gdb_test "print u" " = ${old}" \
143
        "${prefix}; print old u, expecting ${old}"
144
    gdb_test_no_output "set variable u = s_${t}" \
145
        "${prefix}; set u to s_${t}"
146
    gdb_test "print u" " = ${new}" \
147
        "${prefix}; print new u, expecting ${new}"
148
}
149
 
150
up_struct "1" "{s = \\{0}}" "{s = \\{1}}"
151
up_struct "2" "{s = \\{0, 0}}" "{s = \\{1, 2}}"
152
up_struct "3" "{s = \\{0, 0, 0}}" "{s = \\{1, 2, 3}}"
153
up_struct "4" "{s = \\{0, 0, 0, 0}}" "{s = \\{1, 2, 3, 4}}"
154
 
155
#
156
 
157
proc check_field { t } {
158
    global gdb_prompt
159
    gdb_test "tbreak wack_field_${t}"
160
    gdb_test "continue" "register struct f_${t} u = f_${t};" \
161
            "continue field ${t}"
162
 
163
    # Match either the return statement, or the line immediatly after
164
    # it.  The compiler can end up merging the return statement into
165
    # the return instruction.
166
    gdb_test "next" "(return u;|\})" "next field ${t}"
167
 
168
    gdb_test "print u" " = {i = 1, j = 1, k = 1}" "old field ${t}"
169
    gdb_test_no_output "set variable u = F_${t}"
170
    gdb_test "print u" " = {i = 0, j = 0, k = 0}" "new field ${t}"
171
 
172
    gdb_test_no_output "set variable u = F_${t}, u.i = f_${t}.i"
173
    gdb_test "print u" " = {i = 1, j = 0, k = 0}" "f_${t}.i"
174
 
175
    gdb_test_no_output "set variable u = F_${t}, u.j = f_${t}.j"
176
    gdb_test "print u" " = {i = 0, j = 1, k = 0}" "f_${t}.j"
177
 
178
    gdb_test_no_output "set variable u = F_${t}, u.k = f_${t}.k"
179
    gdb_test "print u" " = {i = 0, j = 0, k = 1}" "f_${t}.k"
180
 
181
    gdb_test_no_output "set variable u = f_${t}, u.i = F_${t}.i"
182
    gdb_test "print u" " = {i = 0, j = 1, k = 1}" "F_${t}.i"
183
 
184
    gdb_test_no_output "set variable u = f_${t}, u.j = F_${t}.j"
185
    gdb_test "print u" " = {i = 1, j = 0, k = 1}" "F_${t}.j"
186
 
187
    gdb_test_no_output "set variable u = f_${t}, u.k = F_${t}.k"
188
    gdb_test "print u" " = {i = 1, j = 1, k = 0}" "F_${t}.k"
189
 
190
}
191
 
192
check_field 1
193
check_field 2
194
check_field 3
195
check_field 4
196
 
197
#
198
 
199
# WANTED: A fairly portable way of convincing the compiler to split a
200
# value across memory and registers.
201
 

powered by: WebSVN 2.1.0

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