This is the mail archive of the gdb-patches@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] mips gdbarch-ification


Gdbarch-ify REGISTER_CONVERTIBLE, REGISTER_CONVERT_TO_VIRTUAL, 
REGISTER_CONVERT_TO_RAW, MAX_REGISTER_VIRTUAL_SIZE, and
MAX_REGISTER_RAW_SIZE.  Checked in as obvious.
2002-08-15  Michael Snyder  <msnyder@redhat.com>

	* config/mips/tm-mips.h (REGISTER_CONVERT_TO_VIRTUAL, 
	REGISTER_CONVERT_TO_RAW, REGISTER_CONVERTIBLE, 
	MAX_REGISTER_RAW_SIZE, MAX_REGISTER_VIRTUAL_SIZE): Delete.
	* mips-tdep.c (mips_gdbarch_init): Set the above in the gdbarch.
	(mips_register_convertible, mips_register_convert_to_virtual,
	mips_register_convert_to_raw): Make static.

Index: mips-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/mips-tdep.c,v
retrieving revision 1.101
diff -c -3 -p -r1.101 mips-tdep.c
*** mips-tdep.c	14 Aug 2002 19:17:39 -0000	1.101
--- mips-tdep.c	16 Aug 2002 01:17:14 -0000
*************** mips_register_raw_size (int reg_nr)
*** 439,445 ****
  /* Convert between RAW and VIRTUAL registers.  The RAW register size
     defines the remote-gdb packet. */
  
! int
  mips_register_convertible (int reg_nr)
  {
    if (mips64_transfers_32bit_regs_p)
--- 439,445 ----
  /* Convert between RAW and VIRTUAL registers.  The RAW register size
     defines the remote-gdb packet. */
  
! static int
  mips_register_convertible (int reg_nr)
  {
    if (mips64_transfers_32bit_regs_p)
*************** mips_register_convertible (int reg_nr)
*** 448,454 ****
      return (REGISTER_RAW_SIZE (reg_nr) > REGISTER_VIRTUAL_SIZE (reg_nr));
  }
  
! void
  mips_register_convert_to_virtual (int n, struct type *virtual_type,
  				  char *raw_buf, char *virt_buf)
  {
--- 448,454 ----
      return (REGISTER_RAW_SIZE (reg_nr) > REGISTER_VIRTUAL_SIZE (reg_nr));
  }
  
! static void
  mips_register_convert_to_virtual (int n, struct type *virtual_type,
  				  char *raw_buf, char *virt_buf)
  {
*************** mips_register_convert_to_virtual (int n,
*** 462,468 ****
  	    TYPE_LENGTH (virtual_type));
  }
  
! void
  mips_register_convert_to_raw (struct type *virtual_type, int n,
  			      char *virt_buf, char *raw_buf)
  {
--- 462,468 ----
  	    TYPE_LENGTH (virtual_type));
  }
  
! static void
  mips_register_convert_to_raw (struct type *virtual_type, int n,
  			      char *virt_buf, char *raw_buf)
  {
*************** mips_register_virtual_type (int reg)
*** 513,518 ****
--- 513,526 ----
      }
  }
  
+ /* TARGET_READ_SP -- Remove useless bits from the stack pointer.  */
+ 
+ static CORE_ADDR
+ mips_read_sp (void)
+ {
+   return ADDR_BITS_REMOVE (read_register (SP_REGNUM));
+ }
+ 
  /* Should the upper word of 64-bit addresses be zeroed? */
  enum auto_boolean mask_address_var = AUTO_BOOLEAN_AUTO;
  
*************** mips_frame_chain (struct frame_info *fra
*** 2294,2302 ****
       we loop forever if we see a zero size frame.  */
    if (PROC_FRAME_REG (proc_desc) == SP_REGNUM
        && PROC_FRAME_OFFSET (proc_desc) == 0
!   /* The previous frame from a sigtramp frame might be frameless
!      and have frame size zero.  */
!       && !frame->signal_handler_caller)
      return 0;
    else
      return get_frame_pointer (frame, proc_desc);
--- 2302,2312 ----
       we loop forever if we see a zero size frame.  */
    if (PROC_FRAME_REG (proc_desc) == SP_REGNUM
        && PROC_FRAME_OFFSET (proc_desc) == 0
!       /* The previous frame from a sigtramp frame might be frameless
! 	 and have frame size zero.  */
!       && !frame->signal_handler_caller
!       /* Check if this is a call dummy frame.  */
!       && frame->pc != mips_call_dummy_address ())
      return 0;
    else
      return get_frame_pointer (frame, proc_desc);
*************** mips_o32o64_push_arguments (int nargs,
*** 2959,2965 ****
    argreg = A0_REGNUM;
    float_argreg = FPA0_REGNUM;
  
!   /* the struct_return pointer occupies the first parameter-passing reg */
    if (struct_return)
      {
        if (mips_debug)
--- 2969,2975 ----
    argreg = A0_REGNUM;
    float_argreg = FPA0_REGNUM;
  
!   /* The struct_return pointer occupies the first parameter-passing reg.  */
    if (struct_return)
      {
        if (mips_debug)
*************** mips_pop_frame (void)
*** 3346,3358 ****
    if (frame->saved_regs == NULL)
      FRAME_INIT_SAVED_REGS (frame);
    for (regnum = 0; regnum < NUM_REGS; regnum++)
!     {
!       if (regnum != SP_REGNUM && regnum != PC_REGNUM
! 	  && frame->saved_regs[regnum])
! 	write_register (regnum,
! 			read_memory_integer (frame->saved_regs[regnum],
! 					     MIPS_SAVED_REGSIZE));
!     }
    write_register (SP_REGNUM, new_sp);
    flush_cached_frames ();
  
--- 3356,3377 ----
    if (frame->saved_regs == NULL)
      FRAME_INIT_SAVED_REGS (frame);
    for (regnum = 0; regnum < NUM_REGS; regnum++)
!     if (regnum != SP_REGNUM && regnum != PC_REGNUM
! 	&& frame->saved_regs[regnum])
!       {
! 	/* Floating point registers must not be sign extended, 
! 	   in case MIPS_SAVED_REGSIZE = 4 but sizeof (FP0_REGNUM) == 8.  */
! 
! 	if (FP0_REGNUM <= regnum && regnum < FP0_REGNUM + 32)
! 	  write_register (regnum,
! 			  read_memory_unsigned_integer (frame->saved_regs[regnum],
! 							MIPS_SAVED_REGSIZE));
! 	else
! 	  write_register (regnum,
! 			  read_memory_integer (frame->saved_regs[regnum],
! 					       MIPS_SAVED_REGSIZE));
!       }
! 
    write_register (SP_REGNUM, new_sp);
    flush_cached_frames ();
  
*************** return_value_location (struct type *valt
*** 4079,4093 ****
        if (TARGET_BYTE_ORDER == BFD_ENDIAN_BIG
  	  && len < MIPS_SAVED_REGSIZE)
  	{
! 	  /* "un-left-justify" the value in the low register */
! 	  lo->reg_offset = MIPS_SAVED_REGSIZE - len;
! 	  lo->len = len;
  	  hi->reg_offset = 0;
  	  hi->len = 0;
  	}
        else if (TARGET_BYTE_ORDER == BFD_ENDIAN_BIG
  	       && len > MIPS_SAVED_REGSIZE	/* odd-size structs */
  	       && len < MIPS_SAVED_REGSIZE * 2
  	       && (TYPE_CODE (valtype) == TYPE_CODE_STRUCT ||
  		   TYPE_CODE (valtype) == TYPE_CODE_UNION))
  	{
--- 4098,4125 ----
        if (TARGET_BYTE_ORDER == BFD_ENDIAN_BIG
  	  && len < MIPS_SAVED_REGSIZE)
  	{
! 	  if ((gdbarch_tdep (current_gdbarch) -> mips_abi == MIPS_ABI_N32 
! 	       || gdbarch_tdep (current_gdbarch) -> mips_abi == MIPS_ABI_N64)
! 	      && (TYPE_CODE (valtype) == TYPE_CODE_STRUCT 
! 		  || TYPE_CODE (valtype) == TYPE_CODE_UNION))
! 	    {
! 	      /* Values are already aligned in the low register.  */
! 	      lo->reg_offset = 0;
! 	    }
! 	  else
! 	    {
! 	      /* "un-left-justify" the value in the low register */
! 	      lo->reg_offset = MIPS_SAVED_REGSIZE - len;
! 	    }
  	  hi->reg_offset = 0;
+ 	  lo->len = len;
  	  hi->len = 0;
  	}
        else if (TARGET_BYTE_ORDER == BFD_ENDIAN_BIG
  	       && len > MIPS_SAVED_REGSIZE	/* odd-size structs */
  	       && len < MIPS_SAVED_REGSIZE * 2
+ 	       && gdbarch_tdep (current_gdbarch) -> mips_abi != MIPS_ABI_N32 
+ 	       && gdbarch_tdep (current_gdbarch) -> mips_abi != MIPS_ABI_N64
  	       && (TYPE_CODE (valtype) == TYPE_CODE_STRUCT ||
  		   TYPE_CODE (valtype) == TYPE_CODE_UNION))
  	{
*************** mips_gdbarch_init (struct gdbarch_info i
*** 4925,4930 ****
--- 4957,4963 ----
  	}
      }
  
+ #undef MIPS_DEFAULT_ABI
  #ifdef MIPS_DEFAULT_ABI
    if (mips_abi == MIPS_ABI_UNKNOWN)
      mips_abi = MIPS_DEFAULT_ABI;
*************** mips_gdbarch_init (struct gdbarch_info i
*** 4981,4986 ****
--- 5014,5021 ----
    set_gdbarch_double_bit (gdbarch, 64);
    set_gdbarch_long_double_bit (gdbarch, 64);
    set_gdbarch_register_raw_size (gdbarch, mips_register_raw_size);
+   set_gdbarch_max_register_raw_size (gdbarch, 8);
+   set_gdbarch_max_register_virtual_size (gdbarch, 8);
    tdep->found_abi = found_abi;
    tdep->mips_abi = mips_abi;
  
*************** mips_gdbarch_init (struct gdbarch_info i
*** 5168,5174 ****
    set_gdbarch_read_pc (gdbarch, mips_read_pc);
    set_gdbarch_write_pc (gdbarch, generic_target_write_pc);
    set_gdbarch_read_fp (gdbarch, generic_target_read_fp);
!   set_gdbarch_read_sp (gdbarch, generic_target_read_sp);
    set_gdbarch_write_sp (gdbarch, generic_target_write_sp);
  
    /* Add/remove bits from an address. The MIPS needs be careful to
--- 5203,5209 ----
    set_gdbarch_read_pc (gdbarch, mips_read_pc);
    set_gdbarch_write_pc (gdbarch, generic_target_write_pc);
    set_gdbarch_read_fp (gdbarch, generic_target_read_fp);
!   set_gdbarch_read_sp (gdbarch, mips_read_sp);
    set_gdbarch_write_sp (gdbarch, generic_target_write_sp);
  
    /* Add/remove bits from an address. The MIPS needs be careful to
*************** mips_gdbarch_init (struct gdbarch_info i
*** 5204,5209 ****
--- 5239,5249 ----
    set_gdbarch_sizeof_call_dummy_words (gdbarch, sizeof (mips_call_dummy_words));
    set_gdbarch_push_return_address (gdbarch, mips_push_return_address);
    set_gdbarch_register_convertible (gdbarch, generic_register_convertible_not);
+   set_gdbarch_register_convert_to_virtual (gdbarch, 
+ 					   mips_register_convert_to_virtual);
+   set_gdbarch_register_convert_to_raw (gdbarch, 
+ 				       mips_register_convert_to_raw);
+ 
    set_gdbarch_coerce_float_to_double (gdbarch, mips_coerce_float_to_double);
  
    set_gdbarch_frame_chain_valid (gdbarch, func_frame_chain_valid);
Index: config/mips/tm-mips.h
===================================================================
RCS file: /cvs/src/src/gdb/config/mips/tm-mips.h,v
retrieving revision 1.31
diff -c -3 -p -r1.31 tm-mips.h
*** config/mips/tm-mips.h	10 Aug 2002 01:09:11 -0000	1.31
--- config/mips/tm-mips.h	16 Aug 2002 01:17:14 -0000
*************** extern void mips_do_registers_info (int,
*** 161,198 ****
  
  #define REGISTER_BYTE(N) ((N) * MIPS_REGSIZE)
  
- /* Covert between the RAW and VIRTUAL registers.
- 
-    Some MIPS (SR, FSR, FIR) have a `raw' size of MIPS_REGSIZE but are
-    really 32 bit registers.  This is a legacy of the 64 bit MIPS GDB
-    protocol which transfers 64 bits for 32 bit registers. */
- 
- extern int mips_register_convertible (int reg_nr);
- #define REGISTER_CONVERTIBLE(N) (mips_register_convertible ((N)))
-      
- 
- void mips_register_convert_to_virtual (int reg_nr, struct type *virtual_type,
- 				       char *raw_buf, char *virt_buf);
- #define REGISTER_CONVERT_TO_VIRTUAL(N,VIRTUAL_TYPE,RAW_BUF,VIRT_BUF) \
-   mips_register_convert_to_virtual (N,VIRTUAL_TYPE,RAW_BUF,VIRT_BUF)
- 
- void mips_register_convert_to_raw (struct type *virtual_type, int reg_nr,
- 				   char *virt_buf, char *raw_buf);
- #define REGISTER_CONVERT_TO_RAW(VIRTUAL_TYPE,N,VIRT_BUF,RAW_BUF) \
-   mips_register_convert_to_raw (VIRTUAL_TYPE,N,VIRT_BUF,RAW_BUF)
- 
  /* Number of bytes of storage in the program's representation
     for register N. */
  
  #define REGISTER_VIRTUAL_SIZE(N) TYPE_LENGTH (REGISTER_VIRTUAL_TYPE (N))
- 
- /* Largest value REGISTER_RAW_SIZE can have.  */
- 
- #define MAX_REGISTER_RAW_SIZE 8
- 
- /* Largest value REGISTER_VIRTUAL_SIZE can have.  */
- 
- #define MAX_REGISTER_VIRTUAL_SIZE 8
  
  /* Return the GDB type object for the "standard" data type of data in
     register N.  */
--- 161,170 ----

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]