This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [patch] [python] PR python/15461 (gate architecture calls)
- From: Phil Muldoon <pmuldoon at redhat dot com>
- To: Tom Tromey <tromey at redhat dot com>
- Cc: "gdb-patches at sourceware dot org" <gdb-patches at sourceware dot org>
- Date: Wed, 28 Aug 2013 16:15:37 +0100
- Subject: Re: [patch] [python] PR python/15461 (gate architecture calls)
- Authentication-results: sourceware.org; auth=none
- References: <521DE761 dot 6010403 at redhat dot com> <87k3j5x3yq dot fsf at fleche dot redhat dot com>
On 28/08/13 15:52, Tom Tromey wrote:
>>>>>> "Phil" == Phil Muldoon <pmuldoon@redhat.com> writes:
>
> Phil> This patch gates calls to architecture.name and
> Phil> architecture.disassemble. If the underlying GDB architecture is NULL,
> Phil> calls to those Python functions will result in an assert call.
>
> Thanks.
>
> Phil> +/* Require a valid Architecture. */
> Phil> +#define ARCHPY_REQUIRE_VALID (arch_obj, arch) \
> Phil> + do { \
> Phil> + arch = arch_object_to_gdbarch (arch_obj); \
> Phil> + if (arch == NULL) \
> Phil> + error (_("Architecture is invalid.")); \
> Phil> + } while (0)
>
> I think it would be simpler to either:
>
> * Have this set the python exception and not call error, or
> * Likewise but just have it be done in arch_object_to_gdbarch.
>
> With the current approach you have to have a try/catch and then throw an
> exception; but really all you want is to set the python exception --
> which is cheaper to do directly.
I don't disagree on the efficiency argument, but my goal here was to
follow the pattern that other objects use to determine validity of the
underlying GDB data. To bring a sense of uniformity to how we do
things in Python. So how we check a gdb.Frame's, et al, validity, the
pattern will be the same, as far as possible, for other objects. In
that sense, to me at least, the uniformity of how we do this trumps
expectancy of efficiency. I don't really want to argue the point too
much, as I really don't have very strong feelings either way.
Additionally, I could only see this routine happening in the test-case
derived from the bug, so I think this code would rarely run.
Cheers,
Phil