[AArch64] Refactor aarch64_make_prologue_cache
authorPierre Langlois <pierre.langlois@arm.com>
Thu, 9 Jul 2015 15:35:10 +0000 (16:35 +0100)
committerPierre Langlois <pierre.langlois@arm.com>
Thu, 9 Jul 2015 15:35:10 +0000 (16:35 +0100)
We would previously have to make sure the frame cache was not already
created before calling aarch64_make_prologue_cache.  This patch makes
this function check it so that the caller does not need to do so.

gdb/ChangeLog:

* aarch64-tdep.c (aarch64_make_prologue_cache): Update comment.
New argument this_cache.  Return early if this_cache is already
set.  Set this_cache.
(aarch64_prologue_this_id): Update call to
aarch64_make_prologue_cache.
(aarch64_prologue_prev_register): Likewise.
(aarch64_normal_frame_base): Likewise.

gdb/ChangeLog
gdb/aarch64-tdep.c

index b5b80a39cc61adfe47d2bdb48e7657dde5e2d4e8..672b29731e1a3a01efd54e0422a5a9c076302c1e 100644 (file)
@@ -1,3 +1,13 @@
+2015-07-09  Pierre Langlois  <pierre.langlois@arm.com>
+
+       * aarch64-tdep.c (aarch64_make_prologue_cache): Update comment.
+       New argument this_cache.  Return early if this_cache is already
+       set.  Set this_cache.
+       (aarch64_prologue_this_id): Update call to
+       aarch64_make_prologue_cache.
+       (aarch64_prologue_prev_register): Likewise.
+       (aarch64_normal_frame_base): Likewise.
+
 2015-07-09  Simon Marchi  <simon.marchi@ericsson.com>
 
        * c-valprint.c (c_val_print): Factor out memberptr printing code
index 9650a7a0cd7cf64b95e0778b79f1ca883802b0e2..6f3a643405eee4e35462e43290698c469c112e4f 100644 (file)
@@ -930,18 +930,24 @@ aarch64_scan_prologue (struct frame_info *this_frame,
     }
 }
 
-/* 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_prologue_cache (struct frame_info *this_frame)
+aarch64_make_prologue_cache (struct frame_info *this_frame, void **this_cache)
 {
   struct aarch64_prologue_cache *cache;
   CORE_ADDR unwound_fp;
   int reg;
 
+  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;
 
   aarch64_scan_prologue (this_frame, cache);
 
@@ -970,14 +976,11 @@ static void
 aarch64_prologue_this_id (struct frame_info *this_frame,
                          void **this_cache, struct frame_id *this_id)
 {
-  struct aarch64_prologue_cache *cache;
+  struct aarch64_prologue_cache *cache
+    = aarch64_make_prologue_cache (this_frame, this_cache);
   struct frame_id id;
   CORE_ADDR pc, func;
 
-  if (*this_cache == NULL)
-    *this_cache = aarch64_make_prologue_cache (this_frame);
-  cache = *this_cache;
-
   /* 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)
@@ -999,11 +1002,8 @@ aarch64_prologue_prev_register (struct frame_info *this_frame,
                                void **this_cache, int prev_regnum)
 {
   struct gdbarch *gdbarch = get_frame_arch (this_frame);
-  struct aarch64_prologue_cache *cache;
-
-  if (*this_cache == NULL)
-    *this_cache = aarch64_make_prologue_cache (this_frame);
-  cache = *this_cache;
+  struct aarch64_prologue_cache *cache
+    = aarch64_make_prologue_cache (this_frame, this_cache);
 
   /* If we are asked to unwind the PC, then we need to return the LR
      instead.  The prologue may save PC, but it will point into this
@@ -1120,11 +1120,8 @@ struct frame_unwind aarch64_stub_unwind =
 static CORE_ADDR
 aarch64_normal_frame_base (struct frame_info *this_frame, void **this_cache)
 {
-  struct aarch64_prologue_cache *cache;
-
-  if (*this_cache == NULL)
-    *this_cache = aarch64_make_prologue_cache (this_frame);
-  cache = *this_cache;
+  struct aarch64_prologue_cache *cache
+    = aarch64_make_prologue_cache (this_frame, this_cache);
 
   return cache->prev_sp - cache->framesize;
 }
This page took 0.038607 seconds and 4 git commands to generate.