From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 86220 invoked by alias); 5 Feb 2016 12:17:37 -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 86209 invoked by uid 89); 5 Feb 2016 12:17:36 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.2 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=Hx-languages-length:2151 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Fri, 05 Feb 2016 12:17:35 +0000 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id E5EF34C523; Fri, 5 Feb 2016 12:17:33 +0000 (UTC) Received: from [10.36.112.51] (ovpn-112-51.ams2.redhat.com [10.36.112.51]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u15CHW5R024742; Fri, 5 Feb 2016 07:17:33 -0500 Subject: Re: [PATCH 4/7] py-symbol: Require a frame for lookup_symbol only when necessary To: jeffm@suse.com, gdb-patches@sourceware.org References: <1454606973-31017-1-git-send-email-jeffm@suse.com> <1454606973-31017-5-git-send-email-jeffm@suse.com> From: Phil Muldoon Message-ID: <56B492DC.6090402@redhat.com> Date: Fri, 05 Feb 2016 12:17:00 -0000 MIME-Version: 1.0 In-Reply-To: <1454606973-31017-5-git-send-email-jeffm@suse.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes X-SW-Source: 2016-02/txt/msg00139.txt.bz2 On 04/02/16 17:29, jeffm@suse.com wrote: > From: Jeff Mahoney > > gdbpy_lookup_symbol requires a fr= ame prior to doing the symbol lookup but > a frame isn't necessary for many= symbol types. Calling > symbol_read_needs_frame will tell us if it's nece= ssary but we need to > have already looked up the symbol to use it. This p= atch puts the > lookup first and then only resolves the frame if one is req= uired. > > This allows us to lookup static symbols directly from python rat= her > than using gdb.eval_and_parse. Please add documentation and further tests for new functionality. > --- > gdb/python/py-symbol.c | 31 +++++++++++++++++-------------- > 1 f= ile changed, 17 insertions(+), 14 deletions(-) > > diff --git a/gdb/python/= py-symbol.c b/gdb/python/py-symbol.c > index cbbc9e2..c7f0ff8 100644 > --- = a/gdb/python/py-symbol.c > +++ b/gdb/python/py-symbol.c > @@ -382,14 +382,2= 8 @@ gdbpy_lookup_symbol (PyObject *self, PyObject *args, PyObject *kw) > = > if (block_obj) > block =3D block_object_to_block (block_obj); > -= else > + > + TRY > + { > + symbol =3D lookup_symbol (name, block= , (domain_enum) domain, > + &is_a_field_of_this).symbol; >= + } > + CATCH (except, RETURN_MASK_ALL) > + { > + GDB_PY_HANDL= E_EXCEPTION (except); > + } > + END_CATCH > + > + if (symbol && !block= ) > { > struct frame_info *selected_frame; > > TRY > = { > - selected_frame =3D get_selected_frame (_("No frame selected."= )); > - block =3D get_frame_block (selected_frame, NULL); > + if (symbol_read_needs_frame(symbol)) { Formatting nit, space after function name and before (. > + selected_frame =3D get_selected_frame (_("No frame selected."));= > + block =3D get_frame_block (selected_frame, NULL); > + } > = } > CATCH (except, RETURN_MASK_ALL) > { > @@ -398,17 +412,= 6 @@ gdbpy_lookup_symbol (PyObject *self, PyObject *args, PyObject *kw) > = END_CATCH > } My only concern here is (and the context is not meaningful enough to see), is that you've removed an "else" above which is an unconditional branch, and replaced it with an IF instead. What happens when both IFs can fail? Cheers Phil