2003-04-05 Andrew Cagney <cagney@redhat.com>
authorAndrew Cagney <cagney@redhat.com>
Sat, 5 Apr 2003 18:54:38 +0000 (18:54 +0000)
committerAndrew Cagney <cagney@redhat.com>
Sat, 5 Apr 2003 18:54:38 +0000 (18:54 +0000)
* frame.c (frame_func_unwind, get_frame_func): New functions.
* frame.h (get_frame_func, frame_func_unwind): Declare.
(struct frame_info): Add field "prev_func" for caching the
previous frame's function address.
* arm-tdep.c (arm_frameless_function_invocation): Combine
get_pc_function_start and get_frame_pc into get_frame_func.
* sh-tdep.c (sh_nofp_frame_init_saved_regs): Ditto.
(sh64_nofp_frame_init_saved_regs): Ditto.
* s390-tdep.c (s390_function_start): Ditto.
* rs6000-tdep.c (rs6000_pop_frame): Ditto.
(rs6000_frameless_function_invocation): Ditto.
(rs6000_frame_saved_pc): Ditto.
* m68k-tdep.c (m68k_frame_init_saved_regs): Ditto.
* ia64-tdep.c (ia64_frame_init_saved_regs): Ditto.
* i386-tdep.c (i386_frameless_signal_p): Ditto.
(i386_frame_init_saved_regs): Ditto.
* hppa-tdep.c (hppa_frame_find_saved_regs): Ditto.
* d10v-tdep.c (d10v_frame_unwind_cache): Combine
get_pc_function_start and frame_pc_unwind into frame_func_unwind.
* cris-tdep.c (cris_frame_init_saved_regs): Ditto.
* blockframe.c (frameless_look_for_prologue): Ditto.

14 files changed:
gdb/ChangeLog
gdb/arm-tdep.c
gdb/blockframe.c
gdb/cris-tdep.c
gdb/d10v-tdep.c
gdb/frame.c
gdb/frame.h
gdb/hppa-tdep.c
gdb/i386-tdep.c
gdb/ia64-tdep.c
gdb/m68k-tdep.c
gdb/rs6000-tdep.c
gdb/s390-tdep.c
gdb/sh-tdep.c

index 8bb0240..b45380c 100644 (file)
@@ -1,5 +1,29 @@
 2003-04-05  Andrew Cagney  <cagney@redhat.com>
 
+       * frame.c (frame_func_unwind, get_frame_func): New functions.
+       * frame.h (get_frame_func, frame_func_unwind): Declare.
+       (struct frame_info): Add field "prev_func" for caching the
+       previous frame's function address.
+       * arm-tdep.c (arm_frameless_function_invocation): Combine
+       get_pc_function_start and get_frame_pc into get_frame_func.
+       * sh-tdep.c (sh_nofp_frame_init_saved_regs): Ditto.
+       (sh64_nofp_frame_init_saved_regs): Ditto.
+       * s390-tdep.c (s390_function_start): Ditto.
+       * rs6000-tdep.c (rs6000_pop_frame): Ditto.
+       (rs6000_frameless_function_invocation): Ditto.
+       (rs6000_frame_saved_pc): Ditto.
+       * m68k-tdep.c (m68k_frame_init_saved_regs): Ditto.
+       * ia64-tdep.c (ia64_frame_init_saved_regs): Ditto.
+       * i386-tdep.c (i386_frameless_signal_p): Ditto.
+       (i386_frame_init_saved_regs): Ditto.
+       * hppa-tdep.c (hppa_frame_find_saved_regs): Ditto.
+       * d10v-tdep.c (d10v_frame_unwind_cache): Combine
+       get_pc_function_start and frame_pc_unwind into frame_func_unwind.
+       * cris-tdep.c (cris_frame_init_saved_regs): Ditto.
+       * blockframe.c (frameless_look_for_prologue): Ditto.
+
+2003-04-05  Andrew Cagney  <cagney@redhat.com>
+
        * frame.c (legacy_get_prev_frame): Link prev to next at the
        function start.  Update comments.
 
index 3968592..5d8c538 100644 (file)
@@ -295,7 +295,7 @@ arm_frameless_function_invocation (struct frame_info *fi)
        stmdb sp!, {}
        sub sp, ip, #4.  */
 
-  func_start = (get_pc_function_start (get_frame_pc (fi)) + FUNCTION_START_OFFSET);
+  func_start = (get_frame_func (fi)) + FUNCTION_START_OFFSET);
   after_prologue = SKIP_PROLOGUE (func_start);
 
   /* There are some frameless functions whose first two instructions
index 364be9e..cf691a3 100644 (file)
@@ -146,7 +146,7 @@ frameless_look_for_prologue (struct frame_info *frame)
 {
   CORE_ADDR func_start, after_prologue;
 
-  func_start = get_pc_function_start (get_frame_pc (frame));
+  func_start = get_frame_func (frame);
   if (func_start)
     {
       func_start += FUNCTION_START_OFFSET;
index 4f9ee9b..2258a17 100644 (file)
@@ -1178,7 +1178,7 @@ cris_frame_init_saved_regs (struct frame_info *fi)
     }
   else
     {    
-      ip = get_pc_function_start (get_frame_pc (fi));
+      ip = get_frame_func (fi);
       sal = find_pc_line (ip, 0);
 
       /* If there is no symbol information then sal.end == 0, and we end up
index 6c234cc..5e94de4 100644 (file)
@@ -720,7 +720,7 @@ d10v_frame_unwind_cache (struct frame_info *next_frame,
   info->sp_offset = 0;
 
   info->uses_frame = 0;
-  for (pc = get_pc_function_start (frame_pc_unwind (next_frame));
+  for (pc = frame_func_unwind (next_frame);
        pc < frame_pc_unwind (next_frame);
        pc += 4)
     {
index 161ff60..b58900b 100644 (file)
@@ -190,6 +190,23 @@ frame_pc_unwind (struct frame_info *this_frame)
   return this_frame->pc_unwind_cache;
 }
 
+CORE_ADDR
+frame_func_unwind (struct frame_info *fi)
+{
+  if (!fi->prev_func.p)
+    {
+      fi->prev_func.p = 1;
+      fi->prev_func.addr = get_pc_function_start (frame_pc_unwind (fi));
+    }
+  return fi->prev_func.addr;
+}
+
+CORE_ADDR
+get_frame_func (struct frame_info *fi)
+{
+  return frame_func_unwind (fi->next);
+}
+
 static int
 do_frame_unwind_register (void *src, int regnum, void *buf)
 {
index ad81bd9..1d26209 100644 (file)
@@ -149,6 +149,12 @@ extern struct frame_info *frame_find_by_id (struct frame_id id);
    this frame.  */
 extern CORE_ADDR get_frame_pc (struct frame_info *);
 
+/* Following on from the `resume' address.  Return the entry point
+   address of the function containing that resume address, or zero if
+   that function isn't known.  */
+extern CORE_ADDR frame_func_unwind (struct frame_info *fi);
+extern CORE_ADDR get_frame_func (struct frame_info *fi);
+
 /* Closely related to the resume address, various symbol table
    attributes that are determined by the PC.  Note that for a normal
    frame, the PC refers to the resume address after the return, and
@@ -410,6 +416,13 @@ struct frame_info
     int pc_unwind_cache_p;
     CORE_ADDR pc_unwind_cache;
 
+    /* Cached copy of the previous frame's function address.  */
+    struct
+    {
+      CORE_ADDR addr;
+      int p;
+    } prev_func;
+
     /* This frame's ID.  Note that the frame's ID, base and PC contain
        redundant information.  */
     int id_p;
index 2e0c192..c9826e0 100644 (file)
@@ -3912,7 +3912,7 @@ hppa_frame_find_saved_regs (struct frame_info *frame_info,
 
   /* Get the starting address of the function referred to by the PC
      saved in frame.  */
-  pc = get_pc_function_start (frame_info->pc);
+  pc = get_frame_func (frame_info);
 
   /* Yow! */
   u = find_unwind_entry (pc);
index 7ef1f6e..317d726 100644 (file)
@@ -502,7 +502,7 @@ i386_frameless_signal_p (struct frame_info *frame)
   return (get_next_frame (frame)
          && get_frame_type (get_next_frame (frame)) == SIGTRAMP_FRAME
          && (frameless_look_for_prologue (frame)
-             || get_frame_pc (frame) == get_pc_function_start (get_frame_pc (frame))));
+             || get_frame_pc (frame) == get_frame_func (frame)));
 }
 
 /* Return the chain-pointer for FRAME.  In the case of the i386, the
@@ -714,7 +714,7 @@ i386_frame_init_saved_regs (struct frame_info *fip)
 
   frame_saved_regs_zalloc (fip);
 
-  pc = get_pc_function_start (get_frame_pc (fip));
+  pc = get_frame_func (fip);
   if (pc != 0)
     locals = i386_get_frame_setup (pc);
 
index ecb4919..5e46d6b 100644 (file)
@@ -1205,7 +1205,7 @@ ia64_frame_init_saved_regs (struct frame_info *frame)
     {
       CORE_ADDR func_start;
 
-      func_start = get_pc_function_start (get_frame_pc (frame));
+      func_start = get_frame_func (frame);
       examine_prologue (func_start, get_frame_pc (frame), frame);
     }
 }
index 7a9886b..a93a156 100644 (file)
@@ -614,7 +614,7 @@ m68k_frame_init_saved_regs (struct frame_info *frame_info)
     }
   else
     {
-      pc = get_pc_function_start (get_frame_pc (frame_info));
+      pc = get_frame_func (frame_info);
 
       nextinsn = read_memory_unsigned_integer (pc, 2);
       if (P_PEA_FP == nextinsn
index 5b48846..08394de 100644 (file)
@@ -990,7 +990,7 @@ rs6000_pop_frame (void)
      still in the link register, otherwise walk the frames and retrieve the
      saved %pc value in the previous frame.  */
 
-  addr = get_pc_function_start (get_frame_pc (frame));
+  addr = get_frame_func (frame);
   (void) skip_prologue (addr, get_frame_pc (frame), &fdata);
 
   wordsize = gdbarch_tdep (current_gdbarch)->wordsize;
@@ -1499,7 +1499,7 @@ rs6000_frameless_function_invocation (struct frame_info *fi)
       && !(get_frame_type (get_next_frame (fi)) == SIGTRAMP_FRAME))
     return 0;
 
-  func_start = get_pc_function_start (get_frame_pc (fi));
+  func_start = get_frame_func (fi);
 
   /* If we failed to find the start of the function, it is a mistake
      to inspect the instructions.  */
@@ -1540,7 +1540,7 @@ rs6000_frame_saved_pc (struct frame_info *fi)
     return deprecated_read_register_dummy (get_frame_pc (fi),
                                           get_frame_base (fi), PC_REGNUM);
 
-  func_start = get_pc_function_start (get_frame_pc (fi));
+  func_start = get_frame_func (fi);
 
   /* If we failed to find the start of the function, it is a mistake
      to inspect the instructions.  */
@@ -1596,8 +1596,7 @@ frame_get_saved_regs (struct frame_info *fi, struct rs6000_framedata *fdatap)
   if (fdatap == NULL)
     {
       fdatap = &work_fdata;
-      (void) skip_prologue (get_pc_function_start (get_frame_pc (fi)),
-                           get_frame_pc (fi), fdatap);
+      (void) skip_prologue (get_frame_func (fi), get_frame_pc (fi), fdatap);
     }
 
   frame_saved_regs_zalloc (fi);
@@ -1720,8 +1719,7 @@ frame_initial_stack_address (struct frame_info *fi)
 
   /* Find out if this function is using an alloca register.  */
 
-  (void) skip_prologue (get_pc_function_start (get_frame_pc (fi)),
-                       get_frame_pc (fi), &fdata);
+  (void) skip_prologue (get_frame_func (fi), get_frame_pc (fi), &fdata);
 
   /* If saved registers of this frame are not known yet, read and
      cache them.  */
index deff25d..2f8f4ff 100644 (file)
@@ -775,7 +775,7 @@ s390_function_start (struct frame_info *fi)
   if (get_frame_extra_info (fi) && get_frame_extra_info (fi)->initialised)
     function_start = get_frame_extra_info (fi)->function_start;
   else if (get_frame_pc (fi))
-    function_start = get_pc_function_start (get_frame_pc (fi));
+    function_start = get_frame_func (fi);
   return function_start;
 }
 
index 804b34a..d30586c 100644 (file)
@@ -1116,7 +1116,7 @@ sh_nofp_frame_init_saved_regs (struct frame_info *fi)
      that does not appear to be part of the prologue.  But give up
      after 20 of them, since we're getting silly then. */
 
-  pc = get_pc_function_start (get_frame_pc (fi));
+  pc = get_frame_func (fi);
   if (!pc)
     {
       deprecated_update_frame_pc_hack (fi, 0);
@@ -1456,7 +1456,7 @@ sh64_nofp_frame_init_saved_regs (struct frame_info *fi)
      that does not appear to be part of the prologue.  But give up
      after 20 of them, since we're getting silly then. */
 
-  pc = get_pc_function_start (get_frame_pc (fi));
+  pc = get_frame_func (fi);
   if (!pc)
     {
       deprecated_update_frame_pc_hack (fi, 0);
@@ -1657,7 +1657,7 @@ sh_fp_frame_init_saved_regs (struct frame_info *fi)
      that does not appear to be part of the prologue.  But give up
      after 20 of them, since we're getting silly then. */
 
-  pc = get_pc_function_start (get_frame_pc (fi));
+  pc = get_frame_func (fi);
   if (!pc)
     {
       deprecated_update_frame_pc_hack (fi, 0);