From patchwork Tue Jul 7 12:51:53 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierre Langlois X-Patchwork-Id: 7555 Received: (qmail 47171 invoked by alias); 7 Jul 2015 12:52:11 -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 47106 invoked by uid 89); 7 Jul 2015 12:52:11 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.9 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:52:09 +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-Oy77oNHNQHmy-m7jm1qg-A-7 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 3/8] [AArch64] Only access inferior registers when creating a frame cache Date: Tue, 7 Jul 2015 13:51:53 +0100 Message-Id: <1436273518-5959-4-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: Oy77oNHNQHmy-m7jm1qg-A-7 X-IsSubscribed: yes This patch moves the address of the start of a function (func) and the address from which it was called (prev_pc) into aarch64_prologue_cache. The idea is to keep accesses to the inferior's registers into aarch64_make_prologue_cache and aarch64_make_stub_cache. gdb/ChangeLog: * aarch64-tdep.c (aarch64_prologue_cache) : New fields. (aarch64_scan_prologue): Set prev_pc. (aarch64_make_prologue_cache): Set func. (aarch64_make_stub_cache): Set prev_pc. (aarch64_prologue_this_id): Remove local variables id, pc and func. Read prev_pc and func from cache. (aarch64_stub_this_id): Read prev_pc from cache. --- gdb/aarch64-tdep.c | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/gdb/aarch64-tdep.c b/gdb/aarch64-tdep.c index 90a63e9..6a38f18 100644 --- a/gdb/aarch64-tdep.c +++ b/gdb/aarch64-tdep.c @@ -148,6 +148,15 @@ static const char *const aarch64_v_register_names[] = /* AArch64 prologue cache structure. */ struct aarch64_prologue_cache { + /* The program counter at the start of the function. It is used to + identify this frame as a prologue frame. */ + CORE_ADDR func; + + /* The program counter at the time this frame was created; i.e. where + this function was called from. It is used to identify this frame as a + stub frame. */ + CORE_ADDR prev_pc; + /* The stack pointer at the time this frame was created; i.e. the caller's stack pointer when this function was called. It is used to identify this frame. */ @@ -889,6 +898,8 @@ aarch64_scan_prologue (struct frame_info *this_frame, CORE_ADDR prev_pc = get_frame_pc (this_frame); struct gdbarch *gdbarch = get_frame_arch (this_frame); + cache->prev_pc = prev_pc; + /* Assume we do not find a frame. */ cache->framereg = -1; cache->framesize = 0; @@ -964,6 +975,8 @@ aarch64_make_prologue_cache (struct frame_info *this_frame, void **this_cache) if (trad_frame_addr_p (cache->saved_regs, reg)) cache->saved_regs[reg].addr += cache->prev_sp; + cache->func = get_frame_func (this_frame); + return cache; } @@ -976,21 +989,16 @@ aarch64_prologue_this_id (struct frame_info *this_frame, { struct aarch64_prologue_cache *cache = aarch64_make_prologue_cache (this_frame, this_cache); - struct frame_id id; - CORE_ADDR pc, func; /* This is meant to halt the backtrace at "_start". */ - pc = get_frame_pc (this_frame); - if (pc <= gdbarch_tdep (get_frame_arch (this_frame))->lowest_pc) + if (cache->prev_pc <= gdbarch_tdep (get_frame_arch (this_frame))->lowest_pc) return; /* If we've hit a wall, stop. */ if (cache->prev_sp == 0) return; - func = get_frame_func (this_frame); - id = frame_id_build (cache->prev_sp, func); - *this_id = id; + *this_id = frame_id_build (cache->prev_sp, cache->func); } /* Implement the "prev_register" frame_unwind method. */ @@ -1065,6 +1073,7 @@ aarch64_make_stub_cache (struct frame_info *this_frame, void **this_cache) cache->prev_sp = get_frame_register_unsigned (this_frame, AARCH64_SP_REGNUM); + cache->prev_pc = get_frame_pc (this_frame); return cache; } @@ -1078,7 +1087,7 @@ aarch64_stub_this_id (struct frame_info *this_frame, 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)); + *this_id = frame_id_build (cache->prev_sp, cache->prev_pc); } /* Implement the "sniffer" frame_unwind method. */