Commit | Line | Data |
---|---|---|
76ff342d | 1 | # Copyright 2000, 2001, 2002, 2004, 2005 Free Software Foundation, Inc. |
fb40c209 AC |
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 | ||
fb40c209 AC |
17 | # |
18 | # Test essential Machine interface (MI) operations | |
19 | # | |
20 | # Verify that stack commands work. | |
21 | ||
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. | |
24 | # | |
25 | ||
26 | load_lib mi-support.exp | |
b30bf9ee | 27 | set MIFLAGS "-i=mi" |
fb40c209 AC |
28 | |
29 | gdb_exit | |
30 | if [mi_gdb_start] { | |
31 | continue | |
32 | } | |
33 | ||
34 | set testfile "basics" | |
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." | |
39 | } | |
40 | ||
41 | mi_delete_breakpoints | |
42 | mi_gdb_reinitialize_dir $srcdir/$subdir | |
43 | mi_gdb_reinitialize_dir $srcdir/$subdir | |
44 | mi_gdb_load ${binfile} | |
45 | ||
fb40c209 AC |
46 | proc test_stack_frame_listing {} { |
47 | global mi_gdb_prompt | |
76ff342d | 48 | global hex fullname_syntax srcfile |
fb40c209 | 49 | |
45f07fef MC |
50 | set line_callee4_head [gdb_get_line_number "callee4 ("] |
51 | set line_callee4_body [expr $line_callee4_head + 2] | |
52 | ||
fb40c209 AC |
53 | # Obtain a stack trace |
54 | # Tests: | |
55 | # -stack-list-frames | |
56 | # -stack-list-frames 1 1 | |
57 | # -stack-list-frames 1 3 | |
58 | ||
59 | mi_gdb_test "231-stack-list-frames" \ | |
76ff342d | 60 | "231\\^done,stack=\\\[frame=\{level=\"0\",addr=\"$hex\",func=\"callee4\",file=\".*basics.c\",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\",.*\}\\\]" \ |
fb40c209 AC |
61 | "stack frame listing" |
62 | mi_gdb_test "232-stack-list-frames 1 1" \ | |
c18008c5 | 63 | "232\\^done,stack=\\\[frame=\{level=\"1\",addr=\"$hex\",func=\"callee3\",.*\}\\\]" \ |
fb40c209 AC |
64 | "stack frame listing 1 1" |
65 | mi_gdb_test "233-stack-list-frames 1 3" \ | |
c18008c5 | 66 | "233\\^done,stack=\\\[frame=\{level=\"1\",addr=\"$hex\",func=\"callee3\",.*\},frame=\{level=\"2\",addr=\"$hex\",func=\"callee2\",.*\},frame=\{level=\"3\",addr=\"$hex\",func=\"callee1\",.*\}\\\]" \ |
fb40c209 AC |
67 | "stack frame listing 1 3" |
68 | ||
69 | mi_gdb_test "234-stack-list-frames 1" \ | |
70 | "234\\^error,msg=\"mi_cmd_stack_list_frames: Usage.*FRAME_LOW FRAME_HIGH.*\"" \ | |
71 | "stack frame listing wrong" | |
72 | } | |
73 | ||
74 | proc test_stack_args_listing {} { | |
75 | global mi_gdb_prompt | |
76 | global hex | |
77 | ||
78 | # Obtain lists for args for the stack frames | |
79 | # Tests: | |
80 | # -stack-list-arguments 0 | |
81 | # -stack-list-arguments 0 1 1 | |
82 | # -stack-list-arguments 0 1 3 | |
83 | # -stack-list-arguments 1 | |
84 | # -stack-list-arguments 1 1 1 | |
85 | # -stack-list-arguments 1 1 3 | |
86 | # -stack-list-arguments | |
87 | ||
88 | mi_gdb_test "231-stack-list-arguments 0" \ | |
dc61bc6d | 89 | "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=\\\[\\\]\}\\\]" \ |
fb40c209 AC |
90 | "stack args listing 0" |
91 | ||
92 | mi_gdb_test "232-stack-list-arguments 0 1 1" \ | |
dc61bc6d | 93 | "232\\^done,stack-args=\\\[frame=\{level=\"1\",args=\\\[name=\"strarg\"\\\]\}\\\]" \ |
fb40c209 AC |
94 | "stack args listing 0 1 1" |
95 | ||
96 | mi_gdb_test "233-stack-list-arguments 0 1 3" \ | |
dc61bc6d | 97 | "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\"\\\]\}\\\]" \ |
fb40c209 AC |
98 | "stack args listing 0 1 3" |
99 | ||
100 | mi_gdb_test "231-stack-list-arguments 1" \ | |
dc61bc6d | 101 | "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=\\\[\\\]\}\\\]" \ |
fb40c209 AC |
102 | "stack args listing 1" |
103 | ||
104 | mi_gdb_test "232-stack-list-arguments 1 1 1" \ | |
dc61bc6d | 105 | "232\\^done,stack-args=\\\[frame=\{level=\"1\",args=\\\[\{name=\"strarg\",value=\"$hex \\\\\"A string argument.\\\\\"\"\}\\\]\}\\\]" \ |
fb40c209 AC |
106 | "stack args listing 1 1 1" |
107 | ||
108 | mi_gdb_test "233-stack-list-arguments 1 1 3" \ | |
dc61bc6d | 109 | "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\"\}\\\]\}\\\]" \ |
fb40c209 AC |
110 | "stack args listing 1 1 3" |
111 | ||
112 | mi_gdb_test "234-stack-list-arguments" \ | |
113 | "234\\^error,msg=\"mi_cmd_stack_list_args: Usage.*PRINT_VALUES.*FRAME_LOW FRAME_HIGH.*\"" \ | |
114 | "stack args listing wrong" | |
115 | } | |
116 | ||
117 | proc test_stack_info_depth {} { | |
118 | global mi_gdb_prompt | |
119 | global hex | |
120 | ||
121 | # Obtain depth of stack | |
122 | # Tests: | |
123 | # -stack-info-depth | |
124 | # -stack-info-depth 3 | |
125 | # -stack-info-depth 99 | |
126 | ||
127 | mi_gdb_test "231-stack-info-depth" \ | |
128 | "231\\^done,depth=\"5\"" \ | |
129 | "stack info-depth" | |
130 | ||
131 | mi_gdb_test "231-stack-info-depth 3" \ | |
132 | "231\\^done,depth=\"3\"" \ | |
133 | "stack info-depth 3" | |
134 | ||
135 | mi_gdb_test "231-stack-info-depth 99" \ | |
136 | "231\\^done,depth=\"5\"" \ | |
137 | "stack info-depth 99" | |
138 | ||
139 | mi_gdb_test "231-stack-info-depth 99 99" \ | |
140 | "231\\^error,msg=\"mi_cmd_stack_info_depth: Usage: .MAX_DEPTH.\"" \ | |
141 | "stack info-depth wrong usage" | |
142 | } | |
143 | ||
144 | proc test_stack_locals_listing {} { | |
145 | global mi_gdb_prompt | |
76ff342d | 146 | global hex fullname_syntax srcfile |
fb40c209 AC |
147 | |
148 | # Obtain lists for locals for the stack frames | |
149 | # Tests: | |
150 | # -stack-list-locals 0 | |
151 | # -stack-list-locals 1 | |
a0c76b6b | 152 | # -stack-list-locals 2 |
fb40c209 AC |
153 | # -stack-list-arguments |
154 | ||
155 | mi_gdb_test "232-stack-list-locals 0" \ | |
dc61bc6d | 156 | "232\\^done,locals=\\\[name=\"A\",name=\"B\",name=\"C\"\\\]" \ |
fb40c209 AC |
157 | "stack locals listing 0" |
158 | ||
45f07fef MC |
159 | set line_callee4_return_0 [gdb_get_line_number "return 0;"] |
160 | ||
fb40c209 AC |
161 | # step until A, B, C, have some reasonable values. |
162 | send_gdb "-exec-next 3\n" | |
163 | gdb_expect { | |
76ff342d | 164 | -re "\\^running\r\n${mi_gdb_prompt}\\*stopped,reason=\"end-stepping-range\",thread-id=\"\[01\]\",frame=\{addr=\"$hex\",func=\"callee4\",args=\\\[\\\],file=\".*basics.c\",fullname=\"${fullname_syntax}${srcfile}\",line=\"$line_callee4_return_0\"\}\r\n$mi_gdb_prompt$" { |
fb40c209 AC |
165 | pass "next's in callee4" |
166 | } | |
167 | timeout { fail "next in callee4 (timeout)" } | |
168 | } | |
169 | ||
170 | mi_gdb_test "232-stack-list-locals 1" \ | |
dc61bc6d | 171 | "232\\^done,locals=\\\[\{name=\"A\",value=\"1\"\},\{name=\"B\",value=\"2\"\},\{name=\"C\",value=\"3\"\}\\\]" \ |
fb40c209 AC |
172 | "stack locals listing 1" |
173 | ||
a0c76b6b NR |
174 | mi_gdb_test "232-stack-list-locals 2" \ |
175 | "232\\^done,locals=\\\[\{name=\"A\",type=\"int\",value=\"1\"\},\{name=\"B\",type=\"int\",value=\"2\"\},\{name=\"C\",type=\"int\",value=\"3\"\}\\\]" \ | |
176 | "stack locals listing 2" | |
177 | ||
fb40c209 AC |
178 | mi_gdb_test "234-stack-list-locals" \ |
179 | "234\\^error,msg=\"mi_cmd_stack_list_locals: Usage.*PRINT_VALUES.*\"" \ | |
180 | "stack locals listing wrong" | |
181 | ||
182 | mi_gdb_test "232-stack-select-frame 1" \ | |
183 | "232\\^done" \ | |
184 | "stack select frame 1" | |
185 | ||
186 | mi_gdb_test "232-stack-list-locals 1" \ | |
dc61bc6d | 187 | "232\\^done,locals=\\\[\\\]" \ |
fb40c209 AC |
188 | "stack locals listing for new frame" |
189 | ||
190 | # this should be a no-op | |
191 | ||
192 | mi_gdb_test "232-stack-select-frame" \ | |
193 | "232\\^done" \ | |
194 | "stack select same frame" | |
195 | ||
196 | mi_gdb_test "232-stack-list-locals 1" \ | |
dc61bc6d | 197 | "232\\^done,locals=\\\[\\\]" \ |
fb40c209 AC |
198 | "stack locals for same frame (level 1)" |
199 | ||
200 | } | |
201 | ||
6afa27b0 | 202 | mi_runto callee4 |
fb40c209 AC |
203 | test_stack_frame_listing |
204 | test_stack_args_listing | |
205 | test_stack_locals_listing | |
206 | test_stack_info_depth | |
207 | ||
208 | ||
209 | mi_gdb_exit | |
210 | return 0 |