This is the mail archive of the archer@sourceware.org mailing list for the Archer 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]

[python] work around a crash


I'm checking this in on the python branch.

Phil pointed out a crash when fetching a field list for a type.  In
this case, the type of the field was NULL.  I'm not sure why this can
happen, though I suspect missing debug info.

I changed the Python code to return None as the type attribute of a
field like this.

Tom

gdb
	* python/python-type.c (convert_field): Handle a NULL type.
gdb/doc
	* gdb.texinfo (Types From Inferior): Update.

diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
index 7c01732..af3d12b 100644
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -18522,7 +18522,8 @@ non-zero value, which is the size of the field in bits.  Otherwise,
 this will be zero; in this case the field's size is given by its type.
 
 @item type
-The type of the field.
+The type of the field.  This is usually an instance of @code{Type},
+but it can be @code{None} in some situations.
 @end table
 @end defmethod
 
diff --git a/gdb/python/python-type.c b/gdb/python/python-type.c
index d336456..2a54556 100644
--- a/gdb/python/python-type.c
+++ b/gdb/python/python-type.c
@@ -175,7 +175,14 @@ convert_field (struct type *type, int field)
   if (PyObject_SetAttrString (result, "bitsize", arg) < 0)
     goto failarg;
 
-  arg = type_to_type_object (TYPE_FIELD_TYPE (type, field));
+  /* A field can have a NULL type in some situations.  */
+  if (TYPE_FIELD_TYPE (type, field) == NULL)
+    {
+      arg = Py_None;
+      Py_INCREF (arg);
+    }
+  else
+    arg = type_to_type_object (TYPE_FIELD_TYPE (type, field));
   if (!arg)
     goto fail;
   if (PyObject_SetAttrString (result, "type", arg) < 0)


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