From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12349 invoked by alias); 30 Jul 2003 21:01:19 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 12338 invoked from network); 30 Jul 2003 21:01:18 -0000 Received: from unknown (HELO mx1.redhat.com) (66.187.233.31) by sources.redhat.com with SMTP; 30 Jul 2003 21:01:18 -0000 Received: from int-mx2.corp.redhat.com (nat-pool-rdu-dmz.redhat.com [172.16.52.200] (may be forged)) by mx1.redhat.com (8.11.6/8.11.6) with ESMTP id h6UL1HZ24896 for ; Wed, 30 Jul 2003 17:01:17 -0400 Received: from potter.sfbay.redhat.com (potter.sfbay.redhat.com [172.16.27.15]) by int-mx2.corp.redhat.com (8.11.6/8.11.6) with ESMTP id h6UL1F621421; Wed, 30 Jul 2003 17:01:16 -0400 Received: from redhat.com (reddwarf.sfbay.redhat.com [172.16.24.50]) by potter.sfbay.redhat.com (8.11.6/8.11.6) with ESMTP id h6UL1EK21183; Wed, 30 Jul 2003 14:01:14 -0700 Message-ID: <3F28321A.7040201@redhat.com> Date: Wed, 30 Jul 2003 21:01:00 -0000 From: Michael Snyder User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4) Gecko/20030624 X-Accept-Language: en-us, en MIME-Version: 1.0 To: gdb-patches@sources.redhat.com, eliz@is.elta.co.il Subject: [SO obvious...] make struct_return work for hand_function_call Content-Type: multipart/mixed; boundary="------------090107020708000209080803" X-SW-Source: 2003-07/txt/msg00547.txt.bz2 This is a multi-part message in MIME format. --------------090107020708000209080803 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Content-length: 192 God, we've struggled with this for years... the answer is so obvious! Eli, this generalizes some special-purpose code that you wrote for HP, which now becomes redundant and may be removed. --------------090107020708000209080803 Content-Type: text/plain; name="structs2" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="structs2" Content-length: 9499 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. Index: value.h =================================================================== RCS file: /cvs/src/src/gdb/value.h,v retrieving revision 1.48 diff -p -r1.48 value.h *** value.h 5 Jun 2003 20:59:16 -0000 1.48 --- value.h 30 Jul 2003 20:55:22 -0000 *************** extern struct value *value_subscript (st *** 420,426 **** extern struct value *value_being_returned (struct type *valtype, struct regcache *retbuf, ! int struct_return); extern struct value *value_in (struct value *element, struct value *set); --- 420,427 ---- extern struct value *value_being_returned (struct type *valtype, struct regcache *retbuf, ! int struct_return, ! CORE_ADDR struct_addr); 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.50 diff -p -r1.50 values.c *** values.c 5 Jun 2003 20:59:16 -0000 1.50 --- values.c 30 Jul 2003 20:55:22 -0000 *************** value_from_double (struct type *type, DO *** 1212,1242 **** /* ARGSUSED */ struct value * value_being_returned (struct type *valtype, struct regcache *retbuf, ! int struct_return) { 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); CHECK_TYPEDEF (valtype); --- 1212,1247 ---- /* ARGSUSED */ struct value * value_being_returned (struct type *valtype, struct regcache *retbuf, ! int struct_return, CORE_ADDR struct_addr) { struct value *val; CORE_ADDR addr; ! 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); Index: infcmd.c =================================================================== RCS file: /cvs/src/src/gdb/infcmd.c,v retrieving revision 1.83 diff -p -r1.83 infcmd.c *** infcmd.c 7 Jul 2003 14:36:58 -0000 1.83 --- infcmd.c 30 Jul 2003 20:55:22 -0000 *************** print_return_value (int structure_return *** 1077,1086 **** if (!structure_return) { ! value = value_being_returned (value_type, stop_registers, structure_return); 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_text (uiout, " = "); value_print (value, stb->stream, 0, Val_no_prettyprint); ui_out_field_stream (uiout, "return-value", stb); --- 1077,1087 ---- if (!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_text (uiout, " = "); value_print (value, stb->stream, 0, Val_no_prettyprint); ui_out_field_stream (uiout, "return-value", stb); *************** print_return_value (int structure_return *** 1088,1107 **** } 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 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); 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_text (uiout, " = "); value_print (value, stb->stream, 0, Val_no_prettyprint); ui_out_field_stream (uiout, "return-value", stb); --- 1089,1111 ---- } else { #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, 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_text (uiout, " = "); value_print (value, stb->stream, 0, Val_no_prettyprint); ui_out_field_stream (uiout, "return-value", stb); Index: infcall.c =================================================================== RCS file: /cvs/src/src/gdb/infcall.c,v retrieving revision 1.17 diff -p -r1.17 infcall.c *** infcall.c 16 Jun 2003 16:47:42 -0000 1.17 --- infcall.c 30 Jul 2003 20:55:23 -0000 *************** call_function_by_hand (struct value *fun *** 421,427 **** 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 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 --- 421,427 ---- vector. Hence this direct call. A follow-on change is to modify this interface so that it takes ! 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 *************** call_function_by_hand (struct value *fun *** 445,451 **** 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 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 --- 445,451 ---- 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 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 *************** the function call).", name); *** 1056,1063 **** } else { ! struct value *retval = value_being_returned (value_type, retbuf, ! struct_return); do_cleanups (retbuf_cleanup); return retval; } --- 1056,1065 ---- } else { ! struct value *retval = value_being_returned (value_type, ! retbuf, ! struct_return, ! struct_addr); do_cleanups (retbuf_cleanup); return retval; } --------------090107020708000209080803--