* [RFA] update alpha return value hooks to regcache
@ 2003-06-02 5:26 Richard Henderson
2003-06-02 16:25 ` Mark Kettenis
0 siblings, 1 reply; 5+ messages in thread
From: Richard Henderson @ 2003-06-02 5:26 UTC (permalink / raw)
To: gdb-patches
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)));
- }
-
\f
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. */
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [RFA] update alpha return value hooks to regcache
2003-06-02 5:26 [RFA] update alpha return value hooks to regcache Richard Henderson
@ 2003-06-02 16:25 ` Mark Kettenis
2003-06-02 18:40 ` Andrew Cagney
2003-06-02 20:46 ` Richard Henderson
0 siblings, 2 replies; 5+ messages in thread
From: Mark Kettenis @ 2003-06-02 16:25 UTC (permalink / raw)
To: Richard Henderson; +Cc: gdb-patches
Richard Henderson <rth@twiddle.net> writes:
> 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.
>
Ah, this one's got a flaw. Using abort() isn't allowed in GDB.
Instead use internal_error() which gives the user the option of
continuing at his/her own risk. You could also use gdb_assert()
(which calls internal_error()).
With that change, this is approved.
Mark
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [RFA] update alpha return value hooks to regcache
2003-06-02 16:25 ` Mark Kettenis
@ 2003-06-02 18:40 ` Andrew Cagney
2003-06-02 20:55 ` Richard Henderson
2003-06-02 20:46 ` Richard Henderson
1 sibling, 1 reply; 5+ messages in thread
From: Andrew Cagney @ 2003-06-02 18:40 UTC (permalink / raw)
To: Richard Henderson; +Cc: Mark Kettenis, gdb-patches
> Richard Henderson <rth@twiddle.net> writes:
>
>
>> 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.
>>
>
>
> Ah, this one's got a flaw. Using abort() isn't allowed in GDB.
> Instead use internal_error() which gives the user the option of
> continuing at his/her own risk. You could also use gdb_assert()
> (which calls internal_error()).
>
> With that change, this is approved.
BTW, also:
> ! 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 ();
please avoid the fallthrough.
Andrew
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [RFA] update alpha return value hooks to regcache
2003-06-02 16:25 ` Mark Kettenis
2003-06-02 18:40 ` Andrew Cagney
@ 2003-06-02 20:46 ` Richard Henderson
1 sibling, 0 replies; 5+ messages in thread
From: Richard Henderson @ 2003-06-02 20:46 UTC (permalink / raw)
To: Mark Kettenis; +Cc: gdb-patches
On Mon, Jun 02, 2003 at 06:24:56PM +0200, Mark Kettenis wrote:
> Ah, this one's got a flaw. Using abort() isn't allowed in GDB.
Ok. Addressed like so.
r~
* alpha-tdep.c (alpha_extract_return_value): Use internal_error.
(alpha_store_return_value): Likewise.
Index: alpha-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/alpha-tdep.c,v
retrieving revision 1.102
diff -c -p -d -u -r1.102 alpha-tdep.c
--- alpha-tdep.c 2 Jun 2003 16:18:32 -0000 1.102
+++ alpha-tdep.c 2 Jun 2003 20:37:07 -0000
@@ -438,7 +438,7 @@ alpha_extract_return_value (struct type
break;
default:
- abort ();
+ internal_error (__FILE__, __LINE__, "unknown floating point width");
}
break;
@@ -462,7 +462,7 @@ alpha_extract_return_value (struct type
break;
default:
- abort ();
+ internal_error (__FILE__, __LINE__, "unknown floating point width");
}
break;
@@ -517,7 +517,7 @@ alpha_store_return_value (struct type *v
error ("Cannot set a 128-bit long double return value.");
default:
- abort ();
+ internal_error (__FILE__, __LINE__, "unknown floating point width");
}
break;
@@ -542,7 +542,7 @@ alpha_store_return_value (struct type *v
error ("Cannot set a 128-bit long double return value.");
default:
- abort ();
+ internal_error (__FILE__, __LINE__, "unknown floating point width");
}
break;
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [RFA] update alpha return value hooks to regcache
2003-06-02 18:40 ` Andrew Cagney
@ 2003-06-02 20:55 ` Richard Henderson
0 siblings, 0 replies; 5+ messages in thread
From: Richard Henderson @ 2003-06-02 20:55 UTC (permalink / raw)
To: Andrew Cagney; +Cc: Mark Kettenis, gdb-patches
On Mon, Jun 02, 2003 at 02:40:05PM -0400, Andrew Cagney wrote:
> please avoid the fallthrough.
Done.
r~
* alpha-tdep.c (alpha_store_return_value): Avoid switch fallthru.
Index: alpha-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/alpha-tdep.c,v
retrieving revision 1.103
diff -c -p -d -u -r1.103 alpha-tdep.c
--- alpha-tdep.c 2 Jun 2003 20:46:41 -0000 1.103
+++ alpha-tdep.c 2 Jun 2003 20:47:54 -0000
@@ -503,8 +503,8 @@ alpha_store_return_value (struct type *v
{
case 4:
alpha_convert_flt_dbl (raw_buffer, valbuf);
- valbuf = raw_buffer;
- /* FALLTHRU */
+ regcache_cooked_write (regcache, ALPHA_FP0_REGNUM, raw_buffer);
+ break;
case 8:
regcache_cooked_write (regcache, ALPHA_FP0_REGNUM, valbuf);
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2003-06-02 20:55 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-06-02 5:26 [RFA] update alpha return value hooks to regcache Richard Henderson
2003-06-02 16:25 ` Mark Kettenis
2003-06-02 18:40 ` Andrew Cagney
2003-06-02 20:55 ` Richard Henderson
2003-06-02 20:46 ` Richard Henderson
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox