OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gdb-7.1/] [gdb/] [mi/] [mi-cmd-var.c] - Blame information for rev 299

Go to most recent revision | Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.