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