From patchwork Thu Jul 9 10:41:08 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierre Langlois X-Patchwork-Id: 7607 Received: (qmail 40692 invoked by alias); 9 Jul 2015 10:41:20 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 40679 invoked by uid 89); 9 Jul 2015 10:41:19 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.2 required=5.0 tests=AWL, BAYES_00, SPF_PASS autolearn=ham version=3.3.2 X-HELO: eu-smtp-delivery-143.mimecast.com Received: from eu-smtp-delivery-143.mimecast.com (HELO eu-smtp-delivery-143.mimecast.com) (207.82.80.143) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 09 Jul 2015 10:41:14 +0000 Received: from cam-owa1.Emea.Arm.com (fw-tnat.cambridge.arm.com [217.140.96.140]) by eu-smtp-1.mimecast.com with ESMTP id uk-mta-26-a7X2SBDGSeSJJflBMo90Ew-1; Thu, 09 Jul 2015 11:41:09 +0100 Received: from e105615-lin.cambridge.arm.com ([10.1.2.79]) by cam-owa1.Emea.Arm.com with Microsoft SMTPSVC(6.0.3790.3959); Thu, 9 Jul 2015 11:41:09 +0100 From: Pierre Langlois To: qiyaoltc@gmail.com Cc: Pierre Langlois , gdb-patches@sourceware.org Subject: [PATCH v2 2/8] [AArch64] Refactor aarch64_make_stub_cache Date: Thu, 9 Jul 2015 11:41:08 +0100 Message-Id: <1436438468-36887-1-git-send-email-pierre.langlois@arm.com> In-Reply-To: <86y4iqmxzi.fsf@gmail.com> References: <86y4iqmxzi.fsf@gmail.com> X-MC-Unique: a7X2SBDGSeSJJflBMo90Ew-1 X-IsSubscribed: yes Here is the updated patch that I'll push. Thanks, Pierre --- We would previously have to make sure the frame cache was not already created before calling aarch64_make_stub_cache. This patch makes this function check it so the caller does not need to do so. gdb/ChangeLog: * aarch64-tdep.c (aarch64_make_stub_cache): Update comment. New argument this_cache. Remove unused local variables reg and unwound_fp. Return early if this_cache is already set. Set this_cache. (aarch64_stub_this_id): Update call to aarch64_make_stub_cache. --- gdb/aarch64-tdep.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/gdb/aarch64-tdep.c b/gdb/aarch64-tdep.c index 0496536..51dda92 100644 --- a/gdb/aarch64-tdep.c +++ b/gdb/aarch64-tdep.c @@ -1050,18 +1050,22 @@ struct frame_unwind aarch64_prologue_unwind = default_frame_sniffer }; -/* Allocate an aarch64_prologue_cache and fill it with information - about the prologue of *THIS_FRAME. */ +/* Allocate and fill in *THIS_CACHE with information about the prologue of + *THIS_FRAME. Do not do this is if *THIS_CACHE was already allocated. + Return a pointer to the current aarch64_prologue_cache in *THIS_CACHE. + */ static struct aarch64_prologue_cache * -aarch64_make_stub_cache (struct frame_info *this_frame) +aarch64_make_stub_cache (struct frame_info *this_frame, void **this_cache) { - int reg; struct aarch64_prologue_cache *cache; - CORE_ADDR unwound_fp; + + if (*this_cache != NULL) + return *this_cache; cache = FRAME_OBSTACK_ZALLOC (struct aarch64_prologue_cache); cache->saved_regs = trad_frame_alloc_saved_regs (this_frame); + *this_cache = cache; cache->prev_sp = get_frame_register_unsigned (this_frame, AARCH64_SP_REGNUM); @@ -1075,11 +1079,8 @@ static void aarch64_stub_this_id (struct frame_info *this_frame, void **this_cache, struct frame_id *this_id) { - struct aarch64_prologue_cache *cache; - - if (*this_cache == NULL) - *this_cache = aarch64_make_stub_cache (this_frame); - cache = *this_cache; + struct aarch64_prologue_cache *cache + = aarch64_make_stub_cache (this_frame, this_cache); *this_id = frame_id_build (cache->prev_sp, get_frame_pc (this_frame)); }