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