]>
Commit | Line | Data |
---|---|---|
42a4f53d | 1 | # Copyright 2000-2019 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 | |
e22f8b7c | 5 | # the Free Software Foundation; either version 3 of the License, or |
fb40c209 | 6 | # (at your option) any later version. |
e22f8b7c | 7 | # |
fb40c209 AC |
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. | |
e22f8b7c | 12 | # |
fb40c209 | 13 | # You should have received a copy of the GNU General Public License |
e22f8b7c | 14 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
fb40c209 | 15 | |
fb40c209 AC |
16 | # |
17 | # Test essential Machine interface (MI) operations | |
18 | # | |
19 | # Verify that stack commands work. | |
20 | ||
21 | # The goal is not to test gdb functionality, which is done by other tests, | |
22 | # but to verify the correct output response to MI operations. | |
23 | # | |
24 | ||
25 | load_lib mi-support.exp | |
b30bf9ee | 26 | set MIFLAGS "-i=mi" |
fb40c209 AC |
27 | |
28 | gdb_exit | |
29 | if [mi_gdb_start] { | |
30 | continue | |
31 | } | |
32 | ||
298a9cf0 TT |
33 | standard_testfile |
34 | ||
9357e021 | 35 | if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } { |
5b362f04 | 36 | untested "failed to compile" |
b60f0898 | 37 | return -1 |
fb40c209 AC |
38 | } |
39 | ||
40 | mi_delete_breakpoints | |
41 | mi_gdb_reinitialize_dir $srcdir/$subdir | |
42 | mi_gdb_reinitialize_dir $srcdir/$subdir | |
43 | mi_gdb_load ${binfile} | |
44 | ||
fb40c209 AC |
45 | proc test_stack_frame_listing {} { |
46 | global mi_gdb_prompt | |
76ff342d | 47 | global hex fullname_syntax srcfile |
fb40c209 | 48 | |
6d52907e JV |
49 | set any "\[^\"\]+" |
50 | ||
a0be7a36 SM |
51 | set callee4_begin [gdb_get_line_number "callee4 begin"] |
52 | mi_continue_to_line $callee4_begin "continue to callee4 begin" | |
45f07fef | 53 | |
fb40c209 AC |
54 | # Obtain a stack trace |
55 | # Tests: | |
56 | # -stack-list-frames | |
57 | # -stack-list-frames 1 1 | |
58 | # -stack-list-frames 1 3 | |
1ed91682 | 59 | # -stack-info-frame |
fb40c209 | 60 | mi_gdb_test "231-stack-list-frames" \ |
6d52907e | 61 | "231\\^done,stack=\\\[frame=\{level=\"0\",addr=\"$hex\",func=\"callee4\",file=\".*${srcfile}\",fullname=\"${fullname_syntax}${srcfile}\",line=\"$callee4_begin\",arch=\"$any\"\},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\",.*\}\\\]" \ |
9b73db36 | 62 | "stack frame listing" |
fb40c209 | 63 | mi_gdb_test "232-stack-list-frames 1 1" \ |
9b73db36 SM |
64 | "232\\^done,stack=\\\[frame=\{level=\"1\",addr=\"$hex\",func=\"callee3\",.*\}\\\]" \ |
65 | "stack frame listing 1 1" | |
fb40c209 | 66 | mi_gdb_test "233-stack-list-frames 1 3" \ |
9b73db36 SM |
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" | |
fb40c209 AC |
69 | |
70 | mi_gdb_test "234-stack-list-frames 1" \ | |
9b73db36 SM |
71 | "234\\^error,msg=\"-stack-list-frames: Usage.*FRAME_LOW FRAME_HIGH.*\"" \ |
72 | "stack frame listing wrong" | |
1ed91682 NR |
73 | |
74 | mi_gdb_test "235-stack-info-frame" \ | |
6d52907e | 75 | "235\\^done,frame=\{level=\"0\",addr=\"$hex\",func=\"callee4\",file=\".*${srcfile}\",fullname=\"${fullname_syntax}${srcfile}\",line=\"$callee4_begin\",arch=\"$any\"\}" \ |
9b73db36 | 76 | "selected frame listing" |
2ab1eb7a VP |
77 | |
78 | mi_gdb_test "236-stack-list-frames 1 300" \ | |
9b73db36 SM |
79 | "236\\^done,stack=\\\[frame=\{level=\"1\",addr=\"$hex\",func=\"callee3\",.*\},frame=\{level=\"2\",addr=\"$hex\",func=\"callee2\",.*\},frame=\{level=\"3\",addr=\"$hex\",func=\"callee1\",.*\}\\\]" \ |
80 | "stack frame listing 1 300" | |
fb40c209 AC |
81 | } |
82 | ||
83 | proc test_stack_args_listing {} { | |
84 | global mi_gdb_prompt | |
85 | global hex | |
86 | ||
87 | # Obtain lists for args for the stack frames | |
88 | # Tests: | |
89 | # -stack-list-arguments 0 | |
90 | # -stack-list-arguments 0 1 1 | |
91 | # -stack-list-arguments 0 1 3 | |
92 | # -stack-list-arguments 1 | |
93 | # -stack-list-arguments 1 1 1 | |
94 | # -stack-list-arguments 1 1 3 | |
95 | # -stack-list-arguments | |
96 | ||
97 | mi_gdb_test "231-stack-list-arguments 0" \ | |
9b73db36 SM |
98 | "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=\\\[\\\]\}\\\]" \ |
99 | "stack args listing 0" | |
fb40c209 AC |
100 | |
101 | mi_gdb_test "232-stack-list-arguments 0 1 1" \ | |
9b73db36 SM |
102 | "232\\^done,stack-args=\\\[frame=\{level=\"1\",args=\\\[name=\"strarg\"\\\]\}\\\]" \ |
103 | "stack args listing 0 1 1" | |
fb40c209 AC |
104 | |
105 | mi_gdb_test "233-stack-list-arguments 0 1 3" \ | |
9b73db36 SM |
106 | "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\"\\\]\}\\\]" \ |
107 | "stack args listing 0 1 3" | |
fb40c209 AC |
108 | |
109 | mi_gdb_test "231-stack-list-arguments 1" \ | |
9b73db36 SM |
110 | "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=\\\[\\\]\}\\\]" \ |
111 | "stack args listing 1" | |
fb40c209 AC |
112 | |
113 | mi_gdb_test "232-stack-list-arguments 1 1 1" \ | |
9b73db36 SM |
114 | "232\\^done,stack-args=\\\[frame=\{level=\"1\",args=\\\[\{name=\"strarg\",value=\"$hex \\\\\"A string argument.\\\\\"\"\}\\\]\}\\\]" \ |
115 | "stack args listing 1 1 1" | |
fb40c209 | 116 | |
8b777f02 | 117 | mi_gdb_test "233-stack-list-arguments --all-values 1 3" \ |
9b73db36 SM |
118 | "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\"\}\\\]\}\\\]" \ |
119 | "stack args listing 1 1 3" | |
fb40c209 AC |
120 | |
121 | mi_gdb_test "234-stack-list-arguments" \ | |
9b73db36 SM |
122 | "234\\^error,msg=\"-stack-list-arguments: Usage.*PRINT_VALUES.*FRAME_LOW FRAME_HIGH.*\"" \ |
123 | "stack args listing wrong" | |
cd5ff84a VP |
124 | |
125 | mi_gdb_test "235-stack-list-arguments 1 1 300" \ | |
9b73db36 SM |
126 | "235\\^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\"\}\\\]\},frame=\{level=\"4\",args=\\\[\\\]\}\\\]" \ |
127 | "stack args listing 1 1 300" | |
fb40c209 AC |
128 | } |
129 | ||
130 | proc test_stack_info_depth {} { | |
131 | global mi_gdb_prompt | |
132 | global hex | |
133 | ||
134 | # Obtain depth of stack | |
135 | # Tests: | |
136 | # -stack-info-depth | |
137 | # -stack-info-depth 3 | |
138 | # -stack-info-depth 99 | |
139 | ||
140 | mi_gdb_test "231-stack-info-depth" \ | |
9b73db36 SM |
141 | "231\\^done,depth=\"5\"" \ |
142 | "stack info-depth" | |
fb40c209 AC |
143 | |
144 | mi_gdb_test "231-stack-info-depth 3" \ | |
9b73db36 SM |
145 | "231\\^done,depth=\"3\"" \ |
146 | "stack info-depth 3" | |
fb40c209 AC |
147 | |
148 | mi_gdb_test "231-stack-info-depth 99" \ | |
9b73db36 SM |
149 | "231\\^done,depth=\"5\"" \ |
150 | "stack info-depth 99" | |
fb40c209 AC |
151 | |
152 | mi_gdb_test "231-stack-info-depth 99 99" \ | |
9b73db36 SM |
153 | "231\\^error,msg=\"-stack-info-depth: Usage: .MAX_DEPTH.\"" \ |
154 | "stack info-depth wrong usage" | |
fb40c209 AC |
155 | } |
156 | ||
157 | proc test_stack_locals_listing {} { | |
158 | global mi_gdb_prompt | |
76ff342d | 159 | global hex fullname_syntax srcfile |
fb40c209 AC |
160 | |
161 | # Obtain lists for locals for the stack frames | |
162 | # Tests: | |
d8d83e9b NR |
163 | # -stack-list-locals 0 (--no-values) |
164 | # -stack-list-locals 1 (--all-values) | |
165 | # -stack-list-locals 2 (--simple-values) | |
fb40c209 AC |
166 | # -stack-list-arguments |
167 | ||
168 | mi_gdb_test "232-stack-list-locals 0" \ | |
9b73db36 SM |
169 | "232\\^done,locals=\\\[name=\"A\",name=\"B\",name=\"C\",name=\"D\"\\\]" \ |
170 | "stack locals listing of names" | |
fb40c209 | 171 | |
9b73db36 | 172 | set line_callee4_return_0 [gdb_get_line_number "return 0;"] |
45f07fef | 173 | |
9b73db36 SM |
174 | # step until A, B, C, D have some reasonable values. |
175 | mi_execute_to "exec-next 4" "end-stepping-range" "callee4" "" ".*${srcfile}" $line_callee4_return_0 ""\ | |
176 | "next's in callee4" | |
fb40c209 AC |
177 | |
178 | mi_gdb_test "232-stack-list-locals 1" \ | |
9b73db36 SM |
179 | "232\\^done,locals=\\\[\{name=\"A\",value=\"1\"\},\{name=\"B\",value=\"2\"\},\{name=\"C\",value=\"3\"\},\{name=\"D\",value=\"\\{0, 1, 2\\}\"\}\\\]" \ |
180 | "stack locals listing of names and values" | |
fb40c209 | 181 | |
8b777f02 | 182 | mi_gdb_test "232-stack-list-locals --simple-values" \ |
9b73db36 SM |
183 | "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\\\]\"\}\\\]" \ |
184 | "stack locals listing, simple types: names and values, complex type: names and types" | |
a0c76b6b | 185 | |
fb40c209 | 186 | mi_gdb_test "234-stack-list-locals" \ |
9b73db36 SM |
187 | "234\\^error,msg=\"-stack-list-locals: Usage.*PRINT_VALUES.*\"" \ |
188 | "stack locals listing wrong" | |
fb40c209 AC |
189 | |
190 | mi_gdb_test "232-stack-select-frame 1" \ | |
9b73db36 SM |
191 | "232\\^done" \ |
192 | "stack select frame 1" | |
fb40c209 AC |
193 | |
194 | mi_gdb_test "232-stack-list-locals 1" \ | |
9b73db36 SM |
195 | "232\\^done,locals=\\\[\\\]" \ |
196 | "stack locals listing for new frame" | |
fb40c209 | 197 | |
fb40c209 | 198 | mi_gdb_test "232-stack-list-locals 1" \ |
9b73db36 SM |
199 | "232\\^done,locals=\\\[\\\]" \ |
200 | "stack locals for same frame (level 1)" | |
fb40c209 AC |
201 | } |
202 | ||
6afa27b0 | 203 | mi_runto callee4 |
fb40c209 AC |
204 | test_stack_frame_listing |
205 | test_stack_args_listing | |
206 | test_stack_locals_listing | |
207 | test_stack_info_depth | |
208 | ||
209 | ||
210 | mi_gdb_exit | |
211 | return 0 |