From 1cdb71fe7e3a2a6b0484c98d52e4b6f41081750d Mon Sep 17 00:00:00 2001 From: Jeff Law Date: Wed, 19 Dec 2001 20:21:43 +0000 Subject: [PATCH] * config/pa/tm-hppa.h (STORE_RETURN_VALUE): Use hppa_store_return_value. (EXTRACT_RETURN_VALUE): Similarly. * hppa-tdep.c (hppa_store_return_value): New function. (hppa_extract_return_value): New function. --- gdb/ChangeLog | 7 +++++- gdb/config/pa/tm-hppa.h | 35 ++++------------------------- gdb/hppa-tdep.c | 50 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 60 insertions(+), 32 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 69fa7641fc..9091a60894 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,6 +1,11 @@ Wed Dec 19 12:18:57 2001 Jeffrey A Law (law@redhat.com) - * infttrate.c (child_acknowledge_created_inferior): Pass + * config/pa/tm-hppa.h (STORE_RETURN_VALUE): Use hppa_store_return_value. + (EXTRACT_RETURN_VALUE): Similarly. + * hppa-tdep.c (hppa_store_return_value): New function. + (hppa_extract_return_value): New function. + + * infttrace.c (child_acknowledge_created_inferior): Pass correct argument to add_thread. (update_thread_state_after_attach): Likewise. diff --git a/gdb/config/pa/tm-hppa.h b/gdb/config/pa/tm-hppa.h index c3c320ee46..9e4b3466f0 100644 --- a/gdb/config/pa/tm-hppa.h +++ b/gdb/config/pa/tm-hppa.h @@ -316,27 +316,10 @@ extern void pa_do_strcat_registers_info (int, int, struct ui_file *, enum precis /* Extract from an array REGBUF containing the (raw) register state a function return value of type TYPE, and copy that, in virtual format, - into VALBUF. - - elz: changed what to return when length is > 4: the stored result is - in register 28 and in register 29, with the lower order word being in reg 29, - so we must start reading it from somehere in the middle of reg28 - - FIXME: Not sure what to do for soft float here. */ + into VALBUF. */ #define EXTRACT_RETURN_VALUE(TYPE,REGBUF,VALBUF) \ - { \ - if (TYPE_CODE (TYPE) == TYPE_CODE_FLT && !SOFT_FLOAT) \ - memcpy ((VALBUF), \ - ((char *)(REGBUF)) + REGISTER_BYTE (FP4_REGNUM), \ - TYPE_LENGTH (TYPE)); \ - else \ - memcpy ((VALBUF), \ - (char *)(REGBUF) + REGISTER_BYTE (28) + \ - (TYPE_LENGTH (TYPE) > 4 ? (8 - TYPE_LENGTH (TYPE)) : (4 - TYPE_LENGTH (TYPE))), \ - TYPE_LENGTH (TYPE)); \ - } - + hppa_extract_return_value (TYPE, REGBUF, VALBUF); /* elz: decide whether the function returning a value of type type will put it on the stack or in the registers. @@ -353,20 +336,10 @@ extern use_struct_convention_fn hppa_use_struct_convention; #define USE_STRUCT_CONVENTION(gcc_p,type) hppa_use_struct_convention (gcc_p,type) /* Write into appropriate registers a function return value - of type TYPE, given in virtual format. - - For software floating point the return value goes into the integer - registers. But we don't have any flag to key this on, so we always - store the value into the integer registers, and if it's a float value, - then we put it in the float registers too. */ + of type TYPE, given in virtual format. */ #define STORE_RETURN_VALUE(TYPE,VALBUF) \ - write_register_bytes (REGISTER_BYTE (28),(VALBUF), TYPE_LENGTH (TYPE)) ; \ - if (!SOFT_FLOAT) \ - write_register_bytes ((TYPE_CODE(TYPE) == TYPE_CODE_FLT \ - ? REGISTER_BYTE (FP4_REGNUM) \ - : REGISTER_BYTE (28)), \ - (VALBUF), TYPE_LENGTH (TYPE)) + hppa_store_return_value (TYPE, VALBUF); /* Extract from an array REGBUF containing the (raw) register state the address in which a function should return its structure value, diff --git a/gdb/hppa-tdep.c b/gdb/hppa-tdep.c index 3806be2956..af72d8c4f7 100644 --- a/gdb/hppa-tdep.c +++ b/gdb/hppa-tdep.c @@ -4680,3 +4680,53 @@ _initialize_hppa_tdep (void) "Print unwind table entry at given address.", &maintenanceprintlist); } + +/* Copy the function value from VALBUF into the proper location + for a function return. + + Called only in the context of the "return" command. */ + +void +hppa_store_return_value (struct type *type, char *valbuf) +{ + /* For software floating point, the return value goes into the + integer registers. But we do not have any flag to key this on, + so we always store the value into the integer registers. + + If its a float value, then we also store it into the floating + point registers. */ + write_register_bytes (REGISTER_BYTE (28) + + (TYPE_LENGTH (type) > 4 + ? (8 - TYPE_LENGTH (type)) + : (4 - TYPE_LENGTH (type))), + valbuf, + TYPE_LENGTH (type)); + if (! SOFT_FLOAT && TYPE_CODE (type) == TYPE_CODE_FLT) + write_register_bytes (REGISTER_BYTE (FP4_REGNUM), + valbuf, + TYPE_LENGTH (type)); +} + +/* Copy the function's return value into VALBUF. + + This function is called only in the context of "target function calls", + ie. when the debugger forces a function to be called in the child, and + when the debugger forces a fucntion to return prematurely via the + "return" command. */ + +void +hppa_extract_return_value (struct type *type, char *regbuf, char *valbuf) +{ + if (! SOFT_FLOAT && TYPE_CODE (type) == TYPE_CODE_FLT) + memcpy (valbuf, + (char *)regbuf + REGISTER_BYTE (FP4_REGNUM), + TYPE_LENGTH (type)); + else + memcpy (valbuf, + ((char *)regbuf + + REGISTER_BYTE (28) + + (TYPE_LENGTH (type) > 4 + ? (8 - TYPE_LENGTH (type)) + : (4 - TYPE_LENGTH (type)))), + TYPE_LENGTH (type)); +} -- 2.34.1