Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1787)

Unified Diff: gdb/python/py-type.c

Issue 11969036: Merge GDB 7.5.1 (Closed) Base URL: http://git.chromium.org/native_client/nacl-gdb.git@master
Patch Set: Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « gdb/python/py-symtab.c ('k') | gdb/python/py-utils.c » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gdb/python/py-type.c
diff --git a/gdb/python/py-type.c b/gdb/python/py-type.c
index dadb0375a93ad1fb010b1f5f23d7fd83a8951d3e..98030a6fecc6e6ff5b4442ad81b3f1b965e0002c 100644
--- a/gdb/python/py-type.c
+++ b/gdb/python/py-type.c
@@ -167,11 +167,24 @@ convert_field (struct type *type, int field)
if (!field_is_static (&TYPE_FIELD (type, field)))
{
- arg = PyLong_FromLong (TYPE_FIELD_BITPOS (type, field));
+ const char *attrstring;
+
+ if (TYPE_CODE (type) == TYPE_CODE_ENUM)
+ {
+ arg = gdb_py_long_from_longest (TYPE_FIELD_ENUMVAL (type, field));
+ attrstring = "enumval";
+ }
+ else
+ {
+ arg = PyLong_FromLong (TYPE_FIELD_BITPOS (type, field));
+ attrstring = "bitpos";
+ }
+
if (!arg)
goto fail;
- if (PyObject_SetAttrString (result, "bitpos", arg) < 0)
+ /* At least python-2.4 had the second parameter non-const. */
+ if (PyObject_SetAttrString (result, (char *) attrstring, arg) < 0)
goto failarg;
}
@@ -1018,6 +1031,10 @@ check_types_equal (struct type *type1, struct type *type2,
if (FIELD_BITPOS (*field1) != FIELD_BITPOS (*field2))
return Py_NE;
break;
+ case FIELD_LOC_KIND_ENUMVAL:
+ if (FIELD_ENUMVAL (*field1) != FIELD_ENUMVAL (*field2))
+ return Py_NE;
+ break;
case FIELD_LOC_KIND_PHYSADDR:
if (FIELD_STATIC_PHYSADDR (*field1)
!= FIELD_STATIC_PHYSADDR (*field2))
@@ -1055,7 +1072,6 @@ check_types_equal (struct type *type1, struct type *type2,
if (TYPE_TARGET_TYPE (type1) != NULL)
{
struct type_equality_entry entry;
- int added;
if (TYPE_TARGET_TYPE (type2) == NULL)
return Py_NE;
@@ -1255,7 +1271,6 @@ typy_getitem (PyObject *self, PyObject *key)
struct type *type = ((type_object *) self)->type;
char *field;
int i;
- volatile struct gdb_exception except;
field = python_string_to_host_string (key);
if (field == NULL)
@@ -1271,7 +1286,7 @@ typy_getitem (PyObject *self, PyObject *key)
for (i = 0; i < TYPE_NFIELDS (type); i++)
{
- char *t_field_name = TYPE_FIELD_NAME (type, i);
+ const char *t_field_name = TYPE_FIELD_NAME (type, i);
if (t_field_name && (strcmp_iw (t_field_name, field) == 0))
{
@@ -1317,7 +1332,6 @@ typy_has_key (PyObject *self, PyObject *args)
struct type *type = ((type_object *) self)->type;
const char *field;
int i;
- volatile struct gdb_exception except;
if (!PyArg_ParseTuple (args, "s", &field))
return NULL;
@@ -1332,7 +1346,7 @@ typy_has_key (PyObject *self, PyObject *args)
for (i = 0; i < TYPE_NFIELDS (type); i++)
{
- char *t_field_name = TYPE_FIELD_NAME (type, i);
+ const char *t_field_name = TYPE_FIELD_NAME (type, i);
if (t_field_name && (strcmp_iw (t_field_name, field) == 0))
Py_RETURN_TRUE;
@@ -1414,7 +1428,6 @@ typy_iterator_iternext (PyObject *self)
{
typy_iterator_object *iter_obj = (typy_iterator_object *) self;
struct type *type = iter_obj->source->type;
- int i;
PyObject *result;
if (iter_obj->field < TYPE_NFIELDS (type))
@@ -1681,6 +1694,13 @@ static PyTypeObject type_object_type =
0, /* tp_new */
};
+static PyGetSetDef field_object_getset[] =
+{
+ { "__dict__", gdb_py_generic_dict, NULL,
+ "The __dict__ for this field.", &field_object_type },
+ { NULL }
+};
+
static PyTypeObject field_object_type =
{
PyObject_HEAD_INIT (NULL)
@@ -1713,7 +1733,7 @@ static PyTypeObject field_object_type =
0, /* tp_iternext */
0, /* tp_methods */
0, /* tp_members */
- 0, /* tp_getset */
+ field_object_getset, /* tp_getset */
0, /* tp_base */
0, /* tp_dict */
0, /* tp_descr_get */
« no previous file with comments | « gdb/python/py-symtab.c ('k') | gdb/python/py-utils.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698