[RFA] update alpha return value hooks to regcache

Richard Henderson rth@twiddle.net
Mon Jun 2 05:26:00 GMT 2003


Ok?


r~


	* alpha-tdep.c (alpha_extract_return_value): Convert to regcache.
	(alpha_extract_struct_value_address): Likewise.
	(alpha_store_return_value): Likewise.
	(alpha_store_struct_return): Remove.
	(alpha_gdbarch_init): Update hook registration to match.

*** alpha-tdep.c.2	Sun Jun  1 21:59:13 2003
--- alpha-tdep.c	Sun Jun  1 22:13:30 2003
*************** alpha_push_dummy_call (struct gdbarch *g
*** 377,418 ****
    return sp;
  }
  
! /* Given a return value in `regbuf' with a type `valtype', 
!    extract and copy its value into `valbuf'.  */
  
  static void
! alpha_extract_return_value (struct type *valtype,
! 			    char regbuf[ALPHA_REGISTER_BYTES], char *valbuf)
  {
!   if (TYPE_CODE (valtype) == TYPE_CODE_FLT)
!     alpha_register_convert_to_virtual (FP0_REGNUM, valtype,
! 				       regbuf + REGISTER_BYTE (FP0_REGNUM),
! 				       valbuf);
!   else
!     memcpy (valbuf, regbuf + REGISTER_BYTE (ALPHA_V0_REGNUM),
!             TYPE_LENGTH (valtype));
  }
  
! /* Given a return value in `regbuf' with a type `valtype', 
!    write its value into the appropriate register.  */
  
  static void
! alpha_store_return_value (struct type *valtype, char *valbuf)
  {
-   char raw_buffer[ALPHA_REGISTER_SIZE];
-   int regnum = ALPHA_V0_REGNUM;
    int length = TYPE_LENGTH (valtype);
  
!   if (TYPE_CODE (valtype) == TYPE_CODE_FLT)
      {
!       regnum = FP0_REGNUM;
!       length = ALPHA_REGISTER_SIZE;
!       alpha_register_convert_to_raw (valtype, regnum, valbuf, raw_buffer);
!     }
!   else
!     memcpy (raw_buffer, valbuf, length);
  
!   deprecated_write_register_bytes (REGISTER_BYTE (regnum), raw_buffer, length);
  }
  
  static int
--- 377,466 ----
    return sp;
  }
  
! /* Extract from REGCACHE the value about to be returned from a function
!    and copy it into VALBUF.  */
  
  static void
! alpha_extract_return_value (struct type *valtype, struct regcache *regcache,
! 			    void *valbuf)
  {
!   char raw_buffer[ALPHA_REGISTER_SIZE];
!   ULONGEST l;
! 
!   switch (TYPE_CODE (valtype))
!     {
!     case TYPE_CODE_FLT:
!       switch (TYPE_LENGTH (valtype))
! 	{
! 	case 4:
! 	  regcache_cooked_read (regcache, ALPHA_FP0_REGNUM, raw_buffer);
! 	  alpha_convert_dbl_flt (valbuf, raw_buffer);
! 	  break;
! 
! 	case 8:
! 	  regcache_cooked_read (regcache, ALPHA_FP0_REGNUM, valbuf);
! 	  break;
! 
! 	default:
! 	  abort ();
! 	}
!       break;
! 
!     default:
!       /* Assume everything else degenerates to an integer.  */
!       regcache_cooked_read_unsigned (regcache, ALPHA_V0_REGNUM, &l);
!       store_unsigned_integer (valbuf, TYPE_LENGTH (valtype), l);
!       break;
!     }
! }
! 
! /* Extract from REGCACHE the address of a structure about to be returned
!    from a function.  */
! 
! static CORE_ADDR
! alpha_extract_struct_value_address (struct regcache *regcache)
! {
!   ULONGEST addr;
!   regcache_cooked_read_unsigned (regcache, ALPHA_V0_REGNUM, &addr);
!   return addr;
  }
  
! /* Insert the given value into REGCACHE as if it was being 
!    returned by a function.  */
  
  static void
! alpha_store_return_value (struct type *valtype, struct regcache *regcache,
! 			  const void *valbuf)
  {
    int length = TYPE_LENGTH (valtype);
+   char raw_buffer[ALPHA_REGISTER_SIZE];
+   ULONGEST l;
  
!   switch (TYPE_CODE (valtype))
      {
!     case TYPE_CODE_FLT:
!       switch (length)
! 	{
! 	case 4:
! 	  alpha_convert_flt_dbl (raw_buffer, valbuf);
! 	  valbuf = raw_buffer;
! 	  /* FALLTHRU */
! 
! 	case 8:
! 	  regcache_cooked_write (regcache, ALPHA_FP0_REGNUM, valbuf);
! 	  break;
! 
! 	default:
! 	  abort ();
! 	}
!       break;
  
!     default:
!       /* Assume everything else degenerates to an integer.  */
!       l = unpack_long (valtype, valbuf);
!       regcache_cooked_write_unsigned (regcache, ALPHA_V0_REGNUM, l);
!       break;
!     }
  }
  
  static int
*************** alpha_use_struct_convention (int gcc_p, 
*** 422,441 ****
    return 1;
  }
  
- static void
- alpha_store_struct_return (CORE_ADDR addr, CORE_ADDR sp)
- {
-   /* Store the address of the place in which to copy the structure the
-      subroutine will return.  Handled by alpha_push_arguments.  */
- }
- 
- static CORE_ADDR
- alpha_extract_struct_value_address (char *regbuf)
- {
-   return (extract_unsigned_integer (regbuf + REGISTER_BYTE (ALPHA_V0_REGNUM),
- 				    REGISTER_RAW_SIZE (ALPHA_V0_REGNUM)));
- }
- 
  
  static const unsigned char *
  alpha_breakpoint_from_pc (CORE_ADDR *pcptr, int *lenptr)
--- 470,475 ----
*************** alpha_gdbarch_init (struct gdbarch_info 
*** 1325,1334 ****
                                      generic_frameless_function_invocation_not);
  
    set_gdbarch_use_struct_convention (gdbarch, alpha_use_struct_convention);
!   set_gdbarch_deprecated_extract_return_value (gdbarch, alpha_extract_return_value);
!   set_gdbarch_deprecated_store_struct_return (gdbarch, alpha_store_struct_return);
!   set_gdbarch_deprecated_store_return_value (gdbarch, alpha_store_return_value);
!   set_gdbarch_deprecated_extract_struct_value_address (gdbarch,
  					    alpha_extract_struct_value_address);
  
    /* Settings for calling functions in the inferior.  */
--- 1359,1367 ----
                                      generic_frameless_function_invocation_not);
  
    set_gdbarch_use_struct_convention (gdbarch, alpha_use_struct_convention);
!   set_gdbarch_extract_return_value (gdbarch, alpha_extract_return_value);
!   set_gdbarch_store_return_value (gdbarch, alpha_store_return_value);
!   set_gdbarch_extract_struct_value_address (gdbarch,
  					    alpha_extract_struct_value_address);
  
    /* Settings for calling functions in the inferior.  */



More information about the Gdb-patches mailing list