Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Siva Chandra <sivachandra@google.com>
To: gdb-patches <gdb-patches@sourceware.org>
Cc: Eli Zaretskii <eliz@gnu.org>
Subject: Re: [RFC/Patch v3] PR 16113: Allow gdb.Field objects as subscripts on gdb.Value objects
Date: Thu, 12 Dec 2013 19:36:00 -0000	[thread overview]
Message-ID: <CAGyQ6gx4wHmEPqEE5TNPFWYVaDtA5qCpaDB04dwkjmV0rNGScg@mail.gmail.com> (raw)
In-Reply-To: <CAGyQ6gyj2rJqpZmNwSpfNiCovAEf6_P_gZvhs8iyf1-DOEOGbQ@mail.gmail.com>

This requires a doc review as there is small addition to NEWS and
gdb.texinfo after Eli approved the changes last.

On Wed, Dec 11, 2013 at 3:23 PM, Siva Chandra <sivachandra@google.com> wrote:
> The attached patch addresses all of Tom's comments except two for
> which I have responses below:
>
> Tom> What about TYPE_CODE_UNION and TYPE_CODE_RANGE?
> Tom> Offhand I don't recall if other types present "fields".
> Tom> Maybe TYPE_CODE_FUNC?  TYPE_CODE_COMPLEX?
>
> I missed TYPE_CODE_UNION so I have added it in the attached patch. The
> other types do not support the "fields" method. [But, is it a mistake
> that we do not support fields for other methods? The documentation
> does talk about ranges, functions and methods. At this point, I am
> tempted to ask as to why we should "overload" the method "fields" to
> return function/method args? Can we bring in a class hierarchy of
> types where in gdb.Type exists as a base class, and gdb.TypeStruct,
> gdb.TypeFunction etc. are derived from it. That way, we can add
> relevant methods to the respective classes. For example,
> gdb.TypeFunction will have "args" as a method and not "fields". I
> understand the notion of fields is overloaded internally, but we could
> make the Python API clearer.]
>
> Siva> +  arg = type_to_type_object (type);
> Siva> +  if (arg == NULL)
> Siva> +    goto fail;
>
> Tom> I think if TYPE is not a gdb.Type then this will return -1 without
> Tom> setting the Python exception.
>
> The above comment is for the change in py-type.c. The variable TYPE in
> question here is "struct type" and not gdb.Type. I think
> type_to_type_object would return NULL only if PyObject_New called in
> it fails. Is an exception not set by PyObject_New on failure?
>
> 2013-12-11  Siva Chandra Reddy  <sivachandra@google.com>
>
>         PR 16113: Allow gdb.Field objects with the subscript operator on
>         gdb.Value objects of struct/class values.
>         * NEWS (Python Scripting): Add entry for the new feature and the
>         new attribute of gdb.Field objects.
>         * python/py-type.c (gdbpy_is_field): New function
>         (convert_field): Add 'parent_type' attribute to gdb.Field
>         objects.
>         * python/py-value.c (valpy_getitem): Allow subscript value to be
>         a gdb.Field object.
>         (value_has_field): New function
>         (get_field_flag): New function
>         * python/python-internal.h (gdbpy_is_field): Add declaration.
>
>         testsuite/
>         * gdb.python/py-value-cc.cc: Improve test case.
>         * gdb.python/py-value-cc.exp: Add new tests.
>
>         doc/
>         * gdb.texinfo (Values From Inferior): Add a note about using
>         gdb.Field objects as subscripts on gdb.Value objects.
>         (Types In Python): Add description about the new attribute of
>         gdb.Field objects.


  parent reply	other threads:[~2013-12-12 19:36 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-11 23:23 Siva Chandra
2013-12-12  2:36 ` Tom Tromey
2013-12-12 19:36 ` Siva Chandra [this message]
2013-12-12 20:11   ` Eli Zaretskii
2013-12-12 20:12 ` Eli Zaretskii

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=CAGyQ6gx4wHmEPqEE5TNPFWYVaDtA5qCpaDB04dwkjmV0rNGScg@mail.gmail.com \
    --to=sivachandra@google.com \
    --cc=eliz@gnu.org \
    --cc=gdb-patches@sourceware.org \
    /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