From: "Martin Ünsal" <munsal@nestlabs.com>
To: gdb@sourceware.org
Subject: Python API: Type introspection of function arguments
Date: Fri, 25 Sep 2015 04:24:00 -0000 [thread overview]
Message-ID: <CAHHafQWq=XGR8JBJR8fSTJwWX2YUdcX0oS2kak_vbxT3xzA-dQ@mail.gmail.com> (raw)
Hi all,
GDB Python bindings are great. I have a question though.
I'm trying to use a Python script to introspect the type of a function
argument. The GDB documentation claims this is possible:
https://sourceware.org/gdb/current/onlinedocs/gdb/Types-In-Python.html#Types-In-Python
"— Function: Type.fields ()
For structure and union types, this method returns the fields. Range
types have two fields, the minimum and maximum values. Enum types have
one field per enum constant. Function and method types have one field
per parameter."
However when I try this (in 7.8.1.20141128-cvs) I get the following error:
>>> sym = gdb.lookup_global_symbol('my_function')
>>> print sym.type.code == gdb.TYPE_CODE_FUNC
True
>>> print sym.type.fields()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: Type is not a structure, union, or enum type.
>>>
I also looked in the code (gdb/python/py-type.c) and this seems to
have the same behavior in 7.10.
In light of this issue, can anyone suggest how to get function
argument type information from Python API?
Thanks,
Martin
next reply other threads:[~2015-09-25 4:24 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-25 4:24 Martin Ünsal [this message]
2015-09-27 23:28 ` Simon Marchi
2015-09-28 4:50 ` Simon Marchi
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='CAHHafQWq=XGR8JBJR8fSTJwWX2YUdcX0oS2kak_vbxT3xzA-dQ@mail.gmail.com' \
--to=munsal@nestlabs.com \
--cc=gdb@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