From: Simon Marchi <simark@simark.ca>
To: Christian Biesinger <cbiesinger@google.com>, gdb-patches@sourceware.org
Subject: Re: [PATCH] Add an objfile getter to gdb.Type
Date: Thu, 23 May 2019 19:34:00 -0000 [thread overview]
Message-ID: <e130fe5f-70ed-7bb6-c909-ff9a5538de34@simark.ca> (raw)
In-Reply-To: <20190523183935.209380-1-cbiesinger@google.com>
Hi Christian,
On 2019-05-23 2:39 p.m., Christian Biesinger via gdb-patches wrote:
> diff --git a/gdb/doc/python.texi b/gdb/doc/python.texi
> index 98e52bb770..f769ad03a2 100644
> --- a/gdb/doc/python.texi
> +++ b/gdb/doc/python.texi
> @@ -1087,6 +1087,11 @@ languages have this concept. If this type has no tag name, then
> @code{None} is returned.
> @end defvar
>
> +@defvar Type.objfile
> +The @code{gdb.Objfile} that this type was defined in, or @code{None} if
> +there is no associated objfile.
> +@end defvar
> +
> The following methods are provided:
>
> @defun Type.fields ()
> diff --git a/gdb/python/py-type.c b/gdb/python/py-type.c
> index 22cc658a8b..722960e032 100644
> --- a/gdb/python/py-type.c
> +++ b/gdb/python/py-type.c
> @@ -413,6 +413,20 @@ typy_get_tag (PyObject *self, void *closure)
> return PyString_FromString (tagname);
> }
>
> +/* Return the type's tag, or None. */
copy-pasto: "type's objfile"
> +static PyObject *
> +typy_get_objfile (PyObject *self, void *closure)
> +{
> + struct type *type = ((type_object *) self)->type;
> + struct objfile *objfile = nullptr;
> +
> + objfile = TYPE_OBJFILE(type);
You can write it as
struct objfile *objfile = objfile = TYPE_OBJFILE (type);
directly.
We would need a corresponding test though. It should be a relatively easy addition
to testsuite/gdb.python/py-type.exp. See here for info about how to run just one
test:
https://sourceware.org/gdb/wiki/TestingGDB#Running_specific_tests
Thanks!
Simon
next prev parent reply other threads:[~2019-05-23 19:34 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-05-23 18:40 Christian Biesinger via gdb-patches
2019-05-23 19:01 ` Eli Zaretskii
2019-05-23 19:34 ` Simon Marchi [this message]
2019-05-23 20:36 ` Christian Biesinger via gdb-patches
2019-05-23 20:32 ` Christian Biesinger via gdb-patches
2019-05-23 21:06 ` Simon Marchi
2019-05-23 21:25 ` Christian Biesinger via gdb-patches
2019-05-23 21:37 ` Christian Biesinger via gdb-patches
2019-05-28 22:07 ` Tom Tromey
2019-05-30 17:01 ` Christian Biesinger via gdb-patches
2019-06-03 19:50 ` Tom Tromey
2019-06-03 20:28 ` Christian Biesinger via gdb-patches
2019-06-04 15:47 ` Tom Tromey
2019-06-04 21:48 ` Pedro Alves
2019-06-04 22:07 ` Christian Biesinger via gdb-patches
2019-06-05 1:51 ` Tom Tromey
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=e130fe5f-70ed-7bb6-c909-ff9a5538de34@simark.ca \
--to=simark@simark.ca \
--cc=cbiesinger@google.com \
--cc=gdb-patches@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