This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
[commit] value_being_returned -> print_return_value
- From: Andrew Cagney <ac131313 at redhat dot com>
- To: gdb-patches at sources dot redhat dot com
- Date: Wed, 01 Oct 2003 23:58:57 -0400
- Subject: [commit] value_being_returned -> print_return_value
Hello,
This patch moves the bulk of value_being_returned (the struct return
bit) into print_return_value.
With that, value_being_returned's struct_return parameter becomes
redundant. This follows that through by dropping the parameter and
renaming the function to the more exact register_value_being_returned.
committed,
Andrew
2003-10-01 Andrew Cagney <cagney@redhat.com>
* value.h (register_value_being_returned): Declare. Replace
"value_being_returned".
* infcall.c (call_function_by_hand): Use
register_value_being_returned.
* infcmd.c (print_return_value): Call
"register_value_being_returned", handle struct return locally.
* values.c (register_value_being_returned): New function. Replace
"value_being_returned".
Index: infcall.c
===================================================================
RCS file: /cvs/src/src/gdb/infcall.c,v
retrieving revision 1.32
diff -u -r1.32 infcall.c
--- infcall.c 1 Oct 2003 18:48:12 -0000 1.32
+++ infcall.c 2 Oct 2003 03:51:18 -0000
@@ -1101,12 +1101,9 @@
}
else
{
- /* This call to value_being_returned is never made when the
- function uses "struct return convention". Hence, pass "0"
- instead of STRUCT_RETURN. Besides, VALUE_TYPE, in
- combination with RETURN_VALUE() (nee USE_STRUCT_CONVENTION)
- can be used to re-construct the value of STRUCT_RETURN. */
- struct value *retval = value_being_returned (value_type, retbuf, 0);
+ /* The non-register case was handled above. */
+ struct value *retval = register_value_being_returned (value_type,
+ retbuf);
do_cleanups (retbuf_cleanup);
return retval;
}
Index: infcmd.c
===================================================================
RCS file: /cvs/src/src/gdb/infcmd.c,v
retrieving revision 1.94
diff -u -r1.94 infcmd.c
--- infcmd.c 1 Oct 2003 18:48:12 -0000 1.94
+++ infcmd.c 2 Oct 2003 03:51:21 -0000
@@ -1070,7 +1070,7 @@
if (!structure_return)
{
- value = value_being_returned (value_type, stop_registers, 0);
+ value = register_value_being_returned (value_type, stop_registers);
stb = ui_out_stream_new (uiout);
ui_out_text (uiout, "Value returned is ");
ui_out_field_fmt (uiout, "gdb-result-var", "$%d", record_latest_value (value));
@@ -1081,11 +1081,6 @@
}
else
{
- /* FIXME: 2003-09-27: This code block should be handling the
- "use struct convention" case, and not the function
- value_being_returned. This would allow the dramatic
- simplification of value_being_returned (perhaphs renamed to
- register_value_being_returned). */
/* FIXME: 2003-09-27: When returning from a nested inferior
function call, it's possible (with no help from the
architecture vector) to locate and return/print a "struct
@@ -1103,7 +1098,34 @@
ui_out_text (uiout, ".");
ui_out_text (uiout, " Cannot determine contents\n");
#else
- value = value_being_returned (value_type, stop_registers, 1);
+ if (EXTRACT_STRUCT_VALUE_ADDRESS_P ())
+ {
+ CORE_ADDR addr = EXTRACT_STRUCT_VALUE_ADDRESS (stop_registers);
+ if (!addr)
+ error ("Function return value unknown.");
+ value = value_at (value_type, addr, NULL);
+ }
+ else if (DEPRECATED_EXTRACT_STRUCT_VALUE_ADDRESS_P ())
+ {
+ char *buf = deprecated_grub_regcache_for_registers (stop_registers);
+ CORE_ADDR addr = DEPRECATED_EXTRACT_STRUCT_VALUE_ADDRESS (buf);
+ if (!addr)
+ error ("Function return value unknown.");
+ value = value_at (value_type, addr, NULL);
+ }
+ else
+ {
+ /* It is "struct return" yet the value is being extracted,
+ presumably from registers, using EXTRACT_RETURN_VALUE.
+ This doesn't make sense. Unfortunatly, the legacy
+ interfaces allowed this behavior. Sigh! */
+ value = allocate_value (value_type);
+ CHECK_TYPEDEF (value_type);
+ /* If the function returns void, don't bother fetching the
+ return value. */
+ EXTRACT_RETURN_VALUE (value_type, stop_registers,
+ VALUE_CONTENTS_RAW (value));
+ }
stb = ui_out_stream_new (uiout);
ui_out_text (uiout, "Value returned is ");
ui_out_field_fmt (uiout, "gdb-result-var", "$%d", record_latest_value (value));
Index: value.h
===================================================================
RCS file: /cvs/src/src/gdb/value.h,v
retrieving revision 1.52
diff -u -r1.52 value.h
--- value.h 25 Sep 2003 16:39:38 -0000 1.52
+++ value.h 2 Oct 2003 03:51:23 -0000
@@ -416,9 +416,8 @@
extern struct value *value_subscript (struct value *array, struct value *idx);
-extern struct value *value_being_returned (struct type *valtype,
- struct regcache *retbuf,
- int struct_return);
+extern struct value *register_value_being_returned (struct type *valtype,
+ struct regcache *retbuf);
extern struct value *value_in (struct value *element, struct value *set);
Index: values.c
===================================================================
RCS file: /cvs/src/src/gdb/values.c,v
retrieving revision 1.58
diff -u -r1.58 values.c
--- values.c 1 Oct 2003 18:48:12 -0000 1.58
+++ values.c 2 Oct 2003 03:51:27 -0000
@@ -1202,60 +1202,25 @@
return val;
}
-/* Deal with the value that is "about to be returned". */
+/* Deal with the value that is "about to be returned".
-/* Return the value that a function returning now
- would be returning to its caller, assuming its type is VALTYPE.
- RETBUF is where we look for what ought to be the contents
- of the registers (in raw form). This is because it is often
- desirable to restore old values to those registers
- after saving the contents of interest, and then call
- this function using the saved values.
- struct_return is non-zero when the function in question is
- using the structure return conventions on the machine in question;
- 0 when it is using the value returning conventions (this often
- means returning pointer to where structure is vs. returning value). */
-
-/* FIXME: cagney/2003-09-27: Should move the "struct return
- convention" code to the only call site in print_return_value that
- needs it. This function can then be renamed to
- "register_value_being_returned" and with the "struct_return"
- parameter dropped. */
+ Return the value that a function, using the register convention,
+ returning now would be returning to its caller, assuming its type
+ is VALTYPE. RETBUF is where we look for what ought to be the
+ contents of the registers (in raw form). This is because it is
+ often desirable to restore old values to those registers after
+ saving the contents of interest, and then call this function using
+ the saved values. */
struct value *
-value_being_returned (struct type *valtype, struct regcache *retbuf,
- int struct_return)
+register_value_being_returned (struct type *valtype, struct regcache *retbuf)
{
- struct value *val;
- CORE_ADDR addr;
-
- /* If this is not defined, just use EXTRACT_RETURN_VALUE instead. */
- if (EXTRACT_STRUCT_VALUE_ADDRESS_P ())
- if (struct_return)
- {
- addr = EXTRACT_STRUCT_VALUE_ADDRESS (retbuf);
- if (!addr)
- error ("Function return value unknown.");
- return value_at (valtype, addr, NULL);
- }
-
- /* If this is not defined, just use EXTRACT_RETURN_VALUE instead. */
- if (DEPRECATED_EXTRACT_STRUCT_VALUE_ADDRESS_P ())
- if (struct_return)
- {
- char *buf = deprecated_grub_regcache_for_registers (retbuf);
- addr = DEPRECATED_EXTRACT_STRUCT_VALUE_ADDRESS (buf);
- if (!addr)
- error ("Function return value unknown.");
- return value_at (valtype, addr, NULL);
- }
-
- val = allocate_value (valtype);
+ struct value *val = allocate_value (valtype);
CHECK_TYPEDEF (valtype);
- /* If the function returns void, don't bother fetching the return value. */
+ /* If the function returns void, don't bother fetching the return
+ value. */
if (TYPE_CODE (valtype) != TYPE_CODE_VOID)
EXTRACT_RETURN_VALUE (valtype, retbuf, VALUE_CONTENTS_RAW (val));
-
return val;
}