This is the mail archive of the
gdb-cvs@sourceware.org
mailing list for the GDB project.
[binutils-gdb] [AArch64] Only access inferior registers when creating a frame cache
- From: Pierre Langlois <planglois at sourceware dot org>
- To: gdb-cvs at sourceware dot org
- Date: 9 Jul 2015 15:36:03 -0000
- Subject: [binutils-gdb] [AArch64] Only access inferior registers when creating a frame cache
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=db634143224dc7cb985d996bed15257f5cb86b25
commit db634143224dc7cb985d996bed15257f5cb86b25
Author: Pierre Langlois <pierre.langlois@arm.com>
Date: Thu Jul 9 16:35:11 2015 +0100
[AArch64] Only access inferior registers when creating a frame cache
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) <func, prev_pc>: 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.
Diff:
---
gdb/ChangeLog | 11 +++++++++++
gdb/aarch64-tdep.c | 25 +++++++++++++++++--------
2 files changed, 28 insertions(+), 8 deletions(-)
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 73ee4d1..0cc42a3 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,16 @@
2015-07-09 Pierre Langlois <pierre.langlois@arm.com>
+ * aarch64-tdep.c (aarch64_prologue_cache) <func, prev_pc>: 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.
+
+2015-07-09 Pierre Langlois <pierre.langlois@arm.com>
+
* 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
diff --git a/gdb/aarch64-tdep.c b/gdb/aarch64-tdep.c
index b21182b..fe1b71f 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;
@@ -966,6 +977,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;
}
@@ -978,21 +991,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. */
@@ -1069,6 +1077,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;
}
@@ -1082,7 +1091,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. */