Use RAII to save and restore scalars
[deliverable/binutils-gdb.git] / gdb / mi / mi-cmd-var.c
1 /* MI Command Set - varobj commands.
2 Copyright (C) 2000-2016 Free Software Foundation, Inc.
3
4 Contributed by Cygnus Solutions (a Red Hat company).
5
6 This file is part of GDB.
7
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3 of the License, or
11 (at your option) any later version.
12
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with this program. If not, see <http://www.gnu.org/licenses/>. */
20
21 #include "defs.h"
22 #include "mi-cmds.h"
23 #include "mi-main.h"
24 #include "ui-out.h"
25 #include "mi-out.h"
26 #include "varobj.h"
27 #include "language.h"
28 #include "value.h"
29 #include <ctype.h>
30 #include "mi-getopt.h"
31 #include "gdbthread.h"
32 #include "mi-parse.h"
33
34 extern unsigned int varobjdebug; /* defined in varobj.c. */
35
36 static void varobj_update_one (struct varobj *var,
37 enum print_values print_values,
38 int is_explicit);
39
40 static int mi_print_value_p (struct varobj *var,
41 enum print_values print_values);
42
43 /* Print variable object VAR. The PRINT_VALUES parameter controls
44 if the value should be printed. The PRINT_EXPRESSION parameter
45 controls if the expression should be printed. */
46
47 static void
48 print_varobj (struct varobj *var, enum print_values print_values,
49 int print_expression)
50 {
51 struct ui_out *uiout = current_uiout;
52 char *type;
53 int thread_id;
54 char *display_hint;
55
56 ui_out_field_string (uiout, "name", varobj_get_objname (var));
57 if (print_expression)
58 {
59 char *exp = varobj_get_expression (var);
60
61 ui_out_field_string (uiout, "exp", exp);
62 xfree (exp);
63 }
64 ui_out_field_int (uiout, "numchild", varobj_get_num_children (var));
65
66 if (mi_print_value_p (var, print_values))
67 {
68 char *val = varobj_get_value (var);
69
70 ui_out_field_string (uiout, "value", val);
71 xfree (val);
72 }
73
74 type = varobj_get_type (var);
75 if (type != NULL)
76 {
77 ui_out_field_string (uiout, "type", type);
78 xfree (type);
79 }
80
81 thread_id = varobj_get_thread_id (var);
82 if (thread_id > 0)
83 ui_out_field_int (uiout, "thread-id", thread_id);
84
85 if (varobj_get_frozen (var))
86 ui_out_field_int (uiout, "frozen", 1);
87
88 display_hint = varobj_get_display_hint (var);
89 if (display_hint)
90 {
91 ui_out_field_string (uiout, "displayhint", display_hint);
92 xfree (display_hint);
93 }
94
95 if (varobj_is_dynamic_p (var))
96 ui_out_field_int (uiout, "dynamic", 1);
97 }
98
99 /* VAROBJ operations */
100
101 void
102 mi_cmd_var_create (char *command, char **argv, int argc)
103 {
104 struct ui_out *uiout = current_uiout;
105 CORE_ADDR frameaddr = 0;
106 struct varobj *var;
107 char *name;
108 char *frame;
109 char *expr;
110 struct cleanup *old_cleanups;
111 enum varobj_type var_type;
112
113 if (argc != 3)
114 error (_("-var-create: Usage: NAME FRAME EXPRESSION."));
115
116 name = xstrdup (argv[0]);
117 /* Add cleanup for name. Must be free_current_contents as name can
118 be reallocated. */
119 old_cleanups = make_cleanup (free_current_contents, &name);
120
121 frame = xstrdup (argv[1]);
122 make_cleanup (xfree, frame);
123
124 expr = xstrdup (argv[2]);
125 make_cleanup (xfree, expr);
126
127 if (strcmp (name, "-") == 0)
128 {
129 xfree (name);
130 name = varobj_gen_name ();
131 }
132 else if (!isalpha (*name))
133 error (_("-var-create: name of object must begin with a letter"));
134
135 if (strcmp (frame, "*") == 0)
136 var_type = USE_CURRENT_FRAME;
137 else if (strcmp (frame, "@") == 0)
138 var_type = USE_SELECTED_FRAME;
139 else
140 {
141 var_type = USE_SPECIFIED_FRAME;
142 frameaddr = string_to_core_addr (frame);
143 }
144
145 if (varobjdebug)
146 fprintf_unfiltered (gdb_stdlog,
147 "Name=\"%s\", Frame=\"%s\" (%s), Expression=\"%s\"\n",
148 name, frame, hex_string (frameaddr), expr);
149
150 var = varobj_create (name, expr, frameaddr, var_type);
151
152 if (var == NULL)
153 error (_("-var-create: unable to create variable object"));
154
155 print_varobj (var, PRINT_ALL_VALUES, 0 /* don't print expression */);
156
157 ui_out_field_int (uiout, "has_more", varobj_has_more (var, 0));
158
159 do_cleanups (old_cleanups);
160 }
161
162 void
163 mi_cmd_var_delete (char *command, char **argv, int argc)
164 {
165 char *name;
166 struct varobj *var;
167 int numdel;
168 int children_only_p = 0;
169 struct cleanup *old_cleanups;
170 struct ui_out *uiout = current_uiout;
171
172 if (argc < 1 || argc > 2)
173 error (_("-var-delete: Usage: [-c] EXPRESSION."));
174
175 name = xstrdup (argv[0]);
176 /* Add cleanup for name. Must be free_current_contents as name can
177 be reallocated. */
178 old_cleanups = make_cleanup (free_current_contents, &name);
179
180 /* If we have one single argument it cannot be '-c' or any string
181 starting with '-'. */
182 if (argc == 1)
183 {
184 if (strcmp (name, "-c") == 0)
185 error (_("-var-delete: Missing required "
186 "argument after '-c': variable object name"));
187 if (*name == '-')
188 error (_("-var-delete: Illegal variable object name"));
189 }
190
191 /* If we have 2 arguments they must be '-c' followed by a string
192 which would be the variable name. */
193 if (argc == 2)
194 {
195 if (strcmp (name, "-c") != 0)
196 error (_("-var-delete: Invalid option."));
197 children_only_p = 1;
198 do_cleanups (old_cleanups);
199 name = xstrdup (argv[1]);
200 old_cleanups = make_cleanup (free_current_contents, &name);
201 }
202
203 /* If we didn't error out, now NAME contains the name of the
204 variable. */
205
206 var = varobj_get_handle (name);
207
208 numdel = varobj_delete (var, children_only_p);
209
210 ui_out_field_int (uiout, "ndeleted", numdel);
211
212 do_cleanups (old_cleanups);
213 }
214
215 /* Parse a string argument into a format value. */
216
217 static enum varobj_display_formats
218 mi_parse_format (const char *arg)
219 {
220 if (arg != NULL)
221 {
222 int len;
223
224 len = strlen (arg);
225
226 if (strncmp (arg, "natural", len) == 0)
227 return FORMAT_NATURAL;
228 else if (strncmp (arg, "binary", len) == 0)
229 return FORMAT_BINARY;
230 else if (strncmp (arg, "decimal", len) == 0)
231 return FORMAT_DECIMAL;
232 else if (strncmp (arg, "hexadecimal", len) == 0)
233 return FORMAT_HEXADECIMAL;
234 else if (strncmp (arg, "octal", len) == 0)
235 return FORMAT_OCTAL;
236 else if (strncmp (arg, "zero-hexadecimal", len) == 0)
237 return FORMAT_ZHEXADECIMAL;
238 }
239
240 error (_("Must specify the format as: \"natural\", "
241 "\"binary\", \"decimal\", \"hexadecimal\", \"octal\" or \"zero-hexadecimal\""));
242 }
243
244 void
245 mi_cmd_var_set_format (char *command, char **argv, int argc)
246 {
247 enum varobj_display_formats format;
248 struct varobj *var;
249 char *val;
250 struct ui_out *uiout = current_uiout;
251
252 if (argc != 2)
253 error (_("-var-set-format: Usage: NAME FORMAT."));
254
255 /* Get varobj handle, if a valid var obj name was specified. */
256 var = varobj_get_handle (argv[0]);
257
258 format = mi_parse_format (argv[1]);
259
260 /* Set the format of VAR to the given format. */
261 varobj_set_display_format (var, format);
262
263 /* Report the new current format. */
264 ui_out_field_string (uiout, "format", varobj_format_string[(int) format]);
265
266 /* Report the value in the new format. */
267 val = varobj_get_value (var);
268 ui_out_field_string (uiout, "value", val);
269 xfree (val);
270 }
271
272 void
273 mi_cmd_var_set_visualizer (char *command, char **argv, int argc)
274 {
275 struct varobj *var;
276
277 if (argc != 2)
278 error (_("Usage: NAME VISUALIZER_FUNCTION."));
279
280 var = varobj_get_handle (argv[0]);
281
282 if (var == NULL)
283 error (_("Variable object not found"));
284
285 varobj_set_visualizer (var, argv[1]);
286 }
287
288 void
289 mi_cmd_var_set_frozen (char *command, char **argv, int argc)
290 {
291 struct varobj *var;
292 int frozen;
293
294 if (argc != 2)
295 error (_("-var-set-format: Usage: NAME FROZEN_FLAG."));
296
297 var = varobj_get_handle (argv[0]);
298
299 if (strcmp (argv[1], "0") == 0)
300 frozen = 0;
301 else if (strcmp (argv[1], "1") == 0)
302 frozen = 1;
303 else
304 error (_("Invalid flag value"));
305
306 varobj_set_frozen (var, frozen);
307
308 /* We don't automatically return the new value, or what varobjs got
309 new values during unfreezing. If this information is required,
310 client should call -var-update explicitly. */
311 }
312
313 void
314 mi_cmd_var_show_format (char *command, char **argv, int argc)
315 {
316 struct ui_out *uiout = current_uiout;
317 enum varobj_display_formats format;
318 struct varobj *var;
319
320 if (argc != 1)
321 error (_("-var-show-format: Usage: NAME."));
322
323 /* Get varobj handle, if a valid var obj name was specified. */
324 var = varobj_get_handle (argv[0]);
325
326 format = varobj_get_display_format (var);
327
328 /* Report the current format. */
329 ui_out_field_string (uiout, "format", varobj_format_string[(int) format]);
330 }
331
332 void
333 mi_cmd_var_info_num_children (char *command, char **argv, int argc)
334 {
335 struct ui_out *uiout = current_uiout;
336 struct varobj *var;
337
338 if (argc != 1)
339 error (_("-var-info-num-children: Usage: NAME."));
340
341 /* Get varobj handle, if a valid var obj name was specified. */
342 var = varobj_get_handle (argv[0]);
343
344 ui_out_field_int (uiout, "numchild", varobj_get_num_children (var));
345 }
346
347 /* Return 1 if given the argument PRINT_VALUES we should display
348 the varobj VAR. */
349
350 static int
351 mi_print_value_p (struct varobj *var, enum print_values print_values)
352 {
353 struct type *type;
354
355 if (print_values == PRINT_NO_VALUES)
356 return 0;
357
358 if (print_values == PRINT_ALL_VALUES)
359 return 1;
360
361 if (varobj_is_dynamic_p (var))
362 return 1;
363
364 type = varobj_get_gdb_type (var);
365 if (type == NULL)
366 return 1;
367 else
368 {
369 type = check_typedef (type);
370
371 /* For PRINT_SIMPLE_VALUES, only print the value if it has a type
372 and that type is not a compound type. */
373 return (TYPE_CODE (type) != TYPE_CODE_ARRAY
374 && TYPE_CODE (type) != TYPE_CODE_STRUCT
375 && TYPE_CODE (type) != TYPE_CODE_UNION);
376 }
377 }
378
379 void
380 mi_cmd_var_list_children (char *command, char **argv, int argc)
381 {
382 struct ui_out *uiout = current_uiout;
383 struct varobj *var;
384 VEC(varobj_p) *children;
385 struct varobj *child;
386 enum print_values print_values;
387 int ix;
388 int from, to;
389 char *display_hint;
390
391 if (argc < 1 || argc > 4)
392 error (_("-var-list-children: Usage: "
393 "[PRINT_VALUES] NAME [FROM TO]"));
394
395 /* Get varobj handle, if a valid var obj name was specified. */
396 if (argc == 1 || argc == 3)
397 var = varobj_get_handle (argv[0]);
398 else
399 var = varobj_get_handle (argv[1]);
400
401 if (argc > 2)
402 {
403 from = atoi (argv[argc - 2]);
404 to = atoi (argv[argc - 1]);
405 }
406 else
407 {
408 from = -1;
409 to = -1;
410 }
411
412 children = varobj_list_children (var, &from, &to);
413 ui_out_field_int (uiout, "numchild", to - from);
414 if (argc == 2 || argc == 4)
415 print_values = mi_parse_print_values (argv[0]);
416 else
417 print_values = PRINT_NO_VALUES;
418
419 display_hint = varobj_get_display_hint (var);
420 if (display_hint)
421 {
422 ui_out_field_string (uiout, "displayhint", display_hint);
423 xfree (display_hint);
424 }
425
426 if (from < to)
427 {
428 struct cleanup *cleanup_children;
429
430 if (mi_version (uiout) == 1)
431 cleanup_children
432 = make_cleanup_ui_out_tuple_begin_end (uiout, "children");
433 else
434 cleanup_children
435 = make_cleanup_ui_out_list_begin_end (uiout, "children");
436 for (ix = from;
437 ix < to && VEC_iterate (varobj_p, children, ix, child);
438 ++ix)
439 {
440 struct cleanup *cleanup_child;
441
442 cleanup_child = make_cleanup_ui_out_tuple_begin_end (uiout, "child");
443 print_varobj (child, print_values, 1 /* print expression */);
444 do_cleanups (cleanup_child);
445 }
446 do_cleanups (cleanup_children);
447 }
448
449 ui_out_field_int (uiout, "has_more", varobj_has_more (var, to));
450 }
451
452 void
453 mi_cmd_var_info_type (char *command, char **argv, int argc)
454 {
455 struct ui_out *uiout = current_uiout;
456 struct varobj *var;
457 char *type_name;
458
459 if (argc != 1)
460 error (_("-var-info-type: Usage: NAME."));
461
462 /* Get varobj handle, if a valid var obj name was specified. */
463 var = varobj_get_handle (argv[0]);
464 type_name = varobj_get_type (var);
465
466 ui_out_field_string (uiout, "type", type_name);
467
468 xfree (type_name);
469 }
470
471 void
472 mi_cmd_var_info_path_expression (char *command, char **argv, int argc)
473 {
474 struct ui_out *uiout = current_uiout;
475 struct varobj *var;
476 char *path_expr;
477
478 if (argc != 1)
479 error (_("Usage: NAME."));
480
481 /* Get varobj handle, if a valid var obj name was specified. */
482 var = varobj_get_handle (argv[0]);
483
484 path_expr = varobj_get_path_expr (var);
485
486 ui_out_field_string (uiout, "path_expr", path_expr);
487 }
488
489 void
490 mi_cmd_var_info_expression (char *command, char **argv, int argc)
491 {
492 struct ui_out *uiout = current_uiout;
493 const struct language_defn *lang;
494 struct varobj *var;
495 char *exp;
496
497 if (argc != 1)
498 error (_("-var-info-expression: Usage: NAME."));
499
500 /* Get varobj handle, if a valid var obj name was specified. */
501 var = varobj_get_handle (argv[0]);
502
503 lang = varobj_get_language (var);
504
505 ui_out_field_string (uiout, "lang", lang->la_natural_name);
506
507 exp = varobj_get_expression (var);
508 ui_out_field_string (uiout, "exp", exp);
509 xfree (exp);
510 }
511
512 void
513 mi_cmd_var_show_attributes (char *command, char **argv, int argc)
514 {
515 struct ui_out *uiout = current_uiout;
516 int attr;
517 char *attstr;
518 struct varobj *var;
519
520 if (argc != 1)
521 error (_("-var-show-attributes: Usage: NAME."));
522
523 /* Get varobj handle, if a valid var obj name was specified */
524 var = varobj_get_handle (argv[0]);
525
526 attr = varobj_get_attributes (var);
527 /* FIXME: define masks for attributes */
528 if (attr & 0x00000001)
529 attstr = "editable";
530 else
531 attstr = "noneditable";
532
533 ui_out_field_string (uiout, "attr", attstr);
534 }
535
536 void
537 mi_cmd_var_evaluate_expression (char *command, char **argv, int argc)
538 {
539 struct ui_out *uiout = current_uiout;
540 struct varobj *var;
541
542 enum varobj_display_formats format;
543 int formatFound;
544 int oind;
545 char *oarg;
546
547 enum opt
548 {
549 OP_FORMAT
550 };
551 static const struct mi_opt opts[] =
552 {
553 {"f", OP_FORMAT, 1},
554 { 0, 0, 0 }
555 };
556
557 /* Parse arguments. */
558 format = FORMAT_NATURAL;
559 formatFound = 0;
560 oind = 0;
561 while (1)
562 {
563 int opt = mi_getopt ("-var-evaluate-expression", argc, argv,
564 opts, &oind, &oarg);
565
566 if (opt < 0)
567 break;
568 switch ((enum opt) opt)
569 {
570 case OP_FORMAT:
571 if (formatFound)
572 error (_("Cannot specify format more than once"));
573
574 format = mi_parse_format (oarg);
575 formatFound = 1;
576 break;
577 }
578 }
579
580 if (oind >= argc)
581 error (_("Usage: [-f FORMAT] NAME"));
582
583 if (oind < argc - 1)
584 error (_("Garbage at end of command"));
585
586 /* Get varobj handle, if a valid var obj name was specified. */
587 var = varobj_get_handle (argv[oind]);
588
589 if (formatFound)
590 {
591 char *val = varobj_get_formatted_value (var, format);
592
593 ui_out_field_string (uiout, "value", val);
594 xfree (val);
595 }
596 else
597 {
598 char *val = varobj_get_value (var);
599
600 ui_out_field_string (uiout, "value", val);
601 xfree (val);
602 }
603 }
604
605 void
606 mi_cmd_var_assign (char *command, char **argv, int argc)
607 {
608 struct ui_out *uiout = current_uiout;
609 struct varobj *var;
610 char *expression, *val;
611
612 if (argc != 2)
613 error (_("-var-assign: Usage: NAME EXPRESSION."));
614
615 /* Get varobj handle, if a valid var obj name was specified. */
616 var = varobj_get_handle (argv[0]);
617
618 if (!varobj_editable_p (var))
619 error (_("-var-assign: Variable object is not editable"));
620
621 expression = xstrdup (argv[1]);
622
623 /* MI command '-var-assign' may write memory, so suppress memory
624 changed notification if it does. */
625 scoped_restore save_suppress
626 = make_scoped_restore (&mi_suppress_notification.memory, 1);
627
628 if (!varobj_set_value (var, expression))
629 error (_("-var-assign: Could not assign "
630 "expression to variable object"));
631
632 val = varobj_get_value (var);
633 ui_out_field_string (uiout, "value", val);
634 xfree (val);
635 }
636
637 /* Type used for parameters passing to mi_cmd_var_update_iter. */
638
639 struct mi_cmd_var_update
640 {
641 int only_floating;
642 enum print_values print_values;
643 };
644
645 /* Helper for mi_cmd_var_update - update each VAR. */
646
647 static void
648 mi_cmd_var_update_iter (struct varobj *var, void *data_pointer)
649 {
650 struct mi_cmd_var_update *data = (struct mi_cmd_var_update *) data_pointer;
651 int thread_id, thread_stopped;
652
653 thread_id = varobj_get_thread_id (var);
654
655 if (thread_id == -1
656 && (ptid_equal (inferior_ptid, null_ptid)
657 || is_stopped (inferior_ptid)))
658 thread_stopped = 1;
659 else
660 {
661 struct thread_info *tp = find_thread_global_id (thread_id);
662
663 if (tp)
664 thread_stopped = is_stopped (tp->ptid);
665 else
666 thread_stopped = 1;
667 }
668
669 if (thread_stopped
670 && (!data->only_floating || varobj_floating_p (var)))
671 varobj_update_one (var, data->print_values, 0 /* implicit */);
672 }
673
674 void
675 mi_cmd_var_update (char *command, char **argv, int argc)
676 {
677 struct ui_out *uiout = current_uiout;
678 struct cleanup *cleanup;
679 char *name;
680 enum print_values print_values;
681
682 if (argc != 1 && argc != 2)
683 error (_("-var-update: Usage: [PRINT_VALUES] NAME."));
684
685 if (argc == 1)
686 name = argv[0];
687 else
688 name = argv[1];
689
690 if (argc == 2)
691 print_values = mi_parse_print_values (argv[0]);
692 else
693 print_values = PRINT_NO_VALUES;
694
695 if (mi_version (uiout) <= 1)
696 cleanup = make_cleanup_ui_out_tuple_begin_end (uiout, "changelist");
697 else
698 cleanup = make_cleanup_ui_out_list_begin_end (uiout, "changelist");
699
700 /* Check if the parameter is a "*", which means that we want to
701 update all variables. */
702
703 if ((*name == '*' || *name == '@') && (*(name + 1) == '\0'))
704 {
705 struct mi_cmd_var_update data;
706
707 data.only_floating = (*name == '@');
708 data.print_values = print_values;
709
710 /* varobj_update_one automatically updates all the children of
711 VAROBJ. Therefore update each VAROBJ only once by iterating
712 only the root VAROBJs. */
713
714 all_root_varobjs (mi_cmd_var_update_iter, &data);
715 }
716 else
717 {
718 /* Get varobj handle, if a valid var obj name was specified. */
719 struct varobj *var = varobj_get_handle (name);
720
721 varobj_update_one (var, print_values, 1 /* explicit */);
722 }
723
724 do_cleanups (cleanup);
725 }
726
727 /* Helper for mi_cmd_var_update(). */
728
729 static void
730 varobj_update_one (struct varobj *var, enum print_values print_values,
731 int is_explicit)
732 {
733 struct ui_out *uiout = current_uiout;
734 VEC (varobj_update_result) *changes;
735 varobj_update_result *r;
736 int i;
737
738 changes = varobj_update (&var, is_explicit);
739
740 for (i = 0; VEC_iterate (varobj_update_result, changes, i, r); ++i)
741 {
742 char *display_hint;
743 int from, to;
744 struct cleanup *cleanup = make_cleanup (null_cleanup, NULL);
745
746 if (mi_version (uiout) > 1)
747 make_cleanup_ui_out_tuple_begin_end (uiout, NULL);
748 ui_out_field_string (uiout, "name", varobj_get_objname (r->varobj));
749
750 switch (r->status)
751 {
752 case VAROBJ_IN_SCOPE:
753 if (mi_print_value_p (r->varobj, print_values))
754 {
755 char *val = varobj_get_value (r->varobj);
756
757 ui_out_field_string (uiout, "value", val);
758 xfree (val);
759 }
760 ui_out_field_string (uiout, "in_scope", "true");
761 break;
762 case VAROBJ_NOT_IN_SCOPE:
763 ui_out_field_string (uiout, "in_scope", "false");
764 break;
765 case VAROBJ_INVALID:
766 ui_out_field_string (uiout, "in_scope", "invalid");
767 break;
768 }
769
770 if (r->status != VAROBJ_INVALID)
771 {
772 if (r->type_changed)
773 ui_out_field_string (uiout, "type_changed", "true");
774 else
775 ui_out_field_string (uiout, "type_changed", "false");
776 }
777
778 if (r->type_changed)
779 {
780 char *type_name = varobj_get_type (r->varobj);
781
782 ui_out_field_string (uiout, "new_type", type_name);
783 xfree (type_name);
784 }
785
786 if (r->type_changed || r->children_changed)
787 ui_out_field_int (uiout, "new_num_children",
788 varobj_get_num_children (r->varobj));
789
790 display_hint = varobj_get_display_hint (r->varobj);
791 if (display_hint)
792 {
793 ui_out_field_string (uiout, "displayhint", display_hint);
794 xfree (display_hint);
795 }
796
797 if (varobj_is_dynamic_p (r->varobj))
798 ui_out_field_int (uiout, "dynamic", 1);
799
800 varobj_get_child_range (r->varobj, &from, &to);
801 ui_out_field_int (uiout, "has_more",
802 varobj_has_more (r->varobj, to));
803
804 if (r->newobj)
805 {
806 int j;
807 varobj_p child;
808 struct cleanup *cleanup;
809
810 cleanup = make_cleanup_ui_out_list_begin_end (uiout, "new_children");
811 for (j = 0; VEC_iterate (varobj_p, r->newobj, j, child); ++j)
812 {
813 struct cleanup *cleanup_child;
814
815 cleanup_child
816 = make_cleanup_ui_out_tuple_begin_end (uiout, NULL);
817 print_varobj (child, print_values, 1 /* print_expression */);
818 do_cleanups (cleanup_child);
819 }
820
821 do_cleanups (cleanup);
822 VEC_free (varobj_p, r->newobj);
823 r->newobj = NULL; /* Paranoia. */
824 }
825
826 do_cleanups (cleanup);
827 }
828 VEC_free (varobj_update_result, changes);
829 }
830
831 void
832 mi_cmd_enable_pretty_printing (char *command, char **argv, int argc)
833 {
834 if (argc != 0)
835 error (_("-enable-pretty-printing: no arguments allowed"));
836
837 varobj_enable_pretty_printing ();
838 }
839
840 void
841 mi_cmd_var_set_update_range (char *command, char **argv, int argc)
842 {
843 struct varobj *var;
844 int from, to;
845
846 if (argc != 3)
847 error (_("-var-set-update-range: Usage: VAROBJ FROM TO"));
848
849 var = varobj_get_handle (argv[0]);
850 from = atoi (argv[1]);
851 to = atoi (argv[2]);
852
853 varobj_set_child_range (var, from, to);
854 }
This page took 0.058788 seconds and 5 git commands to generate.