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