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