From patchwork Tue Jul 7 12:51:52 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierre Langlois X-Patchwork-Id: 7559 Received: (qmail 50740 invoked by alias); 7 Jul 2015 12:53:14 -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 50644 invoked by uid 89); 7 Jul 2015 12:53:14 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.1 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; Tue, 07 Jul 2015 12:53:12 +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-14-n0VEBnVuR_WWcCTqq7VMTQ-5 Received: from e105615-lin.cambridge.arm.com ([10.1.2.79]) by cam-owa1.Emea.Arm.com with Microsoft SMTPSVC(6.0.3790.3959); Tue, 7 Jul 2015 13:52:00 +0100 From: Pierre Langlois To: gdb-patches@sourceware.org Cc: Pierre Langlois Subject: [PATCH 2/8] [AArch64] Refactor aarch64_make_stub_cache Date: Tue, 7 Jul 2015 13:51:52 +0100 Message-Id: <1436273518-5959-3-git-send-email-pierre.langlois@arm.com> In-Reply-To: <1436273518-5959-1-git-send-email-pierre.langlois@arm.com> References: <1436273518-5959-1-git-send-email-pierre.langlois@arm.com> X-MC-Unique: n0VEBnVuR_WWcCTqq7VMTQ-5 X-IsSubscribed: yes 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): 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 | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/gdb/aarch64-tdep.c b/gdb/aarch64-tdep.c index c4b7fe8..90a63e9 100644 --- a/gdb/aarch64-tdep.c +++ b/gdb/aarch64-tdep.c @@ -1052,14 +1052,16 @@ struct frame_unwind aarch64_prologue_unwind = about the prologue of *THIS_FRAME. */ 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) + 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); @@ -1073,11 +1075,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)); }