public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
From: "pipcet at gmail dot com" <sourceware-bugzilla@sourceware.org>
To: gdb-prs@sourceware.org
Subject: [Bug python/18073] New: gdb.Type.fields() throws an exception when called on a function type
Date: Mon, 02 Mar 2015 19:01:00 -0000	[thread overview]
Message-ID: <bug-18073-4717@http.sourceware.org/bugzilla/> (raw)

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.


             reply	other threads:[~2015-03-02 19:00 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-02 19:01 pipcet at gmail dot com [this message]
2015-03-02 20:25 ` [Bug python/18073] " pipcet at gmail dot com
2015-09-30 18:41 ` munsal at nestlabs dot com
2015-10-21 19:59 ` cvs-commit at gcc dot gnu.org
2015-10-21 20:03 ` simon.marchi at ericsson dot com

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-18073-4717@http.sourceware.org/bugzilla/ \
    --to=sourceware-bugzilla@sourceware.org \
    --cc=gdb-prs@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).