From c48a845bff656d9f07bf53c0004bb0fed62891ae Mon Sep 17 00:00:00 2001 From: Michael Snyder Date: Wed, 30 Jul 2003 20:59:10 +0000 Subject: [PATCH] 2003-07-30 Michael Snyder * structs.h (value_being_returned): Add a struct_addr argument. * infcall.c (call_function_by_hand): Pass struct_addr to value_being_returned. * infcmd.c (print_return_value): Pass zero as struct_addr. * values.c (value_being_returned): If struct_addr is passed, use it instead of trying to recover it from the inferior. --- gdb/ChangeLog | 9 +++++++++ gdb/infcall.c | 10 ++++++---- gdb/infcmd.c | 18 +++++++++++------- gdb/value.h | 3 ++- gdb/values.c | 47 ++++++++++++++++++++++++++--------------------- 5 files changed, 54 insertions(+), 33 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 93baf916a4e..69c2d6b827c 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,12 @@ +2003-07-30 Michael Snyder + + * structs.h (value_being_returned): Add a struct_addr argument. + * infcall.c (call_function_by_hand): Pass struct_addr to + value_being_returned. + * infcmd.c (print_return_value): Pass zero as struct_addr. + * values.c (value_being_returned): If struct_addr is passed, + use it instead of trying to recover it from the inferior. + 2003-07-30 Kevin Buettner * mn10300-tdep.c (analyze_dummy_frame): Pass ``pc'' so that diff --git a/gdb/infcall.c b/gdb/infcall.c index 477fc0f44d6..b00785c119a 100644 --- a/gdb/infcall.c +++ b/gdb/infcall.c @@ -421,7 +421,7 @@ call_function_by_hand (struct value *function, int nargs, struct value **args) vector. Hence this direct call. A follow-on change is to modify this interface so that it takes - thread OR frame OR tpid as a parameter, and returns a dummy + thread OR frame OR ptid as a parameter, and returns a dummy frame handle. The handle can then be used further down as a parameter to generic_save_dummy_frame_tos(). Hmm, thinking about it, since everything is ment to be using generic dummy @@ -445,7 +445,7 @@ call_function_by_hand (struct value *function, int nargs, struct value **args) On a RISC architecture, a void parameterless generic dummy frame (i.e., no parameters, no result) typically does not need to push anything the stack and hence can leave SP and - FP. Similarly, a framelss (possibly leaf) function does + FP. Similarly, a frameless (possibly leaf) function does not push anything on the stack and, hence, that too can leave FP and SP unchanged. As a consequence, a sequence of void parameterless generic dummy frame calls to frameless @@ -1056,8 +1056,10 @@ the function call).", name); } else { - struct value *retval = value_being_returned (value_type, retbuf, - struct_return); + struct value *retval = value_being_returned (value_type, + retbuf, + struct_return, + struct_addr); do_cleanups (retbuf_cleanup); return retval; } diff --git a/gdb/infcmd.c b/gdb/infcmd.c index df7d9508cca..c47c9eac876 100644 --- a/gdb/infcmd.c +++ b/gdb/infcmd.c @@ -1077,10 +1077,11 @@ print_return_value (int structure_return, struct type *value_type) if (!structure_return) { - value = value_being_returned (value_type, stop_registers, structure_return); + value = value_being_returned (value_type, stop_registers, 0, 0); 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)); + ui_out_field_fmt (uiout, "gdb-result-var", "$%d", + record_latest_value (value)); ui_out_text (uiout, " = "); value_print (value, stb->stream, 0, Val_no_prettyprint); ui_out_field_stream (uiout, "return-value", stb); @@ -1088,20 +1089,23 @@ print_return_value (int structure_return, struct type *value_type) } else { - /* We cannot determine the contents of the structure because - it is on the stack, and we don't know where, since we did not - initiate the call, as opposed to the call_function_by_hand case */ #ifdef VALUE_RETURNED_FROM_STACK + /* We cannot determine the contents of the structure because it + is on the stack, and we don't know where, since we did not + initiate the call, as opposed to the call_function_by_hand + case. */ value = 0; ui_out_text (uiout, "Value returned has type: "); ui_out_field_string (uiout, "return-type", TYPE_NAME (value_type)); ui_out_text (uiout, "."); ui_out_text (uiout, " Cannot determine contents\n"); #else - value = value_being_returned (value_type, stop_registers, structure_return); + value = value_being_returned (value_type, stop_registers, + structure_return, 0); 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)); + ui_out_field_fmt (uiout, "gdb-result-var", "$%d", + record_latest_value (value)); ui_out_text (uiout, " = "); value_print (value, stb->stream, 0, Val_no_prettyprint); ui_out_field_stream (uiout, "return-value", stb); diff --git a/gdb/value.h b/gdb/value.h index d50626edf17..77d9d3955f8 100644 --- a/gdb/value.h +++ b/gdb/value.h @@ -420,7 +420,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); + int struct_return, + CORE_ADDR struct_addr); extern struct value *value_in (struct value *element, struct value *set); diff --git a/gdb/values.c b/gdb/values.c index 42395c886e2..7e7e9b15534 100644 --- a/gdb/values.c +++ b/gdb/values.c @@ -1212,31 +1212,36 @@ value_from_double (struct type *type, DOUBLEST num) /* ARGSUSED */ struct value * value_being_returned (struct type *valtype, struct regcache *retbuf, - int struct_return) + int struct_return, CORE_ADDR struct_addr) { 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); - } + if (struct_return) + { + if (struct_addr != 0) + { + /* Struct return addr supplied by hand_function_call. */ + return value_at (valtype, struct_addr, NULL); + } + /* If one of these is not defined, just use EXTRACT_RETURN_VALUE + instead. */ + else if (EXTRACT_STRUCT_VALUE_ADDRESS_P ()) + { + addr = EXTRACT_STRUCT_VALUE_ADDRESS (retbuf); + if (!addr) + error ("Function return value unknown."); + return value_at (valtype, addr, NULL); + } + else if (DEPRECATED_EXTRACT_STRUCT_VALUE_ADDRESS_P ()) + { + 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); CHECK_TYPEDEF (valtype); -- 2.30.2