* varobj.c (struct varobj_root): New component thread_id.
[deliverable/binutils-gdb.git] / gdb / mi / mi-cmd-var.c
CommitLineData
fb40c209 1/* MI Command Set - varobj commands.
349c5d5f 2
9b254dd1
DJ
3 Copyright (C) 2000, 2002, 2004, 2005, 2007, 2008
4 Free Software Foundation, Inc.
349c5d5f 5
ab91fdd5 6 Contributed by Cygnus Solutions (a Red Hat company).
fb40c209
AC
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
a9762ec7 12 the Free Software Foundation; either version 3 of the License, or
fb40c209
AC
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
a9762ec7 21 along with this program. If not, see <http://www.gnu.org/licenses/>. */
fb40c209
AC
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>
5f8a3188 30#include "gdb_string.h"
fb40c209 31
1ecb4ee0
DJ
32const char mi_no_values[] = "--no-values";
33const char mi_simple_values[] = "--simple-values";
34const char mi_all_values[] = "--all-values";
35
8756216b 36extern int varobjdebug; /* defined in varobj.c. */
fb40c209 37
8756216b 38static void varobj_update_one (struct varobj *var,
25d5ea92
VP
39 enum print_values print_values,
40 int explicit);
fb40c209 41
a217f3f5
VP
42static int mi_print_value_p (struct type *type, 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. */
47static void
48print_varobj (struct varobj *var, enum print_values print_values,
49 int print_expression)
50{
bccc275a 51 struct type *gdb_type;
a217f3f5 52 char *type;
c5b48eac 53 int thread_id;
a217f3f5
VP
54
55 ui_out_field_string (uiout, "name", varobj_get_objname (var));
56 if (print_expression)
57 ui_out_field_string (uiout, "exp", varobj_get_expression (var));
58 ui_out_field_int (uiout, "numchild", varobj_get_num_children (var));
59
9265acad 60 if (mi_print_value_p (varobj_get_gdb_type (var), print_values))
a217f3f5
VP
61 ui_out_field_string (uiout, "value", varobj_get_value (var));
62
63 type = varobj_get_type (var);
64 if (type != NULL)
65 {
66 ui_out_field_string (uiout, "type", type);
67 xfree (type);
68 }
25d5ea92 69
c5b48eac
VP
70 thread_id = varobj_get_thread_id (var);
71 if (thread_id > 0)
72 ui_out_field_int (uiout, "thread-id", thread_id);
73
25d5ea92
VP
74 if (varobj_get_frozen (var))
75 ui_out_field_int (uiout, "frozen", 1);
a217f3f5
VP
76}
77
fb40c209
AC
78/* VAROBJ operations */
79
80enum mi_cmd_result
81mi_cmd_var_create (char *command, char **argv, int argc)
82{
73a93a32 83 CORE_ADDR frameaddr = 0;
fb40c209
AC
84 struct varobj *var;
85 char *name;
86 char *frame;
87 char *expr;
fb40c209 88 struct cleanup *old_cleanups;
73a93a32 89 enum varobj_type var_type;
fb40c209
AC
90
91 if (argc != 3)
92 {
c6902d46
AC
93 /* mi_error_message = xstrprintf ("mi_cmd_var_create: Usage:
94 ...."); return MI_CMD_ERROR; */
8a3fe4f8 95 error (_("mi_cmd_var_create: Usage: NAME FRAME EXPRESSION."));
fb40c209
AC
96 }
97
98 name = xstrdup (argv[0]);
99 /* Add cleanup for name. Must be free_current_contents as
100 name can be reallocated */
47cf603e 101 old_cleanups = make_cleanup (free_current_contents, &name);
fb40c209
AC
102
103 frame = xstrdup (argv[1]);
51b57b6b 104 make_cleanup (xfree, frame);
fb40c209
AC
105
106 expr = xstrdup (argv[2]);
51b57b6b 107 make_cleanup (xfree, expr);
fb40c209
AC
108
109 if (strcmp (name, "-") == 0)
110 {
b8c9b27d 111 xfree (name);
fb40c209
AC
112 name = varobj_gen_name ();
113 }
114 else if (!isalpha (*name))
8a3fe4f8 115 error (_("mi_cmd_var_create: name of object must begin with a letter"));
fb40c209
AC
116
117 if (strcmp (frame, "*") == 0)
73a93a32
JI
118 var_type = USE_CURRENT_FRAME;
119 else if (strcmp (frame, "@") == 0)
120 var_type = USE_SELECTED_FRAME;
fb40c209 121 else
73a93a32
JI
122 {
123 var_type = USE_SPECIFIED_FRAME;
1bd34ded 124 frameaddr = string_to_core_addr (frame);
73a93a32 125 }
fb40c209
AC
126
127 if (varobjdebug)
128 fprintf_unfiltered (gdb_stdlog,
129 "Name=\"%s\", Frame=\"%s\" (0x%s), Expression=\"%s\"\n",
130 name, frame, paddr (frameaddr), expr);
131
73a93a32 132 var = varobj_create (name, expr, frameaddr, var_type);
fb40c209
AC
133
134 if (var == NULL)
8a3fe4f8 135 error (_("mi_cmd_var_create: unable to create variable object"));
fb40c209 136
224e4ca7 137 print_varobj (var, PRINT_ALL_VALUES, 0 /* don't print expression */);
fb40c209
AC
138
139 do_cleanups (old_cleanups);
140 return MI_CMD_DONE;
141}
142
143enum mi_cmd_result
144mi_cmd_var_delete (char *command, char **argv, int argc)
145{
146 char *name;
fb40c209
AC
147 struct varobj *var;
148 int numdel;
149 int children_only_p = 0;
150 struct cleanup *old_cleanups;
151
152 if (argc < 1 || argc > 2)
8a3fe4f8 153 error (_("mi_cmd_var_delete: Usage: [-c] EXPRESSION."));
fb40c209
AC
154
155 name = xstrdup (argv[0]);
156 /* Add cleanup for name. Must be free_current_contents as
157 name can be reallocated */
47cf603e 158 old_cleanups = make_cleanup (free_current_contents, &name);
fb40c209
AC
159
160 /* If we have one single argument it cannot be '-c' or any string
161 starting with '-'. */
162 if (argc == 1)
163 {
164 if (strcmp (name, "-c") == 0)
8a3fe4f8 165 error (_("mi_cmd_var_delete: Missing required argument after '-c': variable object name"));
fb40c209 166 if (*name == '-')
8a3fe4f8 167 error (_("mi_cmd_var_delete: Illegal variable object name"));
fb40c209
AC
168 }
169
170 /* If we have 2 arguments they must be '-c' followed by a string
171 which would be the variable name. */
172 if (argc == 2)
173 {
fb40c209 174 if (strcmp (name, "-c") != 0)
8a3fe4f8 175 error (_("mi_cmd_var_delete: Invalid option."));
fb40c209 176 children_only_p = 1;
474d0d0c
MS
177 do_cleanups (old_cleanups);
178 name = xstrdup (argv[1]);
179 make_cleanup (free_current_contents, &name);
fb40c209
AC
180 }
181
182 /* If we didn't error out, now NAME contains the name of the
183 variable. */
184
185 var = varobj_get_handle (name);
186
187 if (var == NULL)
8a3fe4f8 188 error (_("mi_cmd_var_delete: Variable object not found."));
fb40c209
AC
189
190 numdel = varobj_delete (var, NULL, children_only_p);
191
192 ui_out_field_int (uiout, "ndeleted", numdel);
193
194 do_cleanups (old_cleanups);
195 return MI_CMD_DONE;
196}
197
198enum mi_cmd_result
199mi_cmd_var_set_format (char *command, char **argv, int argc)
200{
201 enum varobj_display_formats format;
202 int len;
203 struct varobj *var;
204 char *formspec;
205
206 if (argc != 2)
8a3fe4f8 207 error (_("mi_cmd_var_set_format: Usage: NAME FORMAT."));
fb40c209
AC
208
209 /* Get varobj handle, if a valid var obj name was specified */
210 var = varobj_get_handle (argv[0]);
211
212 if (var == NULL)
8a3fe4f8 213 error (_("mi_cmd_var_set_format: Variable object not found"));
fb40c209 214
b538c234 215 formspec = argv[1];
fb40c209 216 if (formspec == NULL)
8a3fe4f8 217 error (_("mi_cmd_var_set_format: Must specify the format as: \"natural\", \"binary\", \"decimal\", \"hexadecimal\", or \"octal\""));
fb40c209
AC
218
219 len = strlen (formspec);
220
bf896cb0 221 if (strncmp (formspec, "natural", len) == 0)
fb40c209 222 format = FORMAT_NATURAL;
bf896cb0 223 else if (strncmp (formspec, "binary", len) == 0)
fb40c209 224 format = FORMAT_BINARY;
bf896cb0 225 else if (strncmp (formspec, "decimal", len) == 0)
fb40c209 226 format = FORMAT_DECIMAL;
bf896cb0 227 else if (strncmp (formspec, "hexadecimal", len) == 0)
fb40c209 228 format = FORMAT_HEXADECIMAL;
bf896cb0 229 else if (strncmp (formspec, "octal", len) == 0)
fb40c209
AC
230 format = FORMAT_OCTAL;
231 else
8a3fe4f8 232 error (_("mi_cmd_var_set_format: Unknown display format: must be: \"natural\", \"binary\", \"decimal\", \"hexadecimal\", or \"octal\""));
fb40c209
AC
233
234 /* Set the format of VAR to given format */
235 varobj_set_display_format (var, format);
236
237 /* Report the new current format */
238 ui_out_field_string (uiout, "format", varobj_format_string[(int) format]);
00ee6348
NR
239
240 /* Report the value in the new format */
241 ui_out_field_string (uiout, "value", varobj_get_value (var));
fb40c209
AC
242 return MI_CMD_DONE;
243}
244
25d5ea92
VP
245enum mi_cmd_result
246mi_cmd_var_set_frozen (char *command, char **argv, int argc)
247{
248 struct varobj *var;
249 int frozen;
250
251 if (argc != 2)
252 error (_("-var-set-format: Usage: NAME FROZEN_FLAG."));
253
254 var = varobj_get_handle (argv[0]);
255 if (var == NULL)
256 error (_("Variable object not found"));
257
258 if (strcmp (argv[1], "0") == 0)
259 frozen = 0;
260 else if (strcmp (argv[1], "1") == 0)
261 frozen = 1;
262 else
263 error (_("Invalid flag value"));
264
265 varobj_set_frozen (var, frozen);
266
267 /* We don't automatically return the new value, or what varobjs got new
268 values during unfreezing. If this information is required, client
269 should call -var-update explicitly. */
270 return MI_CMD_DONE;
271}
272
273
fb40c209
AC
274enum mi_cmd_result
275mi_cmd_var_show_format (char *command, char **argv, int argc)
276{
277 enum varobj_display_formats format;
278 struct varobj *var;
279
280 if (argc != 1)
8a3fe4f8 281 error (_("mi_cmd_var_show_format: Usage: NAME."));
fb40c209
AC
282
283 /* Get varobj handle, if a valid var obj name was specified */
284 var = varobj_get_handle (argv[0]);
285 if (var == NULL)
8a3fe4f8 286 error (_("mi_cmd_var_show_format: Variable object not found"));
fb40c209
AC
287
288 format = varobj_get_display_format (var);
289
290 /* Report the current format */
291 ui_out_field_string (uiout, "format", varobj_format_string[(int) format]);
292 return MI_CMD_DONE;
293}
294
295enum mi_cmd_result
296mi_cmd_var_info_num_children (char *command, char **argv, int argc)
297{
298 struct varobj *var;
299
300 if (argc != 1)
8a3fe4f8 301 error (_("mi_cmd_var_info_num_children: Usage: NAME."));
fb40c209
AC
302
303 /* Get varobj handle, if a valid var obj name was specified */
304 var = varobj_get_handle (argv[0]);
305 if (var == NULL)
8a3fe4f8 306 error (_("mi_cmd_var_info_num_children: Variable object not found"));
fb40c209
AC
307
308 ui_out_field_int (uiout, "numchild", varobj_get_num_children (var));
309 return MI_CMD_DONE;
310}
311
1ecb4ee0
DJ
312/* Parse a string argument into a print_values value. */
313
314static enum print_values
315mi_parse_values_option (const char *arg)
316{
317 if (strcmp (arg, "0") == 0
318 || strcmp (arg, mi_no_values) == 0)
319 return PRINT_NO_VALUES;
320 else if (strcmp (arg, "1") == 0
321 || strcmp (arg, mi_all_values) == 0)
322 return PRINT_ALL_VALUES;
323 else if (strcmp (arg, "2") == 0
324 || strcmp (arg, mi_simple_values) == 0)
325 return PRINT_SIMPLE_VALUES;
326 else
327 error (_("Unknown value for PRINT_VALUES\n\
328Must be: 0 or \"%s\", 1 or \"%s\", 2 or \"%s\""),
329 mi_no_values, mi_simple_values, mi_all_values);
330}
331
332/* Return 1 if given the argument PRINT_VALUES we should display
333 a value of type TYPE. */
334
335static int
336mi_print_value_p (struct type *type, enum print_values print_values)
337{
1ecb4ee0
DJ
338
339 if (print_values == PRINT_NO_VALUES)
340 return 0;
341
342 if (print_values == PRINT_ALL_VALUES)
343 return 1;
344
9265acad
NR
345 if (type == NULL)
346 return 1;
347 else
348 {
349 type = check_typedef (type);
1ecb4ee0 350
9265acad
NR
351 /* For PRINT_SIMPLE_VALUES, only print the value if it has a type
352 and that type is not a compound type. */
353 return (TYPE_CODE (type) != TYPE_CODE_ARRAY
354 && TYPE_CODE (type) != TYPE_CODE_STRUCT
355 && TYPE_CODE (type) != TYPE_CODE_UNION);
356 }
1ecb4ee0
DJ
357}
358
fb40c209
AC
359enum mi_cmd_result
360mi_cmd_var_list_children (char *command, char **argv, int argc)
361{
d56d46f5
VP
362 struct varobj *var;
363 VEC(varobj_p) *children;
364 struct varobj *child;
6ad4a2cf 365 struct cleanup *cleanup_children;
fb40c209 366 int numchild;
c9e1f0fc 367 enum print_values print_values;
d56d46f5 368 int ix;
fb40c209 369
c9e1f0fc 370 if (argc != 1 && argc != 2)
8a3fe4f8 371 error (_("mi_cmd_var_list_children: Usage: [PRINT_VALUES] NAME"));
fb40c209
AC
372
373 /* Get varobj handle, if a valid var obj name was specified */
1ecb4ee0
DJ
374 if (argc == 1)
375 var = varobj_get_handle (argv[0]);
376 else
377 var = varobj_get_handle (argv[1]);
fb40c209 378 if (var == NULL)
8a3fe4f8 379 error (_("Variable object not found"));
fb40c209 380
d56d46f5
VP
381 children = varobj_list_children (var);
382 ui_out_field_int (uiout, "numchild", VEC_length (varobj_p, children));
c9e1f0fc 383 if (argc == 2)
1ecb4ee0
DJ
384 print_values = mi_parse_values_option (argv[0]);
385 else
386 print_values = PRINT_NO_VALUES;
fb40c209 387
d56d46f5
VP
388 if (VEC_length (varobj_p, children) == 0)
389 return MI_CMD_DONE;
fb40c209 390
e7494ffb
AC
391 if (mi_version (uiout) == 1)
392 cleanup_children = make_cleanup_ui_out_tuple_begin_end (uiout, "children");
393 else
394 cleanup_children = make_cleanup_ui_out_list_begin_end (uiout, "children");
d56d46f5 395 for (ix = 0; VEC_iterate (varobj_p, children, ix, child); ++ix)
fb40c209 396 {
6ad4a2cf
JJ
397 struct cleanup *cleanup_child;
398 cleanup_child = make_cleanup_ui_out_tuple_begin_end (uiout, "child");
d56d46f5 399 print_varobj (child, print_values, 1 /* print expression */);
a217f3f5 400 do_cleanups (cleanup_child);
fb40c209 401 }
6ad4a2cf 402 do_cleanups (cleanup_children);
fb40c209
AC
403 return MI_CMD_DONE;
404}
405
406enum mi_cmd_result
407mi_cmd_var_info_type (char *command, char **argv, int argc)
408{
409 struct varobj *var;
410
411 if (argc != 1)
8a3fe4f8 412 error (_("mi_cmd_var_info_type: Usage: NAME."));
fb40c209
AC
413
414 /* Get varobj handle, if a valid var obj name was specified */
415 var = varobj_get_handle (argv[0]);
416 if (var == NULL)
8a3fe4f8 417 error (_("mi_cmd_var_info_type: Variable object not found"));
fb40c209
AC
418
419 ui_out_field_string (uiout, "type", varobj_get_type (var));
420 return MI_CMD_DONE;
421}
422
02142340
VP
423enum mi_cmd_result
424mi_cmd_var_info_path_expression (char *command, char **argv, int argc)
425{
426 struct varobj *var;
427 char *path_expr;
428
429 if (argc != 1)
430 error (_("Usage: NAME."));
431
432 /* Get varobj handle, if a valid var obj name was specified. */
433 var = varobj_get_handle (argv[0]);
434 if (var == NULL)
435 error (_("Variable object not found"));
436
437 path_expr = varobj_get_path_expr (var);
438
439 ui_out_field_string (uiout, "path_expr", path_expr);
440
441 return MI_CMD_DONE;
442}
443
fb40c209
AC
444enum mi_cmd_result
445mi_cmd_var_info_expression (char *command, char **argv, int argc)
446{
447 enum varobj_languages lang;
448 struct varobj *var;
449
450 if (argc != 1)
8a3fe4f8 451 error (_("mi_cmd_var_info_expression: Usage: NAME."));
fb40c209
AC
452
453 /* Get varobj handle, if a valid var obj name was specified */
454 var = varobj_get_handle (argv[0]);
455 if (var == NULL)
8a3fe4f8 456 error (_("mi_cmd_var_info_expression: Variable object not found"));
fb40c209
AC
457
458 lang = varobj_get_language (var);
459
460 ui_out_field_string (uiout, "lang", varobj_language_string[(int) lang]);
461 ui_out_field_string (uiout, "exp", varobj_get_expression (var));
462 return MI_CMD_DONE;
463}
464
465enum mi_cmd_result
466mi_cmd_var_show_attributes (char *command, char **argv, int argc)
467{
468 int attr;
469 char *attstr;
470 struct varobj *var;
471
472 if (argc != 1)
8a3fe4f8 473 error (_("mi_cmd_var_show_attributes: Usage: NAME."));
fb40c209
AC
474
475 /* Get varobj handle, if a valid var obj name was specified */
476 var = varobj_get_handle (argv[0]);
477 if (var == NULL)
8a3fe4f8 478 error (_("mi_cmd_var_show_attributes: Variable object not found"));
fb40c209
AC
479
480 attr = varobj_get_attributes (var);
481 /* FIXME: define masks for attributes */
482 if (attr & 0x00000001)
483 attstr = "editable";
484 else
485 attstr = "noneditable";
486
487 ui_out_field_string (uiout, "attr", attstr);
488 return MI_CMD_DONE;
489}
490
491enum mi_cmd_result
492mi_cmd_var_evaluate_expression (char *command, char **argv, int argc)
493{
494 struct varobj *var;
495
496 if (argc != 1)
8a3fe4f8 497 error (_("mi_cmd_var_evaluate_expression: Usage: NAME."));
fb40c209
AC
498
499 /* Get varobj handle, if a valid var obj name was specified */
500 var = varobj_get_handle (argv[0]);
501 if (var == NULL)
8a3fe4f8 502 error (_("mi_cmd_var_evaluate_expression: Variable object not found"));
fb40c209
AC
503
504 ui_out_field_string (uiout, "value", varobj_get_value (var));
505 return MI_CMD_DONE;
506}
507
508enum mi_cmd_result
509mi_cmd_var_assign (char *command, char **argv, int argc)
510{
511 struct varobj *var;
512 char *expression;
513
514 if (argc != 2)
8a3fe4f8 515 error (_("mi_cmd_var_assign: Usage: NAME EXPRESSION."));
fb40c209
AC
516
517 /* Get varobj handle, if a valid var obj name was specified */
518 var = varobj_get_handle (argv[0]);
519 if (var == NULL)
8a3fe4f8 520 error (_("mi_cmd_var_assign: Variable object not found"));
fb40c209 521
d2562500 522 if (!varobj_editable_p (var))
8a3fe4f8 523 error (_("mi_cmd_var_assign: Variable object is not editable"));
fb40c209
AC
524
525 expression = xstrdup (argv[1]);
526
527 if (!varobj_set_value (var, expression))
98a29c7e 528 error (_("mi_cmd_var_assign: Could not assign expression to variable object"));
fb40c209
AC
529
530 ui_out_field_string (uiout, "value", varobj_get_value (var));
531 return MI_CMD_DONE;
532}
533
534enum mi_cmd_result
535mi_cmd_var_update (char *command, char **argv, int argc)
536{
537 struct varobj *var;
538 struct varobj **rootlist;
539 struct varobj **cr;
3a387118 540 struct cleanup *cleanup;
fb40c209
AC
541 char *name;
542 int nv;
1ecb4ee0 543 enum print_values print_values;
fb40c209 544
1ecb4ee0
DJ
545 if (argc != 1 && argc != 2)
546 error (_("mi_cmd_var_update: Usage: [PRINT_VALUES] NAME."));
547
548 if (argc == 1)
549 name = argv[0];
550 else
551 name = (argv[1]);
fb40c209 552
1ecb4ee0
DJ
553 if (argc == 2)
554 print_values = mi_parse_values_option (argv[0]);
555 else
556 print_values = PRINT_NO_VALUES;
fb40c209
AC
557
558 /* Check if the parameter is a "*" which means that we want
559 to update all variables */
560
561 if ((*name == '*') && (*(name + 1) == '\0'))
562 {
563 nv = varobj_list (&rootlist);
db9a518b 564 cleanup = make_cleanup (xfree, rootlist);
3a387118 565 if (mi_version (uiout) <= 1)
db9a518b 566 make_cleanup_ui_out_tuple_begin_end (uiout, "changelist");
3a387118 567 else
db9a518b 568 make_cleanup_ui_out_list_begin_end (uiout, "changelist");
fb40c209
AC
569 if (nv <= 0)
570 {
3a387118 571 do_cleanups (cleanup);
fb40c209
AC
572 return MI_CMD_DONE;
573 }
574 cr = rootlist;
575 while (*cr != NULL)
576 {
25d5ea92 577 varobj_update_one (*cr, print_values, 0 /* implicit */);
fb40c209
AC
578 cr++;
579 }
3a387118 580 do_cleanups (cleanup);
fb40c209
AC
581 }
582 else
583 {
584 /* Get varobj handle, if a valid var obj name was specified */
585 var = varobj_get_handle (name);
586 if (var == NULL)
8a3fe4f8 587 error (_("mi_cmd_var_update: Variable object not found"));
fb40c209 588
3a387118
JJ
589 if (mi_version (uiout) <= 1)
590 cleanup = make_cleanup_ui_out_tuple_begin_end (uiout, "changelist");
591 else
592 cleanup = make_cleanup_ui_out_list_begin_end (uiout, "changelist");
25d5ea92 593 varobj_update_one (var, print_values, 1 /* explicit */);
3a387118 594 do_cleanups (cleanup);
fb40c209 595 }
73a93a32 596 return MI_CMD_DONE;
fb40c209
AC
597}
598
8756216b 599/* Helper for mi_cmd_var_update(). */
fb40c209 600
8756216b 601static void
25d5ea92
VP
602varobj_update_one (struct varobj *var, enum print_values print_values,
603 int explicit)
fb40c209
AC
604{
605 struct varobj **changelist;
606 struct varobj **cc;
3a387118 607 struct cleanup *cleanup = NULL;
fb40c209
AC
608 int nc;
609
25d5ea92 610 nc = varobj_update (&var, &changelist, explicit);
fb40c209 611
8756216b
DP
612 /* nc >= 0 represents the number of changes reported into changelist.
613 nc < 0 means that an error occured or the the variable has
614 changed type (TYPE_CHANGED). */
73a93a32
JI
615
616 if (nc == 0)
8756216b
DP
617 return;
618 else if (nc < 0)
fb40c209 619 {
3a387118
JJ
620 if (mi_version (uiout) > 1)
621 cleanup = make_cleanup_ui_out_tuple_begin_end (uiout, NULL);
73a93a32 622 ui_out_field_string (uiout, "name", varobj_get_objname(var));
8756216b
DP
623
624 switch (nc)
625 {
626 case NOT_IN_SCOPE:
8756216b
DP
627 ui_out_field_string (uiout, "in_scope", "false");
628 break;
629 case INVALID:
630 ui_out_field_string (uiout, "in_scope", "invalid");
631 break;
632 case TYPE_CHANGED:
633 ui_out_field_string (uiout, "in_scope", "true");
634 ui_out_field_string (uiout, "new_type", varobj_get_type(var));
635 ui_out_field_int (uiout, "new_num_children",
636 varobj_get_num_children(var));
637 break;
638 }
3a387118
JJ
639 if (mi_version (uiout) > 1)
640 do_cleanups (cleanup);
73a93a32
JI
641 }
642 else
643 {
73a93a32
JI
644 cc = changelist;
645 while (*cc != NULL)
646 {
3a387118
JJ
647 if (mi_version (uiout) > 1)
648 cleanup = make_cleanup_ui_out_tuple_begin_end (uiout, NULL);
73a93a32 649 ui_out_field_string (uiout, "name", varobj_get_objname (*cc));
1ecb4ee0
DJ
650 if (mi_print_value_p (varobj_get_gdb_type (*cc), print_values))
651 ui_out_field_string (uiout, "value", varobj_get_value (*cc));
73a93a32
JI
652 ui_out_field_string (uiout, "in_scope", "true");
653 ui_out_field_string (uiout, "type_changed", "false");
3a387118
JJ
654 if (mi_version (uiout) > 1)
655 do_cleanups (cleanup);
73a93a32
JI
656 cc++;
657 }
b8c9b27d 658 xfree (changelist);
fb40c209 659 }
fb40c209 660}
This page took 0.946309 seconds and 4 git commands to generate.