gdb/varobj-iter.h - gdb

Data types defined

Macros defined

Source code

  1. /* Iterator of varobj.
  2.    Copyright (C) 2013-2015 Free Software Foundation, Inc.

  3.    This program is free software; you can redistribute it and/or modify
  4.    it under the terms of the GNU General Public License as published by
  5.    the Free Software Foundation; either version 3 of the License, or
  6.    (at your option) any later version.

  7.    This program is distributed in the hope that it will be useful,
  8.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  9.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  10.    GNU General Public License for more details.

  11.    You should have received a copy of the GNU General Public License
  12.    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */

  13. /* A node or item of varobj, composed of the name and the value.  */

  14. typedef struct varobj_item
  15. {
  16.   /* Name of this item.  */
  17.   char *name;

  18.   /* Value of this item.  */
  19.   struct value *value;
  20. } varobj_item;

  21. struct varobj_iter_ops;

  22. /* A dynamic varobj iterator "class".  */

  23. struct varobj_iter
  24. {
  25.   /* The 'vtable'.  */
  26.   const struct varobj_iter_ops *ops;

  27.   /* The varobj this iterator is listing children for.  */
  28.   struct varobj *var;

  29.   /* The next raw index we will try to check is available.  If it is
  30.      equal to number_of_children, then we've already iterated the
  31.      whole set.  */
  32.   int next_raw_index;
  33. };

  34. /* The vtable of the varobj iterator class.  */

  35. struct varobj_iter_ops
  36. {
  37.   /* Destructor.  Releases everything from SELF (but not SELF
  38.      itself).  */
  39.   void (*dtor) (struct varobj_iter *self);

  40.   /* Returns the next object or NULL if it has reached the end.  */
  41.   varobj_item *(*next) (struct varobj_iter *self);
  42. };

  43. /* Returns the next varobj or NULL if it has reached the end.  */

  44. #define varobj_iter_next(ITER)        (ITER)->ops->next (ITER)

  45. /* Delete a varobj_iter object.  */

  46. #define varobj_iter_delete(ITER)               \
  47.   do                                               \
  48.     {                                               \
  49.       if ((ITER) != NULL)                       \
  50.         {                                       \
  51.           (ITER)->ops->dtor (ITER);               \
  52.           xfree (ITER);                       \
  53.         }                                       \
  54.     } while (0)