From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5179 invoked by alias); 28 Aug 2013 15:15:42 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 5170 invoked by uid 89); 28 Aug 2013 15:15:42 -0000 Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 28 Aug 2013 15:15:42 +0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-5.2 required=5.0 tests=AWL,BAYES_00,KHOP_THREADED,RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r7SFFdFr027483 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 28 Aug 2013 11:15:40 -0400 Received: from localhost.localdomain (ovpn-112-21.ams2.redhat.com [10.36.112.21]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r7SFFbe9015038; Wed, 28 Aug 2013 11:15:38 -0400 Message-ID: <521E1419.5040404@redhat.com> Date: Wed, 28 Aug 2013 15:15:00 -0000 From: Phil Muldoon MIME-Version: 1.0 To: Tom Tromey CC: "gdb-patches@sourceware.org" Subject: Re: [patch] [python] PR python/15461 (gate architecture calls) References: <521DE761.6010403@redhat.com> <87k3j5x3yq.fsf@fleche.redhat.com> In-Reply-To: <87k3j5x3yq.fsf@fleche.redhat.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-SW-Source: 2013-08/txt/msg00832.txt.bz2 On 28/08/13 15:52, Tom Tromey wrote: >>>>>> "Phil" == Phil Muldoon 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