Change frame_filter_flags to use DEF_ENUM_FLAGS_TYPE
[deliverable/binutils-gdb.git] / gdb / mi / mi-cmd-stack.c
CommitLineData
fb40c209 1/* MI Command Set - stack commands.
e2882c85 2 Copyright (C) 2000-2018 Free Software Foundation, Inc.
ab91fdd5 3 Contributed by Cygnus Solutions (a Red Hat company).
fb40c209
AC
4
5 This file is part of GDB.
6
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
a9762ec7 9 the Free Software Foundation; either version 3 of the License, or
fb40c209
AC
10 (at your option) any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
a9762ec7 18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
fb40c209
AC
19
20#include "defs.h"
21#include "target.h"
22#include "frame.h"
23#include "value.h"
24#include "mi-cmds.h"
25#include "ui-out.h"
e88c90f2 26#include "symtab.h"
fe898f56 27#include "block.h"
b9362cc7 28#include "stack.h"
de4f826b 29#include "dictionary.h"
d8ca156b 30#include "language.h"
79a45b7d 31#include "valprint.h"
1e611234
PM
32#include "utils.h"
33#include "mi-getopt.h"
6dddc817 34#include "extension.h"
1e611234 35#include <ctype.h>
87967e27 36#include "mi-parse.h"
0092b74d 37#include "common/gdb_optional.h"
daf3c977
VP
38
39enum what_to_list { locals, arguments, all };
40
6211c335 41static void list_args_or_locals (enum what_to_list what,
bdaf8d4a 42 enum print_values values,
6211c335
YQ
43 struct frame_info *fi,
44 int skip_unavailable);
fb40c209 45
1e611234
PM
46/* True if we want to allow Python-based frame filters. */
47static int frame_filters = 0;
48
49void
9f33b8b7 50mi_cmd_enable_frame_filters (const char *command, char **argv, int argc)
1e611234
PM
51{
52 if (argc != 0)
53 error (_("-enable-frame-filters: no arguments allowed"));
54 frame_filters = 1;
55}
56
10367c7c
PA
57/* Like apply_ext_lang_frame_filter, but take a print_values */
58
59static enum ext_lang_bt_status
d4dd3282
TT
60mi_apply_ext_lang_frame_filter (struct frame_info *frame,
61 frame_filter_flags flags,
10367c7c
PA
62 enum print_values print_values,
63 struct ui_out *out,
64 int frame_low, int frame_high)
65{
66 /* ext_lang_frame_args's MI options are compatible with MI print
67 values. */
68 return apply_ext_lang_frame_filter (frame, flags,
69 (enum ext_lang_frame_args) print_values,
70 out,
71 frame_low, frame_high);
72}
73
2b03b41d 74/* Print a list of the stack frames. Args can be none, in which case
fb40c209
AC
75 we want to print the whole backtrace, or a pair of numbers
76 specifying the frame numbers at which to start and stop the
2b03b41d
SS
77 display. If the two numbers are equal, a single frame will be
78 displayed. */
79
ce8f13f8 80void
9f33b8b7 81mi_cmd_stack_list_frames (const char *command, char **argv, int argc)
fb40c209
AC
82{
83 int frame_low;
84 int frame_high;
85 int i;
86 struct frame_info *fi;
6dddc817 87 enum ext_lang_bt_status result = EXT_LANG_BT_ERROR;
1e611234
PM
88 int raw_arg = 0;
89 int oind = 0;
90 enum opt
91 {
92 NO_FRAME_FILTERS
93 };
94 static const struct mi_opt opts[] =
95 {
96 {"-no-frame-filters", NO_FRAME_FILTERS, 0},
97 { 0, 0, 0 }
98 };
99
100 /* Parse arguments. In this instance we are just looking for
101 --no-frame-filters. */
102 while (1)
103 {
104 char *oarg;
105 int opt = mi_getopt ("-stack-list-frames", argc, argv,
106 opts, &oind, &oarg);
107 if (opt < 0)
108 break;
109 switch ((enum opt) opt)
110 {
111 case NO_FRAME_FILTERS:
112 raw_arg = oind;
113 break;
114 }
115 }
fb40c209 116
1e611234
PM
117 /* After the last option is parsed, there should either be low -
118 high range, or no further arguments. */
119 if ((argc - oind != 0) && (argc - oind != 2))
120 error (_("-stack-list-frames: Usage: [--no-frame-filters] [FRAME_LOW FRAME_HIGH]"));
fb40c209 121
1e611234
PM
122 /* If there is a range, set it. */
123 if (argc - oind == 2)
fb40c209 124 {
1e611234
PM
125 frame_low = atoi (argv[0 + oind]);
126 frame_high = atoi (argv[1 + oind]);
fb40c209
AC
127 }
128 else
129 {
130 /* Called with no arguments, it means we want the whole
2b03b41d 131 backtrace. */
fb40c209
AC
132 frame_low = -1;
133 frame_high = -1;
134 }
135
136 /* Let's position fi on the frame at which to start the
137 display. Could be the innermost frame if the whole stack needs
2b03b41d 138 displaying, or if frame_low is 0. */
fb40c209
AC
139 for (i = 0, fi = get_current_frame ();
140 fi && i < frame_low;
141 i++, fi = get_prev_frame (fi));
142
143 if (fi == NULL)
1b05df00 144 error (_("-stack-list-frames: Not enough frames in stack."));
fb40c209 145
10f489e5 146 ui_out_emit_list list_emitter (current_uiout, "stack");
fb40c209 147
1e611234 148 if (! raw_arg && frame_filters)
fb40c209 149 {
d4dd3282 150 frame_filter_flags flags = PRINT_LEVEL | PRINT_FRAME_INFO;
1e611234
PM
151 int py_frame_low = frame_low;
152
153 /* We cannot pass -1 to frame_low, as that would signify a
154 relative backtrace from the tail of the stack. So, in the case
155 of frame_low == -1, assign and increment it. */
156 if (py_frame_low == -1)
157 py_frame_low++;
158
6dddc817
DE
159 result = apply_ext_lang_frame_filter (get_current_frame (), flags,
160 NO_VALUES, current_uiout,
161 py_frame_low, frame_high);
1e611234
PM
162 }
163
164 /* Run the inbuilt backtrace if there are no filters registered, or
165 if "--no-frame-filters" has been specified from the command. */
6dddc817 166 if (! frame_filters || raw_arg || result == EXT_LANG_BT_NO_FILTERS)
1e611234
PM
167 {
168 /* Now let's print the frames up to frame_high, or until there are
169 frames in the stack. */
170 for (;
171 fi && (i <= frame_high || frame_high == -1);
172 i++, fi = get_prev_frame (fi))
173 {
174 QUIT;
175 /* Print the location and the address always, even for level 0.
176 If args is 0, don't print the arguments. */
08d72866 177 print_frame_info (fi, 1, LOC_AND_ADDRESS, 0 /* args */, 0);
1e611234 178 }
fb40c209 179 }
fb40c209
AC
180}
181
ce8f13f8 182void
9f33b8b7 183mi_cmd_stack_info_depth (const char *command, char **argv, int argc)
fb40c209
AC
184{
185 int frame_high;
186 int i;
187 struct frame_info *fi;
188
fb40c209 189 if (argc > 1)
1b05df00 190 error (_("-stack-info-depth: Usage: [MAX_DEPTH]"));
fb40c209
AC
191
192 if (argc == 1)
193 frame_high = atoi (argv[0]);
194 else
195 /* Called with no arguments, it means we want the real depth of
2b03b41d 196 the stack. */
fb40c209
AC
197 frame_high = -1;
198
199 for (i = 0, fi = get_current_frame ();
200 fi && (i < frame_high || frame_high == -1);
201 i++, fi = get_prev_frame (fi))
202 QUIT;
203
112e8700 204 current_uiout->field_int ("depth", i);
fb40c209
AC
205}
206
7a93fb82 207/* Print a list of the locals for the current frame. With argument of
fb40c209 208 0, print only the names, with argument of 1 print also the
2b03b41d
SS
209 values. */
210
ce8f13f8 211void
9f33b8b7 212mi_cmd_stack_list_locals (const char *command, char **argv, int argc)
fb40c209 213{
f5ec2042 214 struct frame_info *frame;
1e611234 215 int raw_arg = 0;
6dddc817 216 enum ext_lang_bt_status result = EXT_LANG_BT_ERROR;
f486487f 217 enum print_values print_value;
645eab03 218 int oind = 0;
6211c335 219 int skip_unavailable = 0;
f5ec2042 220
645eab03
YQ
221 if (argc > 1)
222 {
645eab03
YQ
223 enum opt
224 {
6211c335
YQ
225 NO_FRAME_FILTERS,
226 SKIP_UNAVAILABLE,
645eab03
YQ
227 };
228 static const struct mi_opt opts[] =
229 {
230 {"-no-frame-filters", NO_FRAME_FILTERS, 0},
6211c335 231 {"-skip-unavailable", SKIP_UNAVAILABLE, 0},
645eab03
YQ
232 { 0, 0, 0 }
233 };
234
235 while (1)
236 {
237 char *oarg;
238 /* Don't parse 'print-values' as an option. */
239 int opt = mi_getopt ("-stack-list-locals", argc - 1, argv,
240 opts, &oind, &oarg);
241
242 if (opt < 0)
243 break;
244 switch ((enum opt) opt)
245 {
246 case NO_FRAME_FILTERS:
247 raw_arg = oind;
6211c335
YQ
248 case SKIP_UNAVAILABLE:
249 skip_unavailable = 1;
645eab03
YQ
250 break;
251 }
252 }
253 }
fb40c209 254
645eab03
YQ
255 /* After the last option is parsed, there should be only
256 'print-values'. */
257 if (argc - oind != 1)
6211c335
YQ
258 error (_("-stack-list-locals: Usage: [--no-frame-filters] "
259 "[--skip-unavailable] PRINT_VALUES"));
f5ec2042 260
1e611234 261 frame = get_selected_frame (NULL);
645eab03 262 print_value = mi_parse_print_values (argv[oind]);
1e611234
PM
263
264 if (! raw_arg && frame_filters)
265 {
d4dd3282 266 frame_filter_flags flags = PRINT_LEVEL | PRINT_LOCALS;
1e611234 267
10367c7c
PA
268 result = mi_apply_ext_lang_frame_filter (frame, flags, print_value,
269 current_uiout, 0, 0);
1e611234
PM
270 }
271
272 /* Run the inbuilt backtrace if there are no filters registered, or
273 if "--no-frame-filters" has been specified from the command. */
6dddc817 274 if (! frame_filters || raw_arg || result == EXT_LANG_BT_NO_FILTERS)
1e611234 275 {
6211c335
YQ
276 list_args_or_locals (locals, print_value, frame,
277 skip_unavailable);
1e611234 278 }
fb40c209
AC
279}
280
7a93fb82 281/* Print a list of the arguments for the current frame. With argument
fb40c209 282 of 0, print only the names, with argument of 1 print also the
2b03b41d
SS
283 values. */
284
ce8f13f8 285void
9f33b8b7 286mi_cmd_stack_list_args (const char *command, char **argv, int argc)
fb40c209
AC
287{
288 int frame_low;
289 int frame_high;
290 int i;
291 struct frame_info *fi;
8b777f02 292 enum print_values print_values;
79a45e25 293 struct ui_out *uiout = current_uiout;
1e611234 294 int raw_arg = 0;
242f1fd7 295 int oind = 0;
6211c335 296 int skip_unavailable = 0;
6dddc817 297 enum ext_lang_bt_status result = EXT_LANG_BT_ERROR;
242f1fd7
YQ
298 enum opt
299 {
300 NO_FRAME_FILTERS,
6211c335 301 SKIP_UNAVAILABLE,
242f1fd7
YQ
302 };
303 static const struct mi_opt opts[] =
304 {
305 {"-no-frame-filters", NO_FRAME_FILTERS, 0},
6211c335 306 {"-skip-unavailable", SKIP_UNAVAILABLE, 0},
242f1fd7
YQ
307 { 0, 0, 0 }
308 };
309
310 while (1)
311 {
312 char *oarg;
313 int opt = mi_getopt_allow_unknown ("-stack-list-args", argc, argv,
314 opts, &oind, &oarg);
fb40c209 315
242f1fd7
YQ
316 if (opt < 0)
317 break;
318 switch ((enum opt) opt)
319 {
320 case NO_FRAME_FILTERS:
321 raw_arg = oind;
322 break;
6211c335
YQ
323 case SKIP_UNAVAILABLE:
324 skip_unavailable = 1;
325 break;
242f1fd7
YQ
326 }
327 }
fb40c209 328
242f1fd7
YQ
329 if (argc - oind != 1 && argc - oind != 3)
330 error (_("-stack-list-arguments: Usage: " \
6211c335
YQ
331 "[--no-frame-filters] [--skip-unavailable] "
332 "PRINT_VALUES [FRAME_LOW FRAME_HIGH]"));
1e611234 333
242f1fd7 334 if (argc - oind == 3)
fb40c209 335 {
242f1fd7
YQ
336 frame_low = atoi (argv[1 + oind]);
337 frame_high = atoi (argv[2 + oind]);
fb40c209
AC
338 }
339 else
340 {
341 /* Called with no arguments, it means we want args for the whole
2b03b41d 342 backtrace. */
fb40c209
AC
343 frame_low = -1;
344 frame_high = -1;
345 }
346
242f1fd7 347 print_values = mi_parse_print_values (argv[oind]);
8b777f02 348
fb40c209
AC
349 /* Let's position fi on the frame at which to start the
350 display. Could be the innermost frame if the whole stack needs
2b03b41d 351 displaying, or if frame_low is 0. */
fb40c209
AC
352 for (i = 0, fi = get_current_frame ();
353 fi && i < frame_low;
354 i++, fi = get_prev_frame (fi));
355
356 if (fi == NULL)
1b05df00 357 error (_("-stack-list-arguments: Not enough frames in stack."));
fb40c209 358
10f489e5 359 ui_out_emit_list list_emitter (uiout, "stack-args");
fb40c209 360
1e611234 361 if (! raw_arg && frame_filters)
fb40c209 362 {
d4dd3282 363 frame_filter_flags flags = PRINT_LEVEL | PRINT_ARGS;
1e611234
PM
364 int py_frame_low = frame_low;
365
366 /* We cannot pass -1 to frame_low, as that would signify a
367 relative backtrace from the tail of the stack. So, in the case
368 of frame_low == -1, assign and increment it. */
369 if (py_frame_low == -1)
370 py_frame_low++;
371
10367c7c
PA
372 result = mi_apply_ext_lang_frame_filter (get_current_frame (), flags,
373 print_values, current_uiout,
374 py_frame_low, frame_high);
fb40c209
AC
375 }
376
1e611234
PM
377 /* Run the inbuilt backtrace if there are no filters registered, or
378 if "--no-frame-filters" has been specified from the command. */
6dddc817 379 if (! frame_filters || raw_arg || result == EXT_LANG_BT_NO_FILTERS)
1e611234
PM
380 {
381 /* Now let's print the frames up to frame_high, or until there are
382 frames in the stack. */
383 for (;
384 fi && (i <= frame_high || frame_high == -1);
385 i++, fi = get_prev_frame (fi))
386 {
1e611234 387 QUIT;
2e783024 388 ui_out_emit_tuple tuple_emitter (uiout, "frame");
112e8700 389 uiout->field_int ("level", i);
6211c335 390 list_args_or_locals (arguments, print_values, fi, skip_unavailable);
1e611234
PM
391 }
392 }
fb40c209
AC
393}
394
daf3c977 395/* Print a list of the local variables (including arguments) for the
7a93fb82
VP
396 current frame. ARGC must be 1 and ARGV[0] specify if only the names,
397 or both names and values of the variables must be printed. See
398 parse_print_value for possible values. */
2b03b41d 399
daf3c977 400void
9f33b8b7 401mi_cmd_stack_list_variables (const char *command, char **argv, int argc)
daf3c977
VP
402{
403 struct frame_info *frame;
1e611234 404 int raw_arg = 0;
6dddc817 405 enum ext_lang_bt_status result = EXT_LANG_BT_ERROR;
f486487f 406 enum print_values print_value;
645eab03 407 int oind = 0;
6211c335 408 int skip_unavailable = 0;
daf3c977 409
645eab03
YQ
410 if (argc > 1)
411 {
645eab03
YQ
412 enum opt
413 {
6211c335
YQ
414 NO_FRAME_FILTERS,
415 SKIP_UNAVAILABLE,
645eab03
YQ
416 };
417 static const struct mi_opt opts[] =
418 {
419 {"-no-frame-filters", NO_FRAME_FILTERS, 0},
6211c335 420 {"-skip-unavailable", SKIP_UNAVAILABLE, 0},
645eab03
YQ
421 { 0, 0, 0 }
422 };
423
424 while (1)
425 {
426 char *oarg;
427 /* Don't parse 'print-values' as an option. */
428 int opt = mi_getopt ("-stack-list-variables", argc - 1,
429 argv, opts, &oind, &oarg);
430 if (opt < 0)
431 break;
432 switch ((enum opt) opt)
433 {
434 case NO_FRAME_FILTERS:
435 raw_arg = oind;
436 break;
6211c335
YQ
437 case SKIP_UNAVAILABLE:
438 skip_unavailable = 1;
439 break;
645eab03
YQ
440 }
441 }
442 }
daf3c977 443
645eab03
YQ
444 /* After the last option is parsed, there should be only
445 'print-values'. */
446 if (argc - oind != 1)
6211c335
YQ
447 error (_("-stack-list-variables: Usage: [--no-frame-filters] " \
448 "[--skip-unavailable] PRINT_VALUES"));
daf3c977 449
1e611234 450 frame = get_selected_frame (NULL);
645eab03 451 print_value = mi_parse_print_values (argv[oind]);
1e611234
PM
452
453 if (! raw_arg && frame_filters)
454 {
d4dd3282 455 frame_filter_flags flags = PRINT_LEVEL | PRINT_ARGS | PRINT_LOCALS;
1e611234 456
10367c7c
PA
457 result = mi_apply_ext_lang_frame_filter (frame, flags,
458 print_value,
459 current_uiout, 0, 0);
1e611234
PM
460 }
461
462 /* Run the inbuilt backtrace if there are no filters registered, or
463 if "--no-frame-filters" has been specified from the command. */
6dddc817 464 if (! frame_filters || raw_arg || result == EXT_LANG_BT_NO_FILTERS)
1e611234 465 {
6211c335
YQ
466 list_args_or_locals (all, print_value, frame,
467 skip_unavailable);
1e611234 468 }
daf3c977
VP
469}
470
2b03b41d
SS
471/* Print single local or argument. ARG must be already read in. For
472 WHAT and VALUES see list_args_or_locals.
93d86cef 473
2b03b41d 474 Errors are printed as if they would be the parameter value. Use
6211c335
YQ
475 zeroed ARG iff it should not be printed according to VALUES. If
476 SKIP_UNAVAILABLE is true, only print ARG if it is available. */
93d86cef
JK
477
478static void
479list_arg_or_local (const struct frame_arg *arg, enum what_to_list what,
6211c335 480 enum print_values values, int skip_unavailable)
93d86cef 481{
93d86cef 482 struct ui_out *uiout = current_uiout;
f99d8bf4 483
93d86cef
JK
484 gdb_assert (!arg->val || !arg->error);
485 gdb_assert ((values == PRINT_NO_VALUES && arg->val == NULL
486 && arg->error == NULL)
487 || values == PRINT_SIMPLE_VALUES
488 || (values == PRINT_ALL_VALUES
489 && (arg->val != NULL || arg->error != NULL)));
e18b2753
JK
490 gdb_assert (arg->entry_kind == print_entry_values_no
491 || (arg->entry_kind == print_entry_values_only
492 && (arg->val || arg->error)));
93d86cef 493
6211c335
YQ
494 if (skip_unavailable && arg->val != NULL
495 && (value_entirely_unavailable (arg->val)
496 /* A scalar object that does not have all bits available is
497 also considered unavailable, because all bits contribute
498 to its representation. */
499 || (val_print_scalar_type_p (value_type (arg->val))
500 && !value_bytes_available (arg->val,
501 value_embedded_offset (arg->val),
502 TYPE_LENGTH (value_type (arg->val))))))
503 return;
504
0092b74d 505 gdb::optional<ui_out_emit_tuple> tuple_emitter;
93d86cef 506 if (values != PRINT_NO_VALUES || what == all)
0092b74d 507 tuple_emitter.emplace (uiout, nullptr);
93d86cef 508
d7e74731
PA
509 string_file stb;
510
511 stb.puts (SYMBOL_PRINT_NAME (arg->sym));
e18b2753 512 if (arg->entry_kind == print_entry_values_only)
d7e74731 513 stb.puts ("@entry");
112e8700 514 uiout->field_stream ("name", stb);
93d86cef
JK
515
516 if (what == all && SYMBOL_IS_ARGUMENT (arg->sym))
112e8700 517 uiout->field_int ("arg", 1);
93d86cef
JK
518
519 if (values == PRINT_SIMPLE_VALUES)
520 {
521 check_typedef (arg->sym->type);
d7e74731 522 type_print (arg->sym->type, "", &stb, -1);
112e8700 523 uiout->field_stream ("type", stb);
93d86cef
JK
524 }
525
526 if (arg->val || arg->error)
527 {
492d29ea 528 const char *error_message = NULL;
93d86cef
JK
529
530 if (arg->error)
492d29ea 531 error_message = arg->error;
93d86cef
JK
532 else
533 {
492d29ea 534 TRY
93d86cef
JK
535 {
536 struct value_print_options opts;
537
2a998fc0 538 get_no_prettyformat_print_options (&opts);
93d86cef 539 opts.deref_ref = 1;
d7e74731 540 common_val_print (arg->val, &stb, 0, &opts,
93d86cef
JK
541 language_def (SYMBOL_LANGUAGE (arg->sym)));
542 }
492d29ea
PA
543 CATCH (except, RETURN_MASK_ERROR)
544 {
545 error_message = except.message;
546 }
547 END_CATCH
93d86cef 548 }
492d29ea 549 if (error_message != NULL)
d7e74731 550 stb.printf (_("<error reading variable: %s>"), error_message);
112e8700 551 uiout->field_stream ("value", stb);
93d86cef 552 }
93d86cef 553}
daf3c977 554
5c4aa40b
YQ
555/* Print a list of the objects for the frame FI in a certain form,
556 which is determined by VALUES. The objects can be locals,
6211c335
YQ
557 arguments or both, which is determined by WHAT. If SKIP_UNAVAILABLE
558 is true, only print the arguments or local variables whose values
559 are available. */
2b03b41d 560
fb40c209 561static void
bdaf8d4a 562list_args_or_locals (enum what_to_list what, enum print_values values,
6211c335 563 struct frame_info *fi, int skip_unavailable)
fb40c209 564{
3977b71f 565 const struct block *block;
fb40c209 566 struct symbol *sym;
8157b174 567 struct block_iterator iter;
f5ec2042 568 struct type *type;
a121b7c1 569 const char *name_of_result;
79a45e25 570 struct ui_out *uiout = current_uiout;
fb40c209 571
ae767bfb 572 block = get_frame_block (fi, 0);
fb40c209 573
daf3c977
VP
574 switch (what)
575 {
576 case locals:
d6fd4674
PA
577 name_of_result = "locals";
578 break;
daf3c977 579 case arguments:
d6fd4674
PA
580 name_of_result = "args";
581 break;
daf3c977 582 case all:
d6fd4674
PA
583 name_of_result = "variables";
584 break;
654e7c1f 585 default:
d6fd4674
PA
586 internal_error (__FILE__, __LINE__,
587 "unexpected what_to_list: %d", (int) what);
daf3c977
VP
588 }
589
10f489e5 590 ui_out_emit_list list_emitter (uiout, name_of_result);
fb40c209
AC
591
592 while (block != 0)
593 {
de4f826b 594 ALL_BLOCK_SYMBOLS (block, iter, sym)
fb40c209 595 {
39bf4652
JB
596 int print_me = 0;
597
fb40c209
AC
598 switch (SYMBOL_CLASS (sym))
599 {
600 default:
601 case LOC_UNDEF: /* catches errors */
602 case LOC_CONST: /* constant */
603 case LOC_TYPEDEF: /* local typedef */
604 case LOC_LABEL: /* local label */
605 case LOC_BLOCK: /* local function */
606 case LOC_CONST_BYTES: /* loc. byte seq. */
607 case LOC_UNRESOLVED: /* unresolved static */
608 case LOC_OPTIMIZED_OUT: /* optimized out */
609 print_me = 0;
610 break;
611
612 case LOC_ARG: /* argument */
613 case LOC_REF_ARG: /* reference arg */
fb40c209 614 case LOC_REGPARM_ADDR: /* indirect register arg */
fb40c209 615 case LOC_LOCAL: /* stack local */
fb40c209
AC
616 case LOC_STATIC: /* static */
617 case LOC_REGISTER: /* register */
4cf623b6 618 case LOC_COMPUTED: /* computed location */
daf3c977 619 if (what == all)
fb40c209 620 print_me = 1;
daf3c977
VP
621 else if (what == locals)
622 print_me = !SYMBOL_IS_ARGUMENT (sym);
623 else
624 print_me = SYMBOL_IS_ARGUMENT (sym);
fb40c209
AC
625 break;
626 }
627 if (print_me)
628 {
6bb0384f 629 struct symbol *sym2;
e18b2753 630 struct frame_arg arg, entryarg;
fb40c209 631
daf3c977 632 if (SYMBOL_IS_ARGUMENT (sym))
f7e44f65 633 sym2 = lookup_symbol (SYMBOL_LINKAGE_NAME (sym),
f5ec2042 634 block, VAR_DOMAIN,
d12307c1 635 NULL).symbol;
f5ec2042 636 else
2a2d4dc3 637 sym2 = sym;
f7e44f65 638 gdb_assert (sym2 != NULL);
93d86cef
JK
639
640 memset (&arg, 0, sizeof (arg));
641 arg.sym = sym2;
e18b2753
JK
642 arg.entry_kind = print_entry_values_no;
643 memset (&entryarg, 0, sizeof (entryarg));
644 entryarg.sym = sym2;
645 entryarg.entry_kind = print_entry_values_no;
93d86cef 646
f5ec2042
NR
647 switch (values)
648 {
649 case PRINT_SIMPLE_VALUES:
650 type = check_typedef (sym2->type);
f5ec2042
NR
651 if (TYPE_CODE (type) != TYPE_CODE_ARRAY
652 && TYPE_CODE (type) != TYPE_CODE_STRUCT
653 && TYPE_CODE (type) != TYPE_CODE_UNION)
654 {
f5ec2042 655 case PRINT_ALL_VALUES:
82a0a75f
YQ
656 if (SYMBOL_IS_ARGUMENT (sym))
657 read_frame_arg (sym2, fi, &arg, &entryarg);
658 else
659 read_frame_local (sym2, fi, &arg);
93d86cef 660 }
f5ec2042 661 break;
fb40c209 662 }
7a93fb82 663
e18b2753 664 if (arg.entry_kind != print_entry_values_only)
6211c335 665 list_arg_or_local (&arg, what, values, skip_unavailable);
e18b2753 666 if (entryarg.entry_kind != print_entry_values_no)
6211c335 667 list_arg_or_local (&entryarg, what, values, skip_unavailable);
93d86cef 668 xfree (arg.error);
e18b2753 669 xfree (entryarg.error);
fb40c209
AC
670 }
671 }
2b03b41d 672
fb40c209
AC
673 if (BLOCK_FUNCTION (block))
674 break;
675 else
676 block = BLOCK_SUPERBLOCK (block);
677 }
fb40c209
AC
678}
679
ce8f13f8 680void
9f33b8b7 681mi_cmd_stack_select_frame (const char *command, char **argv, int argc)
fb40c209 682{
fcf43932 683 if (argc == 0 || argc > 1)
1b05df00 684 error (_("-stack-select-frame: Usage: FRAME_SPEC"));
fb40c209 685
fcf43932 686 select_frame_command (argv[0], 1 /* not used */ );
fb40c209 687}
64fd8944 688
ce8f13f8 689void
9f33b8b7 690mi_cmd_stack_info_frame (const char *command, char **argv, int argc)
64fd8944
NR
691{
692 if (argc > 0)
2b03b41d 693 error (_("-stack-info-frame: No arguments allowed"));
ce8f13f8 694
08d72866 695 print_frame_info (get_selected_frame (NULL), 1, LOC_AND_ADDRESS, 0, 1);
64fd8944 696}
This page took 1.549756 seconds and 4 git commands to generate.