Import gdb-7.10.1
[dragonfly.git] / contrib / gdb-7 / gdb / mi / mi-cmd-var.c
1 /* MI Command Set - varobj commands.
2    Copyright (C) 2000-2015 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, NULL, 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     }
237
238   error (_("Must specify the format as: \"natural\", "
239            "\"binary\", \"decimal\", \"hexadecimal\", or \"octal\""));
240 }
241
242 void
243 mi_cmd_var_set_format (char *command, char **argv, int argc)
244 {
245   enum varobj_display_formats format;
246   struct varobj *var;
247   char *val;
248   struct ui_out *uiout = current_uiout;
249
250   if (argc != 2)
251     error (_("-var-set-format: Usage: NAME FORMAT."));
252
253   /* Get varobj handle, if a valid var obj name was specified.  */
254   var = varobj_get_handle (argv[0]);
255
256   format = mi_parse_format (argv[1]);
257   
258   /* Set the format of VAR to the given format.  */
259   varobj_set_display_format (var, format);
260
261   /* Report the new current format.  */
262   ui_out_field_string (uiout, "format", varobj_format_string[(int) format]);
263  
264   /* Report the value in the new format.  */
265   val = varobj_get_value (var);
266   ui_out_field_string (uiout, "value", val);
267   xfree (val);
268 }
269
270 void
271 mi_cmd_var_set_visualizer (char *command, char **argv, int argc)
272 {
273   struct varobj *var;
274
275   if (argc != 2)
276     error (_("Usage: NAME VISUALIZER_FUNCTION."));
277
278   var = varobj_get_handle (argv[0]);
279
280   if (var == NULL)
281     error (_("Variable object not found"));
282
283   varobj_set_visualizer (var, argv[1]);
284 }
285
286 void
287 mi_cmd_var_set_frozen (char *command, char **argv, int argc)
288 {
289   struct varobj *var;
290   int frozen;
291
292   if (argc != 2)
293     error (_("-var-set-format: Usage: NAME FROZEN_FLAG."));
294
295   var = varobj_get_handle (argv[0]);
296
297   if (strcmp (argv[1], "0") == 0)
298     frozen = 0;
299   else if (strcmp (argv[1], "1") == 0)
300     frozen = 1;
301   else
302     error (_("Invalid flag value"));
303
304   varobj_set_frozen (var, frozen);
305
306   /* We don't automatically return the new value, or what varobjs got
307      new values during unfreezing.  If this information is required,
308      client should call -var-update explicitly.  */
309 }
310
311 void
312 mi_cmd_var_show_format (char *command, char **argv, int argc)
313 {
314   struct ui_out *uiout = current_uiout;
315   enum varobj_display_formats format;
316   struct varobj *var;
317
318   if (argc != 1)
319     error (_("-var-show-format: Usage: NAME."));
320
321   /* Get varobj handle, if a valid var obj name was specified.  */
322   var = varobj_get_handle (argv[0]);
323
324   format = varobj_get_display_format (var);
325
326   /* Report the current format.  */
327   ui_out_field_string (uiout, "format", varobj_format_string[(int) format]);
328 }
329
330 void
331 mi_cmd_var_info_num_children (char *command, char **argv, int argc)
332 {
333   struct ui_out *uiout = current_uiout;
334   struct varobj *var;
335
336   if (argc != 1)
337     error (_("-var-info-num-children: Usage: NAME."));
338
339   /* Get varobj handle, if a valid var obj name was specified.  */
340   var = varobj_get_handle (argv[0]);
341
342   ui_out_field_int (uiout, "numchild", varobj_get_num_children (var));
343 }
344
345 /* Return 1 if given the argument PRINT_VALUES we should display
346    the varobj VAR.  */
347
348 static int
349 mi_print_value_p (struct varobj *var, enum print_values print_values)
350 {
351   struct type *type;
352
353   if (print_values == PRINT_NO_VALUES)
354     return 0;
355
356   if (print_values == PRINT_ALL_VALUES)
357     return 1;
358
359   if (varobj_is_dynamic_p (var))
360     return 1;
361
362   type = varobj_get_gdb_type (var);
363   if (type == NULL)
364     return 1;
365   else
366     {
367       type = check_typedef (type);
368
369       /* For PRINT_SIMPLE_VALUES, only print the value if it has a type
370          and that type is not a compound type.  */
371       return (TYPE_CODE (type) != TYPE_CODE_ARRAY
372               && TYPE_CODE (type) != TYPE_CODE_STRUCT
373               && TYPE_CODE (type) != TYPE_CODE_UNION);
374     }
375 }
376
377 void
378 mi_cmd_var_list_children (char *command, char **argv, int argc)
379 {
380   struct ui_out *uiout = current_uiout;
381   struct varobj *var;  
382   VEC(varobj_p) *children;
383   struct varobj *child;
384   enum print_values print_values;
385   int ix;
386   int from, to;
387   char *display_hint;
388
389   if (argc < 1 || argc > 4)
390     error (_("-var-list-children: Usage: "
391              "[PRINT_VALUES] NAME [FROM TO]"));
392
393   /* Get varobj handle, if a valid var obj name was specified.  */
394   if (argc == 1 || argc == 3)
395     var = varobj_get_handle (argv[0]);
396   else
397     var = varobj_get_handle (argv[1]);
398
399   if (argc > 2)
400     {
401       from = atoi (argv[argc - 2]);
402       to = atoi (argv[argc - 1]);
403     }
404   else
405     {
406       from = -1;
407       to = -1;
408     }
409
410   children = varobj_list_children (var, &from, &to);
411   ui_out_field_int (uiout, "numchild", to - from);
412   if (argc == 2 || argc == 4)
413     print_values = mi_parse_print_values (argv[0]);
414   else
415     print_values = PRINT_NO_VALUES;
416
417   display_hint = varobj_get_display_hint (var);
418   if (display_hint)
419     {
420       ui_out_field_string (uiout, "displayhint", display_hint);
421       xfree (display_hint);
422     }
423
424   if (from < to)
425     {
426       struct cleanup *cleanup_children;
427
428       if (mi_version (uiout) == 1)
429         cleanup_children
430           = make_cleanup_ui_out_tuple_begin_end (uiout, "children");
431       else
432         cleanup_children
433           = make_cleanup_ui_out_list_begin_end (uiout, "children");
434       for (ix = from;
435            ix < to && VEC_iterate (varobj_p, children, ix, child);
436            ++ix)
437         {
438           struct cleanup *cleanup_child;
439
440           cleanup_child = make_cleanup_ui_out_tuple_begin_end (uiout, "child");
441           print_varobj (child, print_values, 1 /* print expression */);
442           do_cleanups (cleanup_child);
443         }
444       do_cleanups (cleanup_children);
445     }
446
447   ui_out_field_int (uiout, "has_more", varobj_has_more (var, to));
448 }
449
450 void
451 mi_cmd_var_info_type (char *command, char **argv, int argc)
452 {
453   struct ui_out *uiout = current_uiout;
454   struct varobj *var;
455   char *type_name;
456
457   if (argc != 1)
458     error (_("-var-info-type: Usage: NAME."));
459
460   /* Get varobj handle, if a valid var obj name was specified.  */
461   var = varobj_get_handle (argv[0]);
462   type_name = varobj_get_type (var);
463
464   ui_out_field_string (uiout, "type", type_name);
465
466   xfree (type_name);
467 }
468
469 void
470 mi_cmd_var_info_path_expression (char *command, char **argv, int argc)
471 {
472   struct ui_out *uiout = current_uiout;
473   struct varobj *var;
474   char *path_expr;
475
476   if (argc != 1)
477     error (_("Usage: NAME."));
478
479   /* Get varobj handle, if a valid var obj name was specified.  */
480   var = varobj_get_handle (argv[0]);
481   
482   path_expr = varobj_get_path_expr (var);
483
484   ui_out_field_string (uiout, "path_expr", path_expr);
485 }
486
487 void
488 mi_cmd_var_info_expression (char *command, char **argv, int argc)
489 {
490   struct ui_out *uiout = current_uiout;
491   const struct language_defn *lang;
492   struct varobj *var;
493   char *exp;
494
495   if (argc != 1)
496     error (_("-var-info-expression: Usage: NAME."));
497
498   /* Get varobj handle, if a valid var obj name was specified.  */
499   var = varobj_get_handle (argv[0]);
500
501   lang = varobj_get_language (var);
502
503   ui_out_field_string (uiout, "lang", lang->la_natural_name);
504
505   exp = varobj_get_expression (var);
506   ui_out_field_string (uiout, "exp", exp);
507   xfree (exp);
508 }
509
510 void
511 mi_cmd_var_show_attributes (char *command, char **argv, int argc)
512 {
513   struct ui_out *uiout = current_uiout;
514   int attr;
515   char *attstr;
516   struct varobj *var;
517
518   if (argc != 1)
519     error (_("-var-show-attributes: Usage: NAME."));
520
521   /* Get varobj handle, if a valid var obj name was specified */
522   var = varobj_get_handle (argv[0]);
523
524   attr = varobj_get_attributes (var);
525   /* FIXME: define masks for attributes */
526   if (attr & 0x00000001)
527     attstr = "editable";
528   else
529     attstr = "noneditable";
530
531   ui_out_field_string (uiout, "attr", attstr);
532 }
533
534 void
535 mi_cmd_var_evaluate_expression (char *command, char **argv, int argc)
536 {
537   struct ui_out *uiout = current_uiout;
538   struct varobj *var;
539
540   enum varobj_display_formats format;
541   int formatFound;
542   int oind;
543   char *oarg;
544     
545   enum opt
546   {
547     OP_FORMAT
548   };
549   static const struct mi_opt opts[] =
550     {
551       {"f", OP_FORMAT, 1},
552       { 0, 0, 0 }
553     };
554
555   /* Parse arguments.  */
556   format = FORMAT_NATURAL;
557   formatFound = 0;
558   oind = 0;
559   while (1)
560     {
561       int opt = mi_getopt ("-var-evaluate-expression", argc, argv,
562                            opts, &oind, &oarg);
563
564       if (opt < 0)
565         break;
566       switch ((enum opt) opt)
567         {
568         case OP_FORMAT:
569           if (formatFound)
570             error (_("Cannot specify format more than once"));
571    
572           format = mi_parse_format (oarg);
573           formatFound = 1;
574           break;
575         }
576     }
577
578   if (oind >= argc)
579     error (_("Usage: [-f FORMAT] NAME"));
580    
581   if (oind < argc - 1)
582     error (_("Garbage at end of command"));
583  
584   /* Get varobj handle, if a valid var obj name was specified.  */
585   var = varobj_get_handle (argv[oind]);
586    
587   if (formatFound)
588     {
589       char *val = varobj_get_formatted_value (var, format);
590
591       ui_out_field_string (uiout, "value", val);
592       xfree (val);
593     }
594   else
595     {
596       char *val = varobj_get_value (var);
597
598       ui_out_field_string (uiout, "value", val);
599       xfree (val);
600     }
601 }
602
603 void
604 mi_cmd_var_assign (char *command, char **argv, int argc)
605 {
606   struct ui_out *uiout = current_uiout;
607   struct varobj *var;
608   char *expression, *val;
609   struct cleanup *cleanup;
610
611   if (argc != 2)
612     error (_("-var-assign: Usage: NAME EXPRESSION."));
613
614   /* Get varobj handle, if a valid var obj name was specified.  */
615   var = varobj_get_handle (argv[0]);
616
617   if (!varobj_editable_p (var))
618     error (_("-var-assign: Variable object is not editable"));
619
620   expression = xstrdup (argv[1]);
621
622   /* MI command '-var-assign' may write memory, so suppress memory
623      changed notification if it does.  */
624   cleanup
625     = make_cleanup_restore_integer (&mi_suppress_notification.memory);
626   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   do_cleanups (cleanup);
637 }
638
639 /* Type used for parameters passing to mi_cmd_var_update_iter.  */
640
641 struct mi_cmd_var_update
642   {
643     int only_floating;
644     enum print_values print_values;
645   };
646
647 /* Helper for mi_cmd_var_update - update each VAR.  */
648
649 static void
650 mi_cmd_var_update_iter (struct varobj *var, void *data_pointer)
651 {
652   struct mi_cmd_var_update *data = data_pointer;
653   int thread_id, thread_stopped;
654
655   thread_id = varobj_get_thread_id (var);
656
657   if (thread_id == -1
658       && (ptid_equal (inferior_ptid, null_ptid)
659           || is_stopped (inferior_ptid)))
660     thread_stopped = 1;
661   else
662     {
663       struct thread_info *tp = find_thread_id (thread_id);
664
665       if (tp)
666         thread_stopped = is_stopped (tp->ptid);
667       else
668         thread_stopped = 1;
669     }
670
671   if (thread_stopped
672       && (!data->only_floating || varobj_floating_p (var)))
673     varobj_update_one (var, data->print_values, 0 /* implicit */);
674 }
675
676 void
677 mi_cmd_var_update (char *command, char **argv, int argc)
678 {
679   struct ui_out *uiout = current_uiout;
680   struct cleanup *cleanup;
681   char *name;
682   enum print_values print_values;
683
684   if (argc != 1 && argc != 2)
685     error (_("-var-update: Usage: [PRINT_VALUES] NAME."));
686
687   if (argc == 1)
688     name = argv[0];
689   else
690     name = argv[1];
691
692   if (argc == 2)
693     print_values = mi_parse_print_values (argv[0]);
694   else
695     print_values = PRINT_NO_VALUES;
696
697   if (mi_version (uiout) <= 1)
698     cleanup = make_cleanup_ui_out_tuple_begin_end (uiout, "changelist");
699   else
700     cleanup = make_cleanup_ui_out_list_begin_end (uiout, "changelist");
701
702   /* Check if the parameter is a "*", which means that we want to
703      update all variables.  */
704
705   if ((*name == '*' || *name == '@') && (*(name + 1) == '\0'))
706     {
707       struct mi_cmd_var_update data;
708
709       data.only_floating = (*name == '@');
710       data.print_values = print_values;
711
712       /* varobj_update_one automatically updates all the children of
713          VAROBJ.  Therefore update each VAROBJ only once by iterating
714          only the root VAROBJs.  */
715
716       all_root_varobjs (mi_cmd_var_update_iter, &data);
717     }
718   else
719     {
720       /* Get varobj handle, if a valid var obj name was specified.  */
721       struct varobj *var = varobj_get_handle (name);
722
723       varobj_update_one (var, print_values, 1 /* explicit */);
724     }
725
726   do_cleanups (cleanup);
727 }
728
729 /* Helper for mi_cmd_var_update().  */
730
731 static void
732 varobj_update_one (struct varobj *var, enum print_values print_values,
733                    int is_explicit)
734 {
735   struct ui_out *uiout = current_uiout;
736   VEC (varobj_update_result) *changes;
737   varobj_update_result *r;
738   int i;
739   
740   changes = varobj_update (&var, is_explicit);
741   
742   for (i = 0; VEC_iterate (varobj_update_result, changes, i, r); ++i)
743     {
744       char *display_hint;
745       int from, to;
746       struct cleanup *cleanup = make_cleanup (null_cleanup, NULL);
747
748       if (mi_version (uiout) > 1)
749         make_cleanup_ui_out_tuple_begin_end (uiout, NULL);
750       ui_out_field_string (uiout, "name", varobj_get_objname (r->varobj));
751
752       switch (r->status)
753         {
754         case VAROBJ_IN_SCOPE:
755           if (mi_print_value_p (r->varobj, print_values))
756             {
757               char *val = varobj_get_value (r->varobj);
758
759               ui_out_field_string (uiout, "value", val);
760               xfree (val);
761             }
762           ui_out_field_string (uiout, "in_scope", "true");
763           break;
764         case VAROBJ_NOT_IN_SCOPE:
765           ui_out_field_string (uiout, "in_scope", "false");
766           break;
767         case VAROBJ_INVALID:
768           ui_out_field_string (uiout, "in_scope", "invalid");
769           break;
770         }
771
772       if (r->status != VAROBJ_INVALID)
773         {
774           if (r->type_changed)
775             ui_out_field_string (uiout, "type_changed", "true");
776           else
777             ui_out_field_string (uiout, "type_changed", "false");
778         }
779
780       if (r->type_changed)
781         {
782           char *type_name = varobj_get_type (r->varobj);
783
784           ui_out_field_string (uiout, "new_type", type_name);
785           xfree (type_name);
786         }
787
788       if (r->type_changed || r->children_changed)
789         ui_out_field_int (uiout, "new_num_children", 
790                           varobj_get_num_children (r->varobj));
791
792       display_hint = varobj_get_display_hint (r->varobj);
793       if (display_hint)
794         {
795           ui_out_field_string (uiout, "displayhint", display_hint);
796           xfree (display_hint);
797         }
798
799       if (varobj_is_dynamic_p (r->varobj))
800         ui_out_field_int (uiout, "dynamic", 1);
801
802       varobj_get_child_range (r->varobj, &from, &to);
803       ui_out_field_int (uiout, "has_more",
804                         varobj_has_more (r->varobj, to));
805
806       if (r->newobj)
807         {
808           int j;
809           varobj_p child;
810           struct cleanup *cleanup;
811
812           cleanup = make_cleanup_ui_out_list_begin_end (uiout, "new_children");
813           for (j = 0; VEC_iterate (varobj_p, r->newobj, j, child); ++j)
814             {
815               struct cleanup *cleanup_child;
816
817               cleanup_child
818                 = make_cleanup_ui_out_tuple_begin_end (uiout, NULL);
819               print_varobj (child, print_values, 1 /* print_expression */);
820               do_cleanups (cleanup_child);
821             }
822
823           do_cleanups (cleanup);
824           VEC_free (varobj_p, r->newobj);
825           r->newobj = NULL;     /* Paranoia.  */
826         }
827
828       do_cleanups (cleanup);
829     }
830   VEC_free (varobj_update_result, changes);
831 }
832
833 void
834 mi_cmd_enable_pretty_printing (char *command, char **argv, int argc)
835 {
836   if (argc != 0)
837     error (_("-enable-pretty-printing: no arguments allowed"));
838
839   varobj_enable_pretty_printing ();
840 }
841
842 void
843 mi_cmd_var_set_update_range (char *command, char **argv, int argc)
844 {
845   struct varobj *var;
846   int from, to;
847
848   if (argc != 3)
849     error (_("-var-set-update-range: Usage: VAROBJ FROM TO"));
850   
851   var = varobj_get_handle (argv[0]);
852   from = atoi (argv[1]);
853   to = atoi (argv[2]);
854
855   varobj_set_child_range (var, from, to);
856 }