This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
PA return2.exp fix
- From: law at redhat dot com
- To: gdb-patches at sources dot redhat dot com
- Date: Wed, 19 Dec 2001 13:21:49 -0700
- Subject: PA return2.exp fix
- Reply-to: law at redhat dot com
For the record, this is the patch that I actually checked in.
* 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.
Index: hppa-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/hppa-tdep.c,v
retrieving revision 1.17
diff -c -3 -p -r1.17 hppa-tdep.c
*** hppa-tdep.c 2001/10/24 02:53:48 1.17
--- hppa-tdep.c 2001/12/19 20:20:28
*************** _initialize_hppa_tdep (void)
*** 4680,4682 ****
--- 4680,4732 ----
"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));
+ }
Index: config/pa/tm-hppa.h
===================================================================
RCS file: /cvs/src/src/gdb/config/pa/tm-hppa.h,v
retrieving revision 1.9
diff -c -3 -p -r1.9 tm-hppa.h
*** tm-hppa.h 2001/05/12 03:18:34 1.9
--- tm-hppa.h 2001/12/19 20:20:36
*************** extern void pa_do_strcat_registers_info
*** 316,343 ****
/* 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. */
-
#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)); \
! }
-
/* elz: decide whether the function returning a value of type type
will put it on the stack or in the registers.
The pa calling convention says that:
--- 316,326 ----
/* 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. */
#define EXTRACT_RETURN_VALUE(TYPE,REGBUF,VALBUF) \
! 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.
The pa calling convention says that:
*************** extern use_struct_convention_fn hppa_use
*** 353,372 ****
#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. */
#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))
/* Extract from an array REGBUF containing the (raw) register state
the address in which a function should return its structure value,
--- 336,345 ----
#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. */
#define STORE_RETURN_VALUE(TYPE,VALBUF) \
! 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,