This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [RFC/Patch v3] PR 16113: Allow gdb.Field objects as subscripts on gdb.Value objects
- From: Tom Tromey <tromey at redhat dot com>
- To: Siva Chandra <sivachandra at google dot com>
- Cc: gdb-patches <gdb-patches at sourceware dot org>
- Date: Wed, 11 Dec 2013 19:36:18 -0700
- Subject: Re: [RFC/Patch v3] PR 16113: Allow gdb.Field objects as subscripts on gdb.Value objects
- Authentication-results: sourceware.org; auth=none
- References: <CAGyQ6gyj2rJqpZmNwSpfNiCovAEf6_P_gZvhs8iyf1-DOEOGbQ at mail dot gmail dot com>
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?
Siva> I missed TYPE_CODE_UNION so I have added it in the attached patch. The
Siva> other types do not support the "fields" method. [But, is it a mistake
Siva> that we do not support fields for other methods? The documentation
Siva> does talk about ranges, functions and methods. At this point, I am
Siva> tempted to ask as to why we should "overload" the method "fields" to
Siva> return function/method args? Can we bring in a class hierarchy of
Siva> types where in gdb.Type exists as a base class, and gdb.TypeStruct,
Siva> gdb.TypeFunction etc. are derived from it. That way, we can add
Siva> relevant methods to the respective classes. For example,
Siva> gdb.TypeFunction will have "args" as a method and not "fields". I
Siva> understand the notion of fields is overloaded internally, but we could
Siva> make the Python API clearer.]
Yeah, I agree, that would be cleaner.
Occasionally it's easy to become blind to the issue after working on gdb
for a while.
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.
Siva> The above comment is for the change in py-type.c. The variable TYPE in
Siva> question here is "struct type" and not gdb.Type. I think
Siva> type_to_type_object would return NULL only if PyObject_New called in
Siva> it fails. Is an exception not set by PyObject_New on failure?
This one is my mistake. I misread that as type_object_to_type.
Siva> 2013-12-11 Siva Chandra Reddy <sivachandra@google.com>
Siva> PR 16113: Allow gdb.Field objects with the subscript operator on
I don't remember if the regexp catches this form, best to write
"PR python/16113" instead.
The patch ok with this change, thanks!
Tom