GDB (API)
|
00001 /* MI Command Set - varobj commands. 00002 Copyright (C) 2000-2013 Free Software Foundation, Inc. 00003 00004 Contributed by Cygnus Solutions (a Red Hat company). 00005 00006 This file is part of GDB. 00007 00008 This program is free software; you can redistribute it and/or modify 00009 it under the terms of the GNU General Public License as published by 00010 the Free Software Foundation; either version 3 of the License, or 00011 (at your option) any later version. 00012 00013 This program is distributed in the hope that it will be useful, 00014 but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00016 GNU General Public License for more details. 00017 00018 You should have received a copy of the GNU General Public License 00019 along with this program. If not, see <http://www.gnu.org/licenses/>. */ 00020 00021 #include "defs.h" 00022 #include "mi-cmds.h" 00023 #include "mi-main.h" 00024 #include "ui-out.h" 00025 #include "mi-out.h" 00026 #include "varobj.h" 00027 #include "value.h" 00028 #include <ctype.h> 00029 #include "gdb_string.h" 00030 #include "mi-getopt.h" 00031 #include "gdbthread.h" 00032 #include "mi-parse.h" 00033 00034 extern unsigned int varobjdebug; /* defined in varobj.c. */ 00035 00036 static void varobj_update_one (struct varobj *var, 00037 enum print_values print_values, 00038 int explicit); 00039 00040 static int mi_print_value_p (struct varobj *var, 00041 enum print_values print_values); 00042 00043 /* Print variable object VAR. The PRINT_VALUES parameter controls 00044 if the value should be printed. The PRINT_EXPRESSION parameter 00045 controls if the expression should be printed. */ 00046 00047 static void 00048 print_varobj (struct varobj *var, enum print_values print_values, 00049 int print_expression) 00050 { 00051 struct ui_out *uiout = current_uiout; 00052 char *type; 00053 int thread_id; 00054 char *display_hint; 00055 00056 ui_out_field_string (uiout, "name", varobj_get_objname (var)); 00057 if (print_expression) 00058 ui_out_field_string (uiout, "exp", varobj_get_expression (var)); 00059 ui_out_field_int (uiout, "numchild", varobj_get_num_children (var)); 00060 00061 if (mi_print_value_p (var, print_values)) 00062 { 00063 char *val = varobj_get_value (var); 00064 00065 ui_out_field_string (uiout, "value", val); 00066 xfree (val); 00067 } 00068 00069 type = varobj_get_type (var); 00070 if (type != NULL) 00071 { 00072 ui_out_field_string (uiout, "type", type); 00073 xfree (type); 00074 } 00075 00076 thread_id = varobj_get_thread_id (var); 00077 if (thread_id > 0) 00078 ui_out_field_int (uiout, "thread-id", thread_id); 00079 00080 if (varobj_get_frozen (var)) 00081 ui_out_field_int (uiout, "frozen", 1); 00082 00083 display_hint = varobj_get_display_hint (var); 00084 if (display_hint) 00085 { 00086 ui_out_field_string (uiout, "displayhint", display_hint); 00087 xfree (display_hint); 00088 } 00089 00090 if (varobj_pretty_printed_p (var)) 00091 ui_out_field_int (uiout, "dynamic", 1); 00092 } 00093 00094 /* VAROBJ operations */ 00095 00096 void 00097 mi_cmd_var_create (char *command, char **argv, int argc) 00098 { 00099 struct ui_out *uiout = current_uiout; 00100 CORE_ADDR frameaddr = 0; 00101 struct varobj *var; 00102 char *name; 00103 char *frame; 00104 char *expr; 00105 struct cleanup *old_cleanups; 00106 enum varobj_type var_type; 00107 00108 if (argc != 3) 00109 error (_("-var-create: Usage: NAME FRAME EXPRESSION.")); 00110 00111 name = xstrdup (argv[0]); 00112 /* Add cleanup for name. Must be free_current_contents as name can 00113 be reallocated. */ 00114 old_cleanups = make_cleanup (free_current_contents, &name); 00115 00116 frame = xstrdup (argv[1]); 00117 make_cleanup (xfree, frame); 00118 00119 expr = xstrdup (argv[2]); 00120 make_cleanup (xfree, expr); 00121 00122 if (strcmp (name, "-") == 0) 00123 { 00124 xfree (name); 00125 name = varobj_gen_name (); 00126 } 00127 else if (!isalpha (*name)) 00128 error (_("-var-create: name of object must begin with a letter")); 00129 00130 if (strcmp (frame, "*") == 0) 00131 var_type = USE_CURRENT_FRAME; 00132 else if (strcmp (frame, "@") == 0) 00133 var_type = USE_SELECTED_FRAME; 00134 else 00135 { 00136 var_type = USE_SPECIFIED_FRAME; 00137 frameaddr = string_to_core_addr (frame); 00138 } 00139 00140 if (varobjdebug) 00141 fprintf_unfiltered (gdb_stdlog, 00142 "Name=\"%s\", Frame=\"%s\" (%s), Expression=\"%s\"\n", 00143 name, frame, hex_string (frameaddr), expr); 00144 00145 var = varobj_create (name, expr, frameaddr, var_type); 00146 00147 if (var == NULL) 00148 error (_("-var-create: unable to create variable object")); 00149 00150 print_varobj (var, PRINT_ALL_VALUES, 0 /* don't print expression */); 00151 00152 ui_out_field_int (uiout, "has_more", varobj_has_more (var, 0)); 00153 00154 do_cleanups (old_cleanups); 00155 } 00156 00157 void 00158 mi_cmd_var_delete (char *command, char **argv, int argc) 00159 { 00160 char *name; 00161 struct varobj *var; 00162 int numdel; 00163 int children_only_p = 0; 00164 struct cleanup *old_cleanups; 00165 struct ui_out *uiout = current_uiout; 00166 00167 if (argc < 1 || argc > 2) 00168 error (_("-var-delete: Usage: [-c] EXPRESSION.")); 00169 00170 name = xstrdup (argv[0]); 00171 /* Add cleanup for name. Must be free_current_contents as name can 00172 be reallocated. */ 00173 old_cleanups = make_cleanup (free_current_contents, &name); 00174 00175 /* If we have one single argument it cannot be '-c' or any string 00176 starting with '-'. */ 00177 if (argc == 1) 00178 { 00179 if (strcmp (name, "-c") == 0) 00180 error (_("-var-delete: Missing required " 00181 "argument after '-c': variable object name")); 00182 if (*name == '-') 00183 error (_("-var-delete: Illegal variable object name")); 00184 } 00185 00186 /* If we have 2 arguments they must be '-c' followed by a string 00187 which would be the variable name. */ 00188 if (argc == 2) 00189 { 00190 if (strcmp (name, "-c") != 0) 00191 error (_("-var-delete: Invalid option.")); 00192 children_only_p = 1; 00193 do_cleanups (old_cleanups); 00194 name = xstrdup (argv[1]); 00195 old_cleanups = make_cleanup (free_current_contents, &name); 00196 } 00197 00198 /* If we didn't error out, now NAME contains the name of the 00199 variable. */ 00200 00201 var = varobj_get_handle (name); 00202 00203 numdel = varobj_delete (var, NULL, children_only_p); 00204 00205 ui_out_field_int (uiout, "ndeleted", numdel); 00206 00207 do_cleanups (old_cleanups); 00208 } 00209 00210 /* Parse a string argument into a format value. */ 00211 00212 static enum varobj_display_formats 00213 mi_parse_format (const char *arg) 00214 { 00215 if (arg != NULL) 00216 { 00217 int len; 00218 00219 len = strlen (arg); 00220 00221 if (strncmp (arg, "natural", len) == 0) 00222 return FORMAT_NATURAL; 00223 else if (strncmp (arg, "binary", len) == 0) 00224 return FORMAT_BINARY; 00225 else if (strncmp (arg, "decimal", len) == 0) 00226 return FORMAT_DECIMAL; 00227 else if (strncmp (arg, "hexadecimal", len) == 0) 00228 return FORMAT_HEXADECIMAL; 00229 else if (strncmp (arg, "octal", len) == 0) 00230 return FORMAT_OCTAL; 00231 } 00232 00233 error (_("Must specify the format as: \"natural\", " 00234 "\"binary\", \"decimal\", \"hexadecimal\", or \"octal\"")); 00235 } 00236 00237 void 00238 mi_cmd_var_set_format (char *command, char **argv, int argc) 00239 { 00240 enum varobj_display_formats format; 00241 struct varobj *var; 00242 char *val; 00243 struct ui_out *uiout = current_uiout; 00244 00245 if (argc != 2) 00246 error (_("-var-set-format: Usage: NAME FORMAT.")); 00247 00248 /* Get varobj handle, if a valid var obj name was specified. */ 00249 var = varobj_get_handle (argv[0]); 00250 00251 format = mi_parse_format (argv[1]); 00252 00253 /* Set the format of VAR to the given format. */ 00254 varobj_set_display_format (var, format); 00255 00256 /* Report the new current format. */ 00257 ui_out_field_string (uiout, "format", varobj_format_string[(int) format]); 00258 00259 /* Report the value in the new format. */ 00260 val = varobj_get_value (var); 00261 ui_out_field_string (uiout, "value", val); 00262 xfree (val); 00263 } 00264 00265 void 00266 mi_cmd_var_set_visualizer (char *command, char **argv, int argc) 00267 { 00268 struct varobj *var; 00269 00270 if (argc != 2) 00271 error (_("Usage: NAME VISUALIZER_FUNCTION.")); 00272 00273 var = varobj_get_handle (argv[0]); 00274 00275 if (var == NULL) 00276 error (_("Variable object not found")); 00277 00278 varobj_set_visualizer (var, argv[1]); 00279 } 00280 00281 void 00282 mi_cmd_var_set_frozen (char *command, char **argv, int argc) 00283 { 00284 struct varobj *var; 00285 int frozen; 00286 00287 if (argc != 2) 00288 error (_("-var-set-format: Usage: NAME FROZEN_FLAG.")); 00289 00290 var = varobj_get_handle (argv[0]); 00291 00292 if (strcmp (argv[1], "0") == 0) 00293 frozen = 0; 00294 else if (strcmp (argv[1], "1") == 0) 00295 frozen = 1; 00296 else 00297 error (_("Invalid flag value")); 00298 00299 varobj_set_frozen (var, frozen); 00300 00301 /* We don't automatically return the new value, or what varobjs got 00302 new values during unfreezing. If this information is required, 00303 client should call -var-update explicitly. */ 00304 } 00305 00306 void 00307 mi_cmd_var_show_format (char *command, char **argv, int argc) 00308 { 00309 struct ui_out *uiout = current_uiout; 00310 enum varobj_display_formats format; 00311 struct varobj *var; 00312 00313 if (argc != 1) 00314 error (_("-var-show-format: Usage: NAME.")); 00315 00316 /* Get varobj handle, if a valid var obj name was specified. */ 00317 var = varobj_get_handle (argv[0]); 00318 00319 format = varobj_get_display_format (var); 00320 00321 /* Report the current format. */ 00322 ui_out_field_string (uiout, "format", varobj_format_string[(int) format]); 00323 } 00324 00325 void 00326 mi_cmd_var_info_num_children (char *command, char **argv, int argc) 00327 { 00328 struct ui_out *uiout = current_uiout; 00329 struct varobj *var; 00330 00331 if (argc != 1) 00332 error (_("-var-info-num-children: Usage: NAME.")); 00333 00334 /* Get varobj handle, if a valid var obj name was specified. */ 00335 var = varobj_get_handle (argv[0]); 00336 00337 ui_out_field_int (uiout, "numchild", varobj_get_num_children (var)); 00338 } 00339 00340 /* Return 1 if given the argument PRINT_VALUES we should display 00341 the varobj VAR. */ 00342 00343 static int 00344 mi_print_value_p (struct varobj *var, enum print_values print_values) 00345 { 00346 struct type *type; 00347 00348 if (print_values == PRINT_NO_VALUES) 00349 return 0; 00350 00351 if (print_values == PRINT_ALL_VALUES) 00352 return 1; 00353 00354 if (varobj_pretty_printed_p (var)) 00355 return 1; 00356 00357 type = varobj_get_gdb_type (var); 00358 if (type == NULL) 00359 return 1; 00360 else 00361 { 00362 type = check_typedef (type); 00363 00364 /* For PRINT_SIMPLE_VALUES, only print the value if it has a type 00365 and that type is not a compound type. */ 00366 return (TYPE_CODE (type) != TYPE_CODE_ARRAY 00367 && TYPE_CODE (type) != TYPE_CODE_STRUCT 00368 && TYPE_CODE (type) != TYPE_CODE_UNION); 00369 } 00370 } 00371 00372 void 00373 mi_cmd_var_list_children (char *command, char **argv, int argc) 00374 { 00375 struct ui_out *uiout = current_uiout; 00376 struct varobj *var; 00377 VEC(varobj_p) *children; 00378 struct varobj *child; 00379 enum print_values print_values; 00380 int ix; 00381 int from, to; 00382 char *display_hint; 00383 00384 if (argc < 1 || argc > 4) 00385 error (_("-var-list-children: Usage: " 00386 "[PRINT_VALUES] NAME [FROM TO]")); 00387 00388 /* Get varobj handle, if a valid var obj name was specified. */ 00389 if (argc == 1 || argc == 3) 00390 var = varobj_get_handle (argv[0]); 00391 else 00392 var = varobj_get_handle (argv[1]); 00393 00394 if (argc > 2) 00395 { 00396 from = atoi (argv[argc - 2]); 00397 to = atoi (argv[argc - 1]); 00398 } 00399 else 00400 { 00401 from = -1; 00402 to = -1; 00403 } 00404 00405 children = varobj_list_children (var, &from, &to); 00406 ui_out_field_int (uiout, "numchild", to - from); 00407 if (argc == 2 || argc == 4) 00408 print_values = mi_parse_print_values (argv[0]); 00409 else 00410 print_values = PRINT_NO_VALUES; 00411 00412 display_hint = varobj_get_display_hint (var); 00413 if (display_hint) 00414 { 00415 ui_out_field_string (uiout, "displayhint", display_hint); 00416 xfree (display_hint); 00417 } 00418 00419 if (from < to) 00420 { 00421 struct cleanup *cleanup_children; 00422 00423 if (mi_version (uiout) == 1) 00424 cleanup_children 00425 = make_cleanup_ui_out_tuple_begin_end (uiout, "children"); 00426 else 00427 cleanup_children 00428 = make_cleanup_ui_out_list_begin_end (uiout, "children"); 00429 for (ix = from; 00430 ix < to && VEC_iterate (varobj_p, children, ix, child); 00431 ++ix) 00432 { 00433 struct cleanup *cleanup_child; 00434 00435 cleanup_child = make_cleanup_ui_out_tuple_begin_end (uiout, "child"); 00436 print_varobj (child, print_values, 1 /* print expression */); 00437 do_cleanups (cleanup_child); 00438 } 00439 do_cleanups (cleanup_children); 00440 } 00441 00442 ui_out_field_int (uiout, "has_more", varobj_has_more (var, to)); 00443 } 00444 00445 void 00446 mi_cmd_var_info_type (char *command, char **argv, int argc) 00447 { 00448 struct ui_out *uiout = current_uiout; 00449 struct varobj *var; 00450 00451 if (argc != 1) 00452 error (_("-var-info-type: Usage: NAME.")); 00453 00454 /* Get varobj handle, if a valid var obj name was specified. */ 00455 var = varobj_get_handle (argv[0]); 00456 00457 ui_out_field_string (uiout, "type", varobj_get_type (var)); 00458 } 00459 00460 void 00461 mi_cmd_var_info_path_expression (char *command, char **argv, int argc) 00462 { 00463 struct ui_out *uiout = current_uiout; 00464 struct varobj *var; 00465 char *path_expr; 00466 00467 if (argc != 1) 00468 error (_("Usage: NAME.")); 00469 00470 /* Get varobj handle, if a valid var obj name was specified. */ 00471 var = varobj_get_handle (argv[0]); 00472 00473 path_expr = varobj_get_path_expr (var); 00474 00475 ui_out_field_string (uiout, "path_expr", path_expr); 00476 } 00477 00478 void 00479 mi_cmd_var_info_expression (char *command, char **argv, int argc) 00480 { 00481 struct ui_out *uiout = current_uiout; 00482 enum varobj_languages lang; 00483 struct varobj *var; 00484 00485 if (argc != 1) 00486 error (_("-var-info-expression: Usage: NAME.")); 00487 00488 /* Get varobj handle, if a valid var obj name was specified. */ 00489 var = varobj_get_handle (argv[0]); 00490 00491 lang = varobj_get_language (var); 00492 00493 ui_out_field_string (uiout, "lang", varobj_language_string[(int) lang]); 00494 ui_out_field_string (uiout, "exp", varobj_get_expression (var)); 00495 } 00496 00497 void 00498 mi_cmd_var_show_attributes (char *command, char **argv, int argc) 00499 { 00500 struct ui_out *uiout = current_uiout; 00501 int attr; 00502 char *attstr; 00503 struct varobj *var; 00504 00505 if (argc != 1) 00506 error (_("-var-show-attributes: Usage: NAME.")); 00507 00508 /* Get varobj handle, if a valid var obj name was specified */ 00509 var = varobj_get_handle (argv[0]); 00510 00511 attr = varobj_get_attributes (var); 00512 /* FIXME: define masks for attributes */ 00513 if (attr & 0x00000001) 00514 attstr = "editable"; 00515 else 00516 attstr = "noneditable"; 00517 00518 ui_out_field_string (uiout, "attr", attstr); 00519 } 00520 00521 void 00522 mi_cmd_var_evaluate_expression (char *command, char **argv, int argc) 00523 { 00524 struct ui_out *uiout = current_uiout; 00525 struct varobj *var; 00526 00527 enum varobj_display_formats format; 00528 int formatFound; 00529 int oind; 00530 char *oarg; 00531 00532 enum opt 00533 { 00534 OP_FORMAT 00535 }; 00536 static const struct mi_opt opts[] = 00537 { 00538 {"f", OP_FORMAT, 1}, 00539 { 0, 0, 0 } 00540 }; 00541 00542 /* Parse arguments. */ 00543 format = FORMAT_NATURAL; 00544 formatFound = 0; 00545 oind = 0; 00546 while (1) 00547 { 00548 int opt = mi_getopt ("-var-evaluate-expression", argc, argv, 00549 opts, &oind, &oarg); 00550 00551 if (opt < 0) 00552 break; 00553 switch ((enum opt) opt) 00554 { 00555 case OP_FORMAT: 00556 if (formatFound) 00557 error (_("Cannot specify format more than once")); 00558 00559 format = mi_parse_format (oarg); 00560 formatFound = 1; 00561 break; 00562 } 00563 } 00564 00565 if (oind >= argc) 00566 error (_("Usage: [-f FORMAT] NAME")); 00567 00568 if (oind < argc - 1) 00569 error (_("Garbage at end of command")); 00570 00571 /* Get varobj handle, if a valid var obj name was specified. */ 00572 var = varobj_get_handle (argv[oind]); 00573 00574 if (formatFound) 00575 { 00576 char *val = varobj_get_formatted_value (var, format); 00577 00578 ui_out_field_string (uiout, "value", val); 00579 xfree (val); 00580 } 00581 else 00582 { 00583 char *val = varobj_get_value (var); 00584 00585 ui_out_field_string (uiout, "value", val); 00586 xfree (val); 00587 } 00588 } 00589 00590 void 00591 mi_cmd_var_assign (char *command, char **argv, int argc) 00592 { 00593 struct ui_out *uiout = current_uiout; 00594 struct varobj *var; 00595 char *expression, *val; 00596 struct cleanup *cleanup; 00597 00598 if (argc != 2) 00599 error (_("-var-assign: Usage: NAME EXPRESSION.")); 00600 00601 /* Get varobj handle, if a valid var obj name was specified. */ 00602 var = varobj_get_handle (argv[0]); 00603 00604 if (!varobj_editable_p (var)) 00605 error (_("-var-assign: Variable object is not editable")); 00606 00607 expression = xstrdup (argv[1]); 00608 00609 /* MI command '-var-assign' may write memory, so suppress memory 00610 changed notification if it does. */ 00611 cleanup 00612 = make_cleanup_restore_integer (&mi_suppress_notification.memory); 00613 mi_suppress_notification.memory = 1; 00614 00615 if (!varobj_set_value (var, expression)) 00616 error (_("-var-assign: Could not assign " 00617 "expression to variable object")); 00618 00619 val = varobj_get_value (var); 00620 ui_out_field_string (uiout, "value", val); 00621 xfree (val); 00622 00623 do_cleanups (cleanup); 00624 } 00625 00626 /* Type used for parameters passing to mi_cmd_var_update_iter. */ 00627 00628 struct mi_cmd_var_update 00629 { 00630 int only_floating; 00631 enum print_values print_values; 00632 }; 00633 00634 /* Helper for mi_cmd_var_update - update each VAR. */ 00635 00636 static void 00637 mi_cmd_var_update_iter (struct varobj *var, void *data_pointer) 00638 { 00639 struct mi_cmd_var_update *data = data_pointer; 00640 int thread_id, thread_stopped; 00641 00642 thread_id = varobj_get_thread_id (var); 00643 00644 if (thread_id == -1 && is_stopped (inferior_ptid)) 00645 thread_stopped = 1; 00646 else 00647 { 00648 struct thread_info *tp = find_thread_id (thread_id); 00649 00650 if (tp) 00651 thread_stopped = is_stopped (tp->ptid); 00652 else 00653 thread_stopped = 1; 00654 } 00655 00656 if (thread_stopped 00657 && (!data->only_floating || varobj_floating_p (var))) 00658 varobj_update_one (var, data->print_values, 0 /* implicit */); 00659 } 00660 00661 void 00662 mi_cmd_var_update (char *command, char **argv, int argc) 00663 { 00664 struct ui_out *uiout = current_uiout; 00665 struct cleanup *cleanup; 00666 char *name; 00667 enum print_values print_values; 00668 00669 if (argc != 1 && argc != 2) 00670 error (_("-var-update: Usage: [PRINT_VALUES] NAME.")); 00671 00672 if (argc == 1) 00673 name = argv[0]; 00674 else 00675 name = argv[1]; 00676 00677 if (argc == 2) 00678 print_values = mi_parse_print_values (argv[0]); 00679 else 00680 print_values = PRINT_NO_VALUES; 00681 00682 if (mi_version (uiout) <= 1) 00683 cleanup = make_cleanup_ui_out_tuple_begin_end (uiout, "changelist"); 00684 else 00685 cleanup = make_cleanup_ui_out_list_begin_end (uiout, "changelist"); 00686 00687 /* Check if the parameter is a "*", which means that we want to 00688 update all variables. */ 00689 00690 if ((*name == '*' || *name == '@') && (*(name + 1) == '\0')) 00691 { 00692 struct mi_cmd_var_update data; 00693 00694 data.only_floating = (*name == '@'); 00695 data.print_values = print_values; 00696 00697 /* varobj_update_one automatically updates all the children of 00698 VAROBJ. Therefore update each VAROBJ only once by iterating 00699 only the root VAROBJs. */ 00700 00701 all_root_varobjs (mi_cmd_var_update_iter, &data); 00702 } 00703 else 00704 { 00705 /* Get varobj handle, if a valid var obj name was specified. */ 00706 struct varobj *var = varobj_get_handle (name); 00707 00708 varobj_update_one (var, print_values, 1 /* explicit */); 00709 } 00710 00711 do_cleanups (cleanup); 00712 } 00713 00714 /* Helper for mi_cmd_var_update(). */ 00715 00716 static void 00717 varobj_update_one (struct varobj *var, enum print_values print_values, 00718 int explicit) 00719 { 00720 struct ui_out *uiout = current_uiout; 00721 VEC (varobj_update_result) *changes; 00722 varobj_update_result *r; 00723 int i; 00724 00725 changes = varobj_update (&var, explicit); 00726 00727 for (i = 0; VEC_iterate (varobj_update_result, changes, i, r); ++i) 00728 { 00729 char *display_hint; 00730 int from, to; 00731 struct cleanup *cleanup = make_cleanup (null_cleanup, NULL); 00732 00733 if (mi_version (uiout) > 1) 00734 make_cleanup_ui_out_tuple_begin_end (uiout, NULL); 00735 ui_out_field_string (uiout, "name", varobj_get_objname (r->varobj)); 00736 00737 switch (r->status) 00738 { 00739 case VAROBJ_IN_SCOPE: 00740 if (mi_print_value_p (r->varobj, print_values)) 00741 { 00742 char *val = varobj_get_value (r->varobj); 00743 00744 ui_out_field_string (uiout, "value", val); 00745 xfree (val); 00746 } 00747 ui_out_field_string (uiout, "in_scope", "true"); 00748 break; 00749 case VAROBJ_NOT_IN_SCOPE: 00750 ui_out_field_string (uiout, "in_scope", "false"); 00751 break; 00752 case VAROBJ_INVALID: 00753 ui_out_field_string (uiout, "in_scope", "invalid"); 00754 break; 00755 } 00756 00757 if (r->status != VAROBJ_INVALID) 00758 { 00759 if (r->type_changed) 00760 ui_out_field_string (uiout, "type_changed", "true"); 00761 else 00762 ui_out_field_string (uiout, "type_changed", "false"); 00763 } 00764 00765 if (r->type_changed) 00766 ui_out_field_string (uiout, "new_type", varobj_get_type (r->varobj)); 00767 00768 if (r->type_changed || r->children_changed) 00769 ui_out_field_int (uiout, "new_num_children", 00770 varobj_get_num_children (r->varobj)); 00771 00772 display_hint = varobj_get_display_hint (r->varobj); 00773 if (display_hint) 00774 { 00775 ui_out_field_string (uiout, "displayhint", display_hint); 00776 xfree (display_hint); 00777 } 00778 00779 if (varobj_pretty_printed_p (r->varobj)) 00780 ui_out_field_int (uiout, "dynamic", 1); 00781 00782 varobj_get_child_range (r->varobj, &from, &to); 00783 ui_out_field_int (uiout, "has_more", 00784 varobj_has_more (r->varobj, to)); 00785 00786 if (r->new) 00787 { 00788 int j; 00789 varobj_p child; 00790 struct cleanup *cleanup; 00791 00792 cleanup = make_cleanup_ui_out_list_begin_end (uiout, "new_children"); 00793 for (j = 0; VEC_iterate (varobj_p, r->new, j, child); ++j) 00794 { 00795 struct cleanup *cleanup_child; 00796 00797 cleanup_child 00798 = make_cleanup_ui_out_tuple_begin_end (uiout, NULL); 00799 print_varobj (child, print_values, 1 /* print_expression */); 00800 do_cleanups (cleanup_child); 00801 } 00802 00803 do_cleanups (cleanup); 00804 VEC_free (varobj_p, r->new); 00805 r->new = NULL; /* Paranoia. */ 00806 } 00807 00808 do_cleanups (cleanup); 00809 } 00810 VEC_free (varobj_update_result, changes); 00811 } 00812 00813 void 00814 mi_cmd_enable_pretty_printing (char *command, char **argv, int argc) 00815 { 00816 if (argc != 0) 00817 error (_("-enable-pretty-printing: no arguments allowed")); 00818 00819 varobj_enable_pretty_printing (); 00820 } 00821 00822 void 00823 mi_cmd_var_set_update_range (char *command, char **argv, int argc) 00824 { 00825 struct varobj *var; 00826 int from, to; 00827 00828 if (argc != 3) 00829 error (_("-var-set-update-range: Usage: VAROBJ FROM TO")); 00830 00831 var = varobj_get_handle (argv[0]); 00832 from = atoi (argv[1]); 00833 to = atoi (argv[2]); 00834 00835 varobj_set_child_range (var, from, to); 00836 }