[AArch64] Only access inferior registers when creating a frame cache
authorPierre Langlois <pierre.langlois@arm.com>
Thu, 9 Jul 2015 15:35:11 +0000 (16:35 +0100)
committerPierre Langlois <pierre.langlois@arm.com>
Thu, 9 Jul 2015 15:35:11 +0000 (16:35 +0100)
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.

gdb/ChangeLog
gdb/aarch64-tdep.c

index 73ee4d183e0f05750eae784768d3c62d096b559b..0cc42a378af52a8e4e40d2096fc2af86e6c4a36b 100644 (file)
@@ -1,3 +1,14 @@
+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
index b21182b2f81a24fdaef9bd8b3848e1f958cb0d65..fe1b71fe6aa9fae9aab2834ba7a85094bc7f9a64 100644 (file)
@@ -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.  */
This page took 0.031067 seconds and 4 git commands to generate.