1 |
106 |
markom |
# Copyright (C) 1999 2000 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 |
|
|
#
|
21 |
|
|
# Test essential Machine interface (MI) operations
|
22 |
|
|
#
|
23 |
|
|
# Verify that stack commands work.
|
24 |
|
|
|
25 |
|
|
# The goal is not to test gdb functionality, which is done by other tests,
|
26 |
|
|
# but to verify the correct output response to MI operations.
|
27 |
|
|
#
|
28 |
|
|
|
29 |
|
|
load_lib mi-support.exp
|
30 |
|
|
|
31 |
|
|
gdb_exit
|
32 |
|
|
if [mi_gdb_start] {
|
33 |
|
|
continue
|
34 |
|
|
}
|
35 |
|
|
|
36 |
|
|
set testfile "basics"
|
37 |
|
|
set srcfile ${testfile}.c
|
38 |
|
|
set binfile ${objdir}/${subdir}/${testfile}
|
39 |
|
|
if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-DFAKEARGV}] != "" } {
|
40 |
|
|
gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
|
41 |
|
|
}
|
42 |
|
|
|
43 |
|
|
mi_delete_breakpoints
|
44 |
|
|
mi_gdb_reinitialize_dir $srcdir/$subdir
|
45 |
|
|
mi_gdb_reinitialize_dir $srcdir/$subdir
|
46 |
|
|
mi_gdb_load ${binfile}
|
47 |
|
|
|
48 |
|
|
|
49 |
|
|
mi_gdb_test "200-break-insert callee4" \
|
50 |
|
|
"200\\^done,bkpt=\{number=\"1\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"$hex\",func=\"callee4\",file=\".*basics.c\",line=\"8\",times=\"0\"\}" \
|
51 |
|
|
"break-insert operation"
|
52 |
|
|
|
53 |
|
|
mi_run_cmd
|
54 |
|
|
# The running part has been checked already by mi_run_cmd
|
55 |
|
|
gdb_expect {
|
56 |
|
|
-re "\[\r\n\]*000\\*stopped,reason=\"breakpoint-hit\",bkptno=\"1\",thread-id=\"0\",frame=\{addr=\"$hex\",func=\"callee4\",args=\{\},file=\".*basics.c\",line=\"8\"\}\r\n$mi_gdb_prompt$" {
|
57 |
|
|
pass "run to callee4"
|
58 |
|
|
}
|
59 |
|
|
-re ".*$mi_gdb_prompt$" {fail "run to callee4 (2)"}
|
60 |
|
|
timeout {fail "run to callee4 (timeout 2)"}
|
61 |
|
|
}
|
62 |
|
|
|
63 |
|
|
|
64 |
|
|
proc test_stack_frame_listing {} {
|
65 |
|
|
global mi_gdb_prompt
|
66 |
|
|
global hex
|
67 |
|
|
|
68 |
|
|
# Obtain a stack trace
|
69 |
|
|
# Tests:
|
70 |
|
|
# -stack-list-frames
|
71 |
|
|
# -stack-list-frames 1 1
|
72 |
|
|
# -stack-list-frames 1 3
|
73 |
|
|
|
74 |
|
|
mi_gdb_test "231-stack-list-frames" \
|
75 |
|
|
"231\\^done,stack=\{frame=\{level=\"0 \",addr=\"$hex\",func=\"callee4\",file=\".*basics.c\",line=\"8\"\},frame=\{level=\"1 \",addr=\"$hex\",func=\"callee3\",.*\},frame=\{level=\"2 \",addr=\"$hex\",func=\"callee2\",.*\},frame=\{level=\"3 \",addr=\"$hex\",func=\"callee1\",.*\},frame=\{level=\"4 \",addr=\"$hex\",func=\"main\",.*\}\}" \
|
76 |
|
|
"stack frame listing"
|
77 |
|
|
mi_gdb_test "232-stack-list-frames 1 1" \
|
78 |
|
|
"232\\^done,stack=\{frame=\{level=\"1 \",addr=\"$hex\",func=\"callee3\",.*\}\}" \
|
79 |
|
|
"stack frame listing 1 1"
|
80 |
|
|
mi_gdb_test "233-stack-list-frames 1 3" \
|
81 |
|
|
"233\\^done,stack=\{frame=\{level=\"1 \",addr=\"$hex\",func=\"callee3\",.*\},frame=\{level=\"2 \",addr=\"$hex\",func=\"callee2\",.*\},frame=\{level=\"3 \",addr=\"$hex\",func=\"callee1\",.*\}\}" \
|
82 |
|
|
"stack frame listing 1 3"
|
83 |
|
|
|
84 |
|
|
mi_gdb_test "234-stack-list-frames 1" \
|
85 |
|
|
"234\\^error,msg=\"mi_cmd_stack_list_frames: Usage.*FRAME_LOW FRAME_HIGH.*\"" \
|
86 |
|
|
"stack frame listing wrong"
|
87 |
|
|
}
|
88 |
|
|
|
89 |
|
|
proc test_stack_args_listing {} {
|
90 |
|
|
global mi_gdb_prompt
|
91 |
|
|
global hex
|
92 |
|
|
|
93 |
|
|
# Obtain lists for args for the stack frames
|
94 |
|
|
# Tests:
|
95 |
|
|
# -stack-list-arguments 0
|
96 |
|
|
# -stack-list-arguments 0 1 1
|
97 |
|
|
# -stack-list-arguments 0 1 3
|
98 |
|
|
# -stack-list-arguments 1
|
99 |
|
|
# -stack-list-arguments 1 1 1
|
100 |
|
|
# -stack-list-arguments 1 1 3
|
101 |
|
|
# -stack-list-arguments
|
102 |
|
|
|
103 |
|
|
mi_gdb_test "231-stack-list-arguments 0" \
|
104 |
|
|
"231\\^done,stack-args=\{frame=\{level=\"0\",args=\{\}\},frame=\{level=\"1\",args=\{name=\"strarg\"\}\},frame=\{level=\"2\",args=\{name=\"intarg\",name=\"strarg\"\}\},frame=\{level=\"3\",args=\{name=\"intarg\",name=\"strarg\",name=\"fltarg\"\}\},frame=\{level=\"4\",args=\{\}\}\}" \
|
105 |
|
|
"stack args listing 0"
|
106 |
|
|
|
107 |
|
|
mi_gdb_test "232-stack-list-arguments 0 1 1" \
|
108 |
|
|
"232\\^done,stack-args=\{frame=\{level=\"1\",args=\{name=\"strarg\"\}\}\}" \
|
109 |
|
|
"stack args listing 0 1 1"
|
110 |
|
|
|
111 |
|
|
mi_gdb_test "233-stack-list-arguments 0 1 3" \
|
112 |
|
|
"233\\^done,stack-args=\{frame=\{level=\"1\",args=\{name=\"strarg\"\}\},frame=\{level=\"2\",args=\{name=\"intarg\",name=\"strarg\"\}\},frame=\{level=\"3\",args=\{name=\"intarg\",name=\"strarg\",name=\"fltarg\"\}\}\}" \
|
113 |
|
|
"stack args listing 0 1 3"
|
114 |
|
|
|
115 |
|
|
mi_gdb_test "231-stack-list-arguments 1" \
|
116 |
|
|
"231\\^done,stack-args=\{frame=\{level=\"0\",args=\{\}\},frame=\{level=\"1\",args=\{\{name=\"strarg\",value=\"$hex \\\\\"A string argument.\\\\\"\"\}\}\},frame=\{level=\"2\",args=\{\{name=\"intarg\",value=\"2\"\},\{name=\"strarg\",value=\"$hex \\\\\"A string argument.\\\\\"\"\}\}\},frame=\{level=\"3\",args=\{\{name=\"intarg\",value=\"2\"\},\{name=\"strarg\",value=\"$hex \\\\\"A string argument.\\\\\"\"\},\{name=\"fltarg\",value=\"3.5\"\}\}\},frame=\{level=\"4\",args=\{\}\}\}" \
|
117 |
|
|
"stack args listing 1"
|
118 |
|
|
|
119 |
|
|
mi_gdb_test "232-stack-list-arguments 1 1 1" \
|
120 |
|
|
"232\\^done,stack-args=\{frame=\{level=\"1\",args=\{\{name=\"strarg\",value=\"$hex \\\\\"A string argument.\\\\\"\"\}\}\}\}" \
|
121 |
|
|
"stack args listing 1 1 1"
|
122 |
|
|
|
123 |
|
|
mi_gdb_test "233-stack-list-arguments 1 1 3" \
|
124 |
|
|
"233\\^done,stack-args=\{frame=\{level=\"1\",args=\{\{name=\"strarg\",value=\"$hex \\\\\"A string argument.\\\\\"\"\}\}\},frame=\{level=\"2\",args=\{\{name=\"intarg\",value=\"2\"\},\{name=\"strarg\",value=\"$hex \\\\\"A string argument.\\\\\"\"\}\}\},frame=\{level=\"3\",args=\{\{name=\"intarg\",value=\"2\"\},\{name=\"strarg\",value=\"$hex \\\\\"A string argument.\\\\\"\"\},\{name=\"fltarg\",value=\"3.5\"\}\}\}\}" \
|
125 |
|
|
"stack args listing 1 1 3"
|
126 |
|
|
|
127 |
|
|
mi_gdb_test "234-stack-list-arguments" \
|
128 |
|
|
"234\\^error,msg=\"mi_cmd_stack_list_args: Usage.*PRINT_VALUES.*FRAME_LOW FRAME_HIGH.*\"" \
|
129 |
|
|
"stack args listing wrong"
|
130 |
|
|
}
|
131 |
|
|
|
132 |
|
|
proc test_stack_info_depth {} {
|
133 |
|
|
global mi_gdb_prompt
|
134 |
|
|
global hex
|
135 |
|
|
|
136 |
|
|
# Obtain depth of stack
|
137 |
|
|
# Tests:
|
138 |
|
|
# -stack-info-depth
|
139 |
|
|
# -stack-info-depth 3
|
140 |
|
|
# -stack-info-depth 99
|
141 |
|
|
|
142 |
|
|
mi_gdb_test "231-stack-info-depth" \
|
143 |
|
|
"231\\^done,depth=\"5\"" \
|
144 |
|
|
"stack info-depth"
|
145 |
|
|
|
146 |
|
|
mi_gdb_test "231-stack-info-depth 3" \
|
147 |
|
|
"231\\^done,depth=\"3\"" \
|
148 |
|
|
"stack info-depth 3"
|
149 |
|
|
|
150 |
|
|
mi_gdb_test "231-stack-info-depth 99" \
|
151 |
|
|
"231\\^done,depth=\"5\"" \
|
152 |
|
|
"stack info-depth 99"
|
153 |
|
|
|
154 |
|
|
mi_gdb_test "231-stack-info-depth 99 99" \
|
155 |
|
|
"231\\^error,msg=\"mi_cmd_stack_info_depth: Usage: .MAX_DEPTH.\"" \
|
156 |
|
|
"stack info-depth wrong usage"
|
157 |
|
|
}
|
158 |
|
|
|
159 |
|
|
proc test_stack_locals_listing {} {
|
160 |
|
|
global mi_gdb_prompt
|
161 |
|
|
global hex
|
162 |
|
|
|
163 |
|
|
# Obtain lists for locals for the stack frames
|
164 |
|
|
# Tests:
|
165 |
|
|
# -stack-list-locals 0
|
166 |
|
|
# -stack-list-locals 1
|
167 |
|
|
# -stack-list-arguments
|
168 |
|
|
|
169 |
|
|
mi_gdb_test "232-stack-list-locals 0" \
|
170 |
|
|
"232\\^done,locals=\{name=\"A\",name=\"B\",name=\"C\"\}" \
|
171 |
|
|
"stack locals listing 0"
|
172 |
|
|
|
173 |
|
|
# step until A, B, C, have some reasonable values.
|
174 |
|
|
send_gdb "-exec-next 3\n"
|
175 |
|
|
gdb_expect {
|
176 |
|
|
-re "\\^running\r\n${mi_gdb_prompt}\\*stopped,reason=\"end-stepping-range\",thread-id=\"0\",frame=\{addr=\"$hex\",func=\"callee4\",args=\{\},file=\".*basics.c\",line=\"13\"\}\r\n$mi_gdb_prompt$" {
|
177 |
|
|
pass "next's in callee4"
|
178 |
|
|
}
|
179 |
|
|
timeout { fail "next in callee4 (timeout)" }
|
180 |
|
|
}
|
181 |
|
|
|
182 |
|
|
mi_gdb_test "232-stack-list-locals 1" \
|
183 |
|
|
"232\\^done,locals=\{\{name=\"A\",value=\"1\"\},\{name=\"B\",value=\"2\"\},\{name=\"C\",value=\"3\"\}\}" \
|
184 |
|
|
"stack locals listing 1"
|
185 |
|
|
|
186 |
|
|
mi_gdb_test "234-stack-list-locals" \
|
187 |
|
|
"234\\^error,msg=\"mi_cmd_stack_list_locals: Usage.*PRINT_VALUES.*\"" \
|
188 |
|
|
"stack locals listing wrong"
|
189 |
|
|
|
190 |
|
|
mi_gdb_test "232-stack-select-frame 1" \
|
191 |
|
|
"232\\^done" \
|
192 |
|
|
"stack select frame 1"
|
193 |
|
|
|
194 |
|
|
mi_gdb_test "232-stack-list-locals 1" \
|
195 |
|
|
"232\\^done,locals=\{\}" \
|
196 |
|
|
"stack locals listing for new frame"
|
197 |
|
|
|
198 |
|
|
# this should be a no-op
|
199 |
|
|
|
200 |
|
|
mi_gdb_test "232-stack-select-frame" \
|
201 |
|
|
"232\\^done" \
|
202 |
|
|
"stack select same frame"
|
203 |
|
|
|
204 |
|
|
mi_gdb_test "232-stack-list-locals 1" \
|
205 |
|
|
"232\\^done,locals=\{\}" \
|
206 |
|
|
"stack locals for same frame (level 1)"
|
207 |
|
|
|
208 |
|
|
}
|
209 |
|
|
|
210 |
|
|
test_stack_frame_listing
|
211 |
|
|
test_stack_args_listing
|
212 |
|
|
test_stack_locals_listing
|
213 |
|
|
test_stack_info_depth
|
214 |
|
|
|
215 |
|
|
|
216 |
|
|
mi_gdb_exit
|
217 |
|
|
return 0
|
218 |
|
|
|
219 |
|
|
# Local variables:
|
220 |
|
|
# change-log-default-name: "ChangeLog-mi"
|
221 |
|
|
# End:
|
222 |
|
|
|