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