From: Tom Tromey <tromey@redhat.com>
To: Li Yu <raise.sail@gmail.com>
Cc: gdb-patches@sourceware.org, Paul Koning <paulkoning@comcast.net>
Subject: Re: [PATCH v2] gdb/python: add missing handling for anonymous members of struct and union
Date: Tue, 04 Oct 2011 16:37:00 -0000 [thread overview]
Message-ID: <m38vp0pvc9.fsf@fleche.redhat.com> (raw)
In-Reply-To: <4E8595F6.7080004@gmail.com> (Li Yu's message of "Fri, 30 Sep 2011 18:12:06 +0800")
>>>>> "Li" == Li Yu <raise.sail@gmail.com> writes:
Li> gdb.Type.fields() missed handling for anonymous members.
Li> This patch fix it, below are details:
Thanks.
Do you have a copyright assignment in place? If not, you will need
one. Contact me off-list and I will get you started.
Li> Assume that we have a c source as below:
This patch needs a test case; so I suggest converting this into the
right form for the test suite.
Li> +struct __typy_iterator_object
Don't use leading underscores for the name here.
Li> + typy_iterator_object *iter_obj = (typy_iterator_object *) self, *child_iter_obj;
This line is too long. Just make a second declaration for child_iter_obj.
Li> + char *name;
Probably could be const.
Li> + while (iter_obj->child) /* deepest anonymous member first */
Li> + {
The braces are in the wrong place for the GNU style.
They should be in 2 more spaces; see the GNU coding standards for details.
This occurs in a couple of places.
Li> +restart:
Li> + while (iter_obj->field >= TYPE_NFIELDS (type))
Li> + {
Li> + iter_obj = iter_obj->parent;
Li> + if (!iter_obj)
Li> + return NULL;
This seems strange. This returns NULL without setting a Python
exception.
Also the reference counting seems odd. I guess I don't understand why
the typy_iterator_object has references to other iterator objects,
instead of plain gdb state. References to other objects means that you
at least need to decref them when the iterator object is destroyed.
Li> + Py_DECREF(iter_obj->child);
Missing space before the paren. This occurs in a few spots.
Li> + name = TYPE_FIELD_NAME (type, iter_obj->field);
Li> + if (!name)
Li> + goto abort_clean;
Why is this here? I think you would have to check to be sure that there
is never a NULL field name created by gdb; in which case this should be
some kind of internal error.
Li> + if (name[0]) /* mostly cases */
I don't understand this comment. I suggest just deleting it.
Li> + /* handing for anonymous members here */
Comments in gdb should be full sentences: start with an upper-case
letter, end with a period followed by two spaces. See GNU standards.
Li> + goto abort_clean;;
Double semicolon.
Li> + child_iter_obj = (typy_iterator_object*)typy_make_iter (child_pytype, iter_obj->kind);
Line too long, should be wrapped. Also a missing space after the first ")".
I don't understand why the iterator iterates into sub-objects. Why not
just have a flat iterator? That is, return a field with no name whose
type is some structure, and then let the caller iterate over that type
if need be.
Tom
next prev parent reply other threads:[~2011-10-04 16:37 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-09-30 11:04 Li Yu
2011-09-30 16:15 ` Paul Koning
2011-10-01 14:01 ` Li Yu
2011-10-01 18:54 ` Paul Koning
2011-10-04 16:37 ` Tom Tromey [this message]
2011-10-04 18:05 ` Paul Koning
2011-10-04 20:24 ` Tom Tromey
2011-10-04 20:41 ` Paul Koning
2011-10-19 20:52 ` Tom Tromey
2011-10-19 20:59 ` Paul Koning
2011-10-20 18:49 ` Tom Tromey
2011-10-25 18:34 ` [RFA] Python: iterator for deep traversal of gdb.Type struct/union fields Paul Koning
2011-10-25 19:03 ` Paul Koning
2011-10-25 20:16 ` Eli Zaretskii
2011-10-26 17:14 ` Paul Koning
2011-10-27 13:01 ` Doug Evans
2011-10-27 14:52 ` Paul_Koning
2011-10-27 19:57 ` Tom Tromey
[not found] ` <09787EF419216C41A903FD14EE5506DD030CF168FB@AUSX7MCPC103.AMER.DELL.COM>
2011-10-27 21:56 ` Paul Koning
2011-10-27 22:14 ` Eli Zaretskii
2011-10-28 14:55 ` Paul Koning
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=m38vp0pvc9.fsf@fleche.redhat.com \
--to=tromey@redhat.com \
--cc=gdb-patches@sourceware.org \
--cc=paulkoning@comcast.net \
--cc=raise.sail@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox