mirror of
https://github.com/bminor/binutils-gdb.git
synced 2025-12-12 10:32:50 +00:00
Use bitpos and type to lookup a gdb.Field object when its name is 'None'.
PR python/15464
PR python/16113
* valops.c (value_struct_elt_bitpos): New function
* py-type.c (convert_field): Set 'name' attribute of a gdb.Field
object to 'None' if the field name is an empty string ("").
* python/py-value.c (valpy_getitem): Use 'bitpos' and 'type'
attribute to look for a field when 'name' is 'None'.
(get_field_type): New function
testsuite/
* gdb.python/py-type.c: Enhance test case.
* gdb.python/py-value-cc.cc: Likewise
* gdb.python/py-type.exp: Add new tests.
* gdb.python/py-value-cc.exp: Likewise
This commit is contained in:
@@ -206,15 +206,22 @@ convert_field (struct type *type, int field)
|
||||
Py_DECREF (arg);
|
||||
}
|
||||
|
||||
arg = NULL;
|
||||
if (TYPE_FIELD_NAME (type, field))
|
||||
arg = PyString_FromString (TYPE_FIELD_NAME (type, field));
|
||||
else
|
||||
{
|
||||
const char *field_name = TYPE_FIELD_NAME (type, field);
|
||||
if (field_name[0] != '\0')
|
||||
{
|
||||
arg = PyString_FromString (TYPE_FIELD_NAME (type, field));
|
||||
if (arg == NULL)
|
||||
goto fail;
|
||||
}
|
||||
}
|
||||
if (arg == NULL)
|
||||
{
|
||||
arg = Py_None;
|
||||
Py_INCREF (arg);
|
||||
}
|
||||
if (!arg)
|
||||
goto fail;
|
||||
if (PyObject_SetAttrString (result, "name", arg) < 0)
|
||||
goto failarg;
|
||||
Py_DECREF (arg);
|
||||
|
||||
Reference in New Issue
Block a user