1 # Copyright
2000, 2001, 2002, 2004, 2005 Free Software Foundation
, Inc.
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.
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.
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.
18 # Test essential Machine interface
(MI
) operations
20 # Verify that stack commands work.
22 # The goal is not to test gdb functionality
, which is done by other tests
,
23 # but to verify the correct output response to MI operations.
26 load_lib mi
-support.exp
34 set testfile
"mi-stack"
35 set srcfile $
{testfile
}.c
36 set binfile $
{objdir
}/$
{subdir
}/$
{testfile
}
37 if { [gdb_compile
"${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-DFAKEARGV}] != "" } {
38 gdb_suppress_entire_file
"Testcase compile failed, so all tests in this file will automatically fail."
42 mi_gdb_reinitialize_dir $srcdir
/$subdir
43 mi_gdb_reinitialize_dir $srcdir
/$subdir
44 mi_gdb_load $
{binfile
}
46 proc test_stack_frame_listing
{} {
48 global hex fullname_syntax srcfile
50 set line_callee4_head
[gdb_get_line_number
"callee4 ("]
51 set line_callee4_body
[expr $line_callee4_head
+ 2]
53 # Obtain a stack
trace
56 #
-stack
-list
-frames
1 1
57 #
-stack
-list
-frames
1 3
60 mi_gdb_test
"231-stack-list-frames" \
61 "231\\^done,stack=\\\[frame=\{level=\"0\",addr=\"$hex\",func=\"callee4\",file=\".*${srcfile}\",fullname=\"${fullname_syntax}${srcfile}\",line=\"$line_callee4_body\"\},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\",.*\}\\\]" \
63 mi_gdb_test
"232-stack-list-frames 1 1" \
64 "232\\^done,stack=\\\[frame=\{level=\"1\",addr=\"$hex\",func=\"callee3\",.*\}\\\]" \
65 "stack frame listing 1 1"
66 mi_gdb_test
"233-stack-list-frames 1 3" \
67 "233\\^done,stack=\\\[frame=\{level=\"1\",addr=\"$hex\",func=\"callee3\",.*\},frame=\{level=\"2\",addr=\"$hex\",func=\"callee2\",.*\},frame=\{level=\"3\",addr=\"$hex\",func=\"callee1\",.*\}\\\]" \
68 "stack frame listing 1 3"
70 mi_gdb_test
"234-stack-list-frames 1" \
71 "&.*234\\^error,msg=\"mi_cmd_stack_list_frames: Usage.*FRAME_LOW FRAME_HIGH.*\"" \
72 "stack frame listing wrong"
74 mi_gdb_test
"235-stack-info-frame" \
75 "235\\^done,frame=\{level=\"0\",addr=\"$hex\",func=\"callee4\",file=\".*${srcfile}\",fullname=\"${fullname_syntax}${srcfile}\",line=\"$line_callee4_body\"\}" \
76 "selected frame listing"
79 proc test_stack_args_listing
{} {
83 # Obtain lists
for args for the stack frames
85 #
-stack
-list
-arguments
0
86 #
-stack
-list
-arguments
0 1 1
87 #
-stack
-list
-arguments
0 1 3
88 #
-stack
-list
-arguments
1
89 #
-stack
-list
-arguments
1 1 1
90 #
-stack
-list
-arguments
1 1 3
91 #
-stack
-list
-arguments
93 mi_gdb_test
"231-stack-list-arguments 0" \
94 "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=\\\[\\\]\}\\\]" \
95 "stack args listing 0"
97 mi_gdb_test
"232-stack-list-arguments 0 1 1" \
98 "232\\^done,stack-args=\\\[frame=\{level=\"1\",args=\\\[name=\"strarg\"\\\]\}\\\]" \
99 "stack args listing 0 1 1"
101 mi_gdb_test
"233-stack-list-arguments 0 1 3" \
102 "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\"\\\]\}\\\]" \
103 "stack args listing 0 1 3"
105 mi_gdb_test
"231-stack-list-arguments 1" \
106 "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=\\\[\\\]\}\\\]" \
107 "stack args listing 1"
109 mi_gdb_test
"232-stack-list-arguments 1 1 1" \
110 "232\\^done,stack-args=\\\[frame=\{level=\"1\",args=\\\[\{name=\"strarg\",value=\"$hex \\\\\"A string argument.\\\\\"\"\}\\\]\}\\\]" \
111 "stack args listing 1 1 1"
113 mi_gdb_test
"233-stack-list-arguments 1 1 3" \
114 "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\"\}\\\]\}\\\]" \
115 "stack args listing 1 1 3"
117 mi_gdb_test
"234-stack-list-arguments" \
118 "&.*234\\^error,msg=\"mi_cmd_stack_list_args: Usage.*PRINT_VALUES.*FRAME_LOW FRAME_HIGH.*\"" \
119 "stack args listing wrong"
122 proc test_stack_info_depth
{} {
126 # Obtain depth of stack
129 #
-stack
-info-depth
3
130 #
-stack
-info-depth
99
132 mi_gdb_test
"231-stack-info-depth" \
133 "231\\^done,depth=\"5\"" \
136 mi_gdb_test
"231-stack-info-depth 3" \
137 "231\\^done,depth=\"3\"" \
140 mi_gdb_test
"231-stack-info-depth 99" \
141 "231\\^done,depth=\"5\"" \
142 "stack info-depth 99"
144 mi_gdb_test
"231-stack-info-depth 99 99" \
145 "&.*231\\^error,msg=\"mi_cmd_stack_info_depth: Usage: .MAX_DEPTH.\"" \
146 "stack info-depth wrong usage"
149 proc test_stack_locals_listing
{} {
151 global hex fullname_syntax srcfile
153 # Obtain lists
for locals
for the stack frames
155 #
-stack
-list
-locals
0 (--no
-values)
156 #
-stack
-list
-locals
1 (--all
-values)
157 #
-stack
-list
-locals
2 (--simple
-values)
158 #
-stack
-list
-arguments
160 mi_gdb_test
"232-stack-list-locals 0" \
161 "232\\^done,locals=\\\[name=\"A\",name=\"B\",name=\"C\",name=\"D\"\\\]" \
162 "stack locals listing of names"
164 set line_callee4_return_0
[gdb_get_line_number
"return 0;"]
166 # step until A
, B
, C
, D have some reasonable
values.
167 send_gdb
"-exec-next 4\n"
169 -re
"\\^running\r\n${mi_gdb_prompt}\\*stopped,reason=\"end-stepping-range\",thread-id=\"\[01\]\",frame=\{addr=\"$hex\",func=\"callee4\",args=\\\[\\\],file=\".*${srcfile}\",fullname=\"${fullname_syntax}${srcfile}\",line=\"$line_callee4_return_0\"\}\r\n$mi_gdb_prompt$" {
170 pass
"next's in callee4"
172 timeout
{ fail
"next in callee4 (timeout)" }
175 mi_gdb_test
"232-stack-list-locals 1" \
176 "232\\^done,locals=\\\[\{name=\"A\",value=\"1\"\},\{name=\"B\",value=\"2\"\},\{name=\"C\",value=\"3\"\},\{name=\"D\",value=\"\\{0, 1, 2\\}\"\}\\\]" \
177 "stack locals listing of names and values"
179 mi_gdb_test
"232-stack-list-locals 2" \
180 "232\\^done,locals=\\\[\{name=\"A\",type=\"int\",value=\"1\"\},\{name=\"B\",type=\"int\",value=\"2\"\},\{name=\"C\",type=\"int\",value=\"3\"\},\{name=\"D\",type=\"int \\\[3\\\]\"\}\\\]" \
181 "stack locals listing, simple types: names and values, complex type: names and types"
183 mi_gdb_test
"234-stack-list-locals" \
184 "&.*234\\^error,msg=\"mi_cmd_stack_list_locals: Usage.*PRINT_VALUES.*\"" \
185 "stack locals listing wrong"
187 mi_gdb_test
"232-stack-select-frame 1" \
189 "stack select frame 1"
191 mi_gdb_test
"232-stack-list-locals 1" \
192 "232\\^done,locals=\\\[\\\]" \
193 "stack locals listing for new frame"
195 mi_gdb_test
"232-stack-list-locals 1" \
196 "232\\^done,locals=\\\[\\\]" \
197 "stack locals for same frame (level 1)"
201 test_stack_frame_listing
202 test_stack_args_listing
203 test_stack_locals_listing
204 test_stack_info_depth