This is the mail archive of the gdb-prs@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]

[Bug python/18073] New: gdb.Type.fields() throws an exception when called on a function type


https://sourceware.org/bugzilla/show_bug.cgi?id=18073

            Bug ID: 18073
           Summary: gdb.Type.fields() throws an exception when called on a
                    function type
           Product: gdb
           Version: HEAD
            Status: NEW
          Severity: normal
          Priority: P2
         Component: python
          Assignee: unassigned at sourceware dot org
          Reporter: pipcet at gmail dot com

Created attachment 8160
  --> https://sourceware.org/bugzilla/attachment.cgi?id=8160&action=edit
patch

I'd like to submit the following obvious patch. It makes the python
gdb.Type.fields function return fields for function types, rather than throwing
an exception.

I do not know enough about gdb types to know whether there are any other type
codes that .fields() might validly get called on. (I do know that both the
python and the guile interface to types appear to be broken right now, which is
an unfortunate coincidence.)

diff --git a/gdb/python/py-type.c b/gdb/python/py-type.c
index a3da678..aed6b03 100644
--- a/gdb/python/py-type.c
+++ b/gdb/python/py-type.c
@@ -486,10 +486,11 @@ typy_get_composite (struct type *type)
      exception.  */
   if (TYPE_CODE (type) != TYPE_CODE_STRUCT
       && TYPE_CODE (type) != TYPE_CODE_UNION
-      && TYPE_CODE (type) != TYPE_CODE_ENUM)
+      && TYPE_CODE (type) != TYPE_CODE_ENUM
+      && TYPE_CODE (type) != TYPE_CODE_FUNC)
     {
       PyErr_SetString (PyExc_TypeError,
-               "Type is not a structure, union, or enum type.");
+               "Type is not a structure, union, enum, or function type.");
       return NULL;
     }

-- 
You are receiving this mail because:
You are on the CC list for the bug.


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