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