[patch] Eliminate EXTRA_FRAME_INFO for Alpha target

Jason R Thorpe thorpej@wasabisystems.com
Fri Jan 18 22:43:00 GMT 2002


This patch eliminates EXTRA_FRAME_INFO and includes some cleanup
of related items.

Committed as obvious.

	* alpha-tdep.c (frame_extra_info): New.
	(alpha_find_saved_regs): Make static.  Use
	frame->extra_info.
	(alpha_frame_init_saved_regs): New function.
	(alpha_frame_saved_pc): Use frame->extra_info.
	(temp_saved_regs): Don't declare as struct frame_saved_regs.
	(heuristic_proc_desc): Adjust for temp_saved_regs changes.
	(init_extra_frame_info): Rename to...
	(alpha_init_extra_frame_info): ...this.  Use frame->extra_info.
	(alpha_print_extra_frame_info): New function.
	(alpha_frame_locals_address): Ditto.
	(alpha_frame_args_address): Ditto.
	(alpha_pop_frame): Use frame->extra_info.
	* config/alpha/tm-alpha.h (FRAME_ARGS_ADDRESS): Use
	alpha_frame_args_address.
	(FRAME_LOCALS_ADDRESS): Use alpha_frame_locals_address.
	(alpha_find_saved_regs): Remove prototype.
	(FRAME_INIT_SAVED_REGS): Use alpha_frame_init_saved_regs.
	(EXTRA_FRAME_INFO): Remove.
	(INIT_EXTRA_FRAME_INFO): Use alpha_init_extra_frame_info.
	(PRINT_EXTRA_FRAME_INFO): Use alpha_print_extra_frame_info.

-- 
        -- Jason R. Thorpe <thorpej@wasabisystems.com>
-------------- next part --------------
Index: alpha-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/alpha-tdep.c,v
retrieving revision 1.14
diff -c -r1.14 alpha-tdep.c
*** alpha-tdep.c	2002/01/19 05:26:46	1.14
--- alpha-tdep.c	2002/01/19 06:29:57
***************
*** 34,43 ****
--- 34,52 ----
  #include "regcache.h"
  #include "doublest.h"
  
+ struct frame_extra_info
+   {
+     alpha_extra_func_info_t proc_desc;
+     int localoff;
+     int pc_reg;
+   };
+ 
  /* FIXME: Some of this code should perhaps be merged with mips-tdep.c.  */
  
  /* Prototypes for local functions. */
  
+ static void alpha_find_saved_regs (struct frame_info *);
+ 
  static alpha_extra_func_info_t push_sigtramp_desc (CORE_ADDR low_addr);
  
  static CORE_ADDR read_next_frame_reg (struct frame_info *, int);
***************
*** 311,317 ****
  /* Guaranteed to set frame->saved_regs to some values (it never leaves it
     NULL).  */
  
! void
  alpha_find_saved_regs (struct frame_info *frame)
  {
    int ireg;
--- 320,326 ----
  /* Guaranteed to set frame->saved_regs to some values (it never leaves it
     NULL).  */
  
! static void
  alpha_find_saved_regs (struct frame_info *frame)
  {
    int ireg;
***************
*** 351,357 ****
        return;
      }
  
!   proc_desc = frame->proc_desc;
    if (proc_desc == NULL)
      /* I'm not sure how/whether this can happen.  Normally when we can't
         find a proc_desc, we "synthesize" one using heuristic_proc_desc
--- 360,366 ----
        return;
      }
  
!   proc_desc = frame->extra_info->proc_desc;
    if (proc_desc == NULL)
      /* I'm not sure how/whether this can happen.  Normally when we can't
         find a proc_desc, we "synthesize" one using heuristic_proc_desc
***************
*** 399,404 ****
--- 408,421 ----
    frame->saved_regs[PC_REGNUM] = frame->saved_regs[returnreg];
  }
  
+ void
+ alpha_frame_init_saved_regs (struct frame_info *fi)
+ {
+   if (fi->saved_regs == NULL)
+     alpha_find_saved_regs (fi);
+   fi->saved_regs[SP_REGNUM] = fi->frame;
+ }
+ 
  static CORE_ADDR
  read_next_frame_reg (struct frame_info *fi, int regno)
  {
***************
*** 422,431 ****
  CORE_ADDR
  alpha_frame_saved_pc (struct frame_info *frame)
  {
!   alpha_extra_func_info_t proc_desc = frame->proc_desc;
    /* We have to get the saved pc from the sigcontext
       if it is a signal handler frame.  */
!   int pcreg = frame->signal_handler_caller ? PC_REGNUM : frame->pc_reg;
  
    if (proc_desc && PROC_DESC_IS_DUMMY (proc_desc))
      return read_memory_integer (frame->frame - 8, 8);
--- 439,449 ----
  CORE_ADDR
  alpha_frame_saved_pc (struct frame_info *frame)
  {
!   alpha_extra_func_info_t proc_desc = frame->extra_info->proc_desc;
    /* We have to get the saved pc from the sigcontext
       if it is a signal handler frame.  */
!   int pcreg = frame->signal_handler_caller ? PC_REGNUM
!                                            : frame->extra_info->pc_reg;
  
    if (proc_desc && PROC_DESC_IS_DUMMY (proc_desc))
      return read_memory_integer (frame->frame - 8, 8);
***************
*** 457,463 ****
  
  
  static struct alpha_extra_func_info temp_proc_desc;
! static struct frame_saved_regs temp_saved_regs;
  
  /* Nonzero if instruction at PC is a return instruction.  "ret
     $zero,($ra),1" on alpha. */
--- 475,481 ----
  
  
  static struct alpha_extra_func_info temp_proc_desc;
! static CORE_ADDR temp_saved_regs[NUM_REGS];
  
  /* Nonzero if instruction at PC is a return instruction.  "ret
     $zero,($ra),1" on alpha. */
***************
*** 541,547 ****
    if (start_pc == 0)
      return NULL;
    memset (&temp_proc_desc, '\0', sizeof (temp_proc_desc));
!   memset (&temp_saved_regs, '\0', sizeof (struct frame_saved_regs));
    PROC_LOW_ADDR (&temp_proc_desc) = start_pc;
  
    if (start_pc + 200 < limit_pc)
--- 559,565 ----
    if (start_pc == 0)
      return NULL;
    memset (&temp_proc_desc, '\0', sizeof (temp_proc_desc));
!   memset (&temp_saved_regs, '\0', SIZEOF_FRAME_SAVED_REGS);
    PROC_LOW_ADDR (&temp_proc_desc) = start_pc;
  
    if (start_pc + 200 < limit_pc)
***************
*** 573,579 ****
  	{
  	  int reg = (word & 0x03e00000) >> 21;
  	  reg_mask |= 1 << reg;
! 	  temp_saved_regs.regs[reg] = sp + (short) word;
  
  	  /* Starting with OSF/1-3.2C, the system libraries are shipped
  	     without local symbols, but they still contain procedure
--- 591,597 ----
  	{
  	  int reg = (word & 0x03e00000) >> 21;
  	  reg_mask |= 1 << reg;
! 	  temp_saved_regs[reg] = sp + (short) word;
  
  	  /* Starting with OSF/1-3.2C, the system libraries are shipped
  	     without local symbols, but they still contain procedure
***************
*** 858,881 ****
        + PROC_FRAME_OFFSET (proc_desc);
  }
  
  void
! init_extra_frame_info (struct frame_info *frame)
  {
    /* Use proc_desc calculated in frame_chain */
    alpha_extra_func_info_t proc_desc =
    frame->next ? cached_proc_desc : find_proc_desc (frame->pc, frame->next);
  
    frame->saved_regs = NULL;
!   frame->localoff = 0;
!   frame->pc_reg = RA_REGNUM;
!   frame->proc_desc = proc_desc == &temp_proc_desc ? 0 : proc_desc;
    if (proc_desc)
      {
        /* Get the locals offset and the saved pc register from the
           procedure descriptor, they are valid even if we are in the
           middle of the prologue.  */
!       frame->localoff = PROC_LOCALOFF (proc_desc);
!       frame->pc_reg = PROC_PC_REG (proc_desc);
  
        /* Fixup frame-pointer - only needed for top frame */
  
--- 876,914 ----
        + PROC_FRAME_OFFSET (proc_desc);
  }
  
+ void
+ alpha_print_extra_frame_info (struct frame_info *fi)
+ {
+   if (fi
+       && fi->extra_info
+       && fi->extra_info->proc_desc
+       && fi->extra_info->proc_desc->pdr.framereg < NUM_REGS)
+     printf_filtered (" frame pointer is at %s+%s\n",
+ 		     REGISTER_NAME (fi->extra_info->proc_desc->pdr.framereg),
+ 		     paddr_d (fi->extra_info->proc_desc->pdr.frameoffset));
+ }
+ 
  void
! alpha_init_extra_frame_info (int fromleaf, struct frame_info *frame)
  {
    /* Use proc_desc calculated in frame_chain */
    alpha_extra_func_info_t proc_desc =
    frame->next ? cached_proc_desc : find_proc_desc (frame->pc, frame->next);
  
+   frame->extra_info = (struct frame_extra_info *)
+     frame_obstack_alloc (sizeof (struct frame_extra_info));
+ 
    frame->saved_regs = NULL;
!   frame->extra_info->localoff = 0;
!   frame->extra_info->pc_reg = RA_REGNUM;
!   frame->extra_info->proc_desc = proc_desc == &temp_proc_desc ? 0 : proc_desc;
    if (proc_desc)
      {
        /* Get the locals offset and the saved pc register from the
           procedure descriptor, they are valid even if we are in the
           middle of the prologue.  */
!       frame->extra_info->localoff = PROC_LOCALOFF (proc_desc);
!       frame->extra_info->pc_reg = PROC_PC_REG (proc_desc);
  
        /* Fixup frame-pointer - only needed for top frame */
  
***************
*** 907,913 ****
  	    {
  	      frame->saved_regs = (CORE_ADDR *)
  		frame_obstack_alloc (SIZEOF_FRAME_SAVED_REGS);
! 	      memcpy (frame->saved_regs, temp_saved_regs.regs, SIZEOF_FRAME_SAVED_REGS);
  	      frame->saved_regs[PC_REGNUM]
  		= frame->saved_regs[RA_REGNUM];
  	    }
--- 940,947 ----
  	    {
  	      frame->saved_regs = (CORE_ADDR *)
  		frame_obstack_alloc (SIZEOF_FRAME_SAVED_REGS);
! 	      memcpy (frame->saved_regs, temp_saved_regs,
! 	              SIZEOF_FRAME_SAVED_REGS);
  	      frame->saved_regs[PC_REGNUM]
  		= frame->saved_regs[RA_REGNUM];
  	    }
***************
*** 915,920 ****
--- 949,966 ----
      }
  }
  
+ CORE_ADDR
+ alpha_frame_locals_address (struct frame_info *fi)
+ {
+   return (fi->frame - fi->extra_info->localoff);
+ }
+ 
+ CORE_ADDR
+ alpha_frame_args_address (struct frame_info *fi)
+ {
+   return (fi->frame - (ALPHA_NUM_ARG_REGS * 8));
+ }
+ 
  /* ALPHA stack frames are almost impenetrable.  When execution stops,
     we basically have to look at symbol information for the function
     that we stopped in, which tells us *which* register (if any) is
***************
*** 1154,1160 ****
    struct frame_info *frame = get_current_frame ();
    CORE_ADDR new_sp = frame->frame;
  
!   alpha_extra_func_info_t proc_desc = frame->proc_desc;
  
    /* we need proc_desc to know how to restore the registers;
       if it is NULL, construct (a temporary) one */
--- 1200,1206 ----
    struct frame_info *frame = get_current_frame ();
    CORE_ADDR new_sp = frame->frame;
  
!   alpha_extra_func_info_t proc_desc = frame->extra_info->proc_desc;
  
    /* we need proc_desc to know how to restore the registers;
       if it is NULL, construct (a temporary) one */
Index: config/alpha/tm-alpha.h
===================================================================
RCS file: /cvs/src/src/gdb/config/alpha/tm-alpha.h,v
retrieving revision 1.10
diff -c -r1.10 tm-alpha.h
*** tm-alpha.h	2002/01/19 05:26:47	1.10
--- tm-alpha.h	2002/01/19 06:29:59
***************
*** 276,284 ****
  
  #define ALPHA_NUM_ARG_REGS	6
  
! #define FRAME_ARGS_ADDRESS(fi)	((fi)->frame - (ALPHA_NUM_ARG_REGS * 8))
  
! #define FRAME_LOCALS_ADDRESS(fi) ((fi)->frame - (fi)->localoff)
  
  /* Return number of args passed to a frame.
     Can return -1, meaning no way to tell.  */
--- 276,286 ----
  
  #define ALPHA_NUM_ARG_REGS	6
  
! #define FRAME_ARGS_ADDRESS(fi) alpha_frame_args_address ((fi))
! extern CORE_ADDR alpha_frame_args_address (struct frame_info *);
  
! #define FRAME_LOCALS_ADDRESS(fi) alpha_frame_locals_address ((fi))
! extern CORE_ADDR alpha_frame_locals_address (struct frame_info *);
  
  /* Return number of args passed to a frame.
     Can return -1, meaning no way to tell.  */
***************
*** 295,308 ****
     ways in the stack frame.  sp is even more special:
     the address we return for it IS the sp for the next frame.  */
  
- extern void alpha_find_saved_regs (struct frame_info *);
- 
  #define FRAME_INIT_SAVED_REGS(frame_info) \
!   do { \
!     if ((frame_info)->saved_regs == NULL) \
!       alpha_find_saved_regs (frame_info); \
!     (frame_info)->saved_regs[SP_REGNUM] = (frame_info)->frame; \
!   } while (0)
  
  
  /* Things needed for making the inferior call functions.  */
--- 297,305 ----
     ways in the stack frame.  sp is even more special:
     the address we return for it IS the sp for the next frame.  */
  
  #define FRAME_INIT_SAVED_REGS(frame_info) \
!   alpha_frame_init_saved_regs (frame_info)
! extern void alpha_frame_init_saved_regs (struct frame_info *);
  
  
  /* Things needed for making the inferior call functions.  */
***************
*** 391,411 ****
  #define mips_extra_func_info alpha_extra_func_info
  #define mips_extra_func_info_t alpha_extra_func_info_t
  
! #define EXTRA_FRAME_INFO \
!   int localoff; \
!   int pc_reg; \
!   alpha_extra_func_info_t proc_desc;
! 
! #define INIT_EXTRA_FRAME_INFO(fromleaf, fci) init_extra_frame_info(fci)
! extern void init_extra_frame_info (struct frame_info *);
! 
! #define	PRINT_EXTRA_FRAME_INFO(fi) \
!   { \
!     if (fi && fi->proc_desc && fi->proc_desc->pdr.framereg < NUM_REGS) \
!       printf_filtered (" frame pointer is at %s+%ld\n", \
!                        REGISTER_NAME (fi->proc_desc->pdr.framereg), \
!                                  fi->proc_desc->pdr.frameoffset); \
!   }
  
  /* It takes two values to specify a frame on the ALPHA.  Sigh.
  
--- 388,401 ----
  #define mips_extra_func_info alpha_extra_func_info
  #define mips_extra_func_info_t alpha_extra_func_info_t
  
! 
! #define INIT_EXTRA_FRAME_INFO(fromleaf, fci) \
!   alpha_init_extra_frame_info(fromleaf, fci)
! extern void alpha_init_extra_frame_info (int, struct frame_info *);
! 
! #define PRINT_EXTRA_FRAME_INFO(fi) alpha_print_extra_frame_info ((fi))
! extern void alpha_print_extra_frame_info (struct frame_info *);
! 
  
  /* It takes two values to specify a frame on the ALPHA.  Sigh.
  


More information about the Gdb-patches mailing list