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