This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Patch] PR python/15464 and python/16113


I was not aware of "unnamed fields" until I saw Tom's update to 15464
today. Playing with them and my previous patch for 16113, I realized
that my patch does not handle unnamed fields thoroughly. It does
however work for the example posted with the 15464 report.

[I probably would have looked up unnamed fields when working on my
earlier patch, but the documentation for gdb.Field.name only says
this: "The name of the field, or None for anonymous fields." I know
anonymous fields exist in Go, and they show up with a name behind the
scenes. Hence, I considered the documentation to be incorrect. I had
made a note to ask about this or fix this, but missed getting back to
it.]

Unnamed fields have a name equal to an empty string (""). Hence, if
there were only one unnamed field, my previous patch works as it looks
up a field by name. It fails when there are more than one unnamed
fields. The attached patch fixes this by looking up unnamed fields
using 'bitpos' instead of the field name.

2013-12-27  Siva Chandra Reddy  <sivachandra@google.com>

        PR python/15464
        PR python/16133
        * valops.c (value_struct_elt_bitpos): New function
        * python/py-value.c (valpy_getitem): Use 'bitpos' attribute to
        look for a field when 'name' is 'None' or empty.

        testsuite/
        * gdb.python/py-value-cc.cc: Enhance test case.
        * gdb.python/py-value-cc.exp: Add new tests.

Attachment: value_field_subscript_patch_v1.txt
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]