This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH v4] gdb/python: add missing handling for anonymous members of struct and union
- From: Phil Muldoon <pmuldoon at redhat dot com>
- To: Li Yu <raise dot sail at gmail dot com>
- Cc: gdb-patches at sourceware dot org, Paul Koning <paulkoning at comcast dot net>, Tom Tromey <tromey at redhat dot com>
- Date: Tue, 18 Oct 2011 14:57:45 +0100
- Subject: Re: [PATCH v4] gdb/python: add missing handling for anonymous members of struct and union
- References: <CA+WLrf-MM2WPr6r8DLKcZP5-A6qmZst8Sxzy4u5OvrxFET5sEQ@mail.gmail.com>
- Reply-to: pmuldoon at redhat dot com
Li Yu <raise.sail@gmail.com> writes:
> gdb.Type.fields() missed handling for anonymous members.
>
> This patch fix it, below are details:
Sorry I missed this patch. I have some questions.
Given this functionality, do you have any use-cases in mind for it? Do
we really want to include anonymous members in field () output? I ask
because I cannot decide if the additional anonymous field information
constitutes an API break. If so we may have to reconstitute this
functionality from fields() so that it takes a keyword to turn this
behavior on and off.
Also, this patch requires a GDB testcase, and probably a documentation
update. Also, a ChangeLog.
> /* A type iterator object. */
> -typedef struct {
> +typedef struct iterator_object
> +{
> PyObject_HEAD
> + /* The iterators for support fields of anonymous field */
> + struct iterator_object *child;
Comments have to be complete sentences, including punctuation. So add a
period at the end of that comment.
> + if (iter_obj->child)
> + {
> + result = typy_iterator_iternext((PyObject*)iter_obj->child);
Spacing around the ( and ) is incorrect.
> + if (result)
> + return result;
> + Py_CLEAR(iter_obj->child);
> + }
> +
> + type = iter_obj->source->type;
> +
> +restart:
> + if (iter_obj->field >= TYPE_NFIELDS (type))
> + return NULL;
> +
> + name = TYPE_FIELD_NAME (type, iter_obj->field);
> + if (!name || name[0]) /* array element or regular named member */
> {
Comments need to be complete and punctuated.
> result = make_fielditem (type, iter_obj->field, iter_obj->kind);
> if (result != NULL)
> @@ -1269,7 +1289,14 @@ typy_iterator_iternext (PyObject *self)
> return result;
> }
>
> - return NULL;
> + type = TYPE_FIELD_TYPE(type, iter_obj->field++);
> + child_pytype = type_to_type_object(type);
Bracket spacing.
> + if (!child_pytype)
> + return NULL;
> + child_iter_obj =
> (typy_iterator_object*)typy_make_iter(child_pytype, iter_obj->kind);
Bracket spacing.
> + iter_obj->child = child_iter_obj;
> + iter_obj = child_iter_obj;
> + goto restart;
> }
>
> static void
Cheers,
Phil