From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 82137 invoked by alias); 31 Oct 2018 11:18:15 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 81936 invoked by uid 89); 31 Oct 2018 11:18:13 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.0 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,RCVD_IN_DNSWL_NONE,SPF_HELO_PASS,SPF_PASS autolearn=ham version=3.3.2 spammy=core_addr, CORE_ADDR X-HELO: EUR02-HE1-obe.outbound.protection.outlook.com Received: from mail-eopbgr10053.outbound.protection.outlook.com (HELO EUR02-HE1-obe.outbound.protection.outlook.com) (40.107.1.53) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 31 Oct 2018 11:18:11 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector1-arm-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=FmTA8xY2kZUWYUfwVU3dF+lyabRQYmsxgP+wM0XLXv0=; b=UxpLxCKn2ez4VXgq6/buK9O5ij6c+miuD0HdvL+OSdOp1XSn3GMDVN7RC000sUflWmpVj+dj0P2cul2dk3Qfx52WoXVDhqdBAjgAlNSJMC3BsfPHN0kYZ/G9qVcRV+ICzvbXShZnVlbXTdtRY/JyunTfxmqxqdxrg5v6U8834I8= Received: from DB6PR0802MB2133.eurprd08.prod.outlook.com (10.172.226.148) by DB6PR0802MB2248.eurprd08.prod.outlook.com (10.172.227.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1294.21; Wed, 31 Oct 2018 11:18:05 +0000 Received: from DB6PR0802MB2133.eurprd08.prod.outlook.com ([fe80::748a:5f72:2321:bc11]) by DB6PR0802MB2133.eurprd08.prod.outlook.com ([fe80::748a:5f72:2321:bc11%7]) with mapi id 15.20.1273.028; Wed, 31 Oct 2018 11:18:05 +0000 From: Alan Hayward To: "gdb-patches@sourceware.org" CC: nd , Alan Hayward Subject: [PATCH v4 1/3] Use enum for return method for dummy calls Date: Wed, 31 Oct 2018 11:18:00 -0000 Message-ID: <20181031111754.64707-2-alan.hayward@arm.com> References: <20181031111754.64707-1-alan.hayward@arm.com> In-Reply-To: <20181031111754.64707-1-alan.hayward@arm.com> authentication-results: spf=none (sender IP is ) smtp.mailfrom=Alan.Hayward@arm.com; received-spf: None (protection.outlook.com: arm.com does not designate permitted sender hosts) Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-IsSubscribed: yes X-SW-Source: 2018-10/txt/msg00742.txt.bz2 In call_function_by_hand_dummy, struct_return and hidden_first_param_p are used to represent a single concept. Replace with an enum. gdb/ChangeLog: 2018-10-31 Alan Hayward * gdbarch.sh (enum function_call_return_method): Add enum. * gdbarch.h: Regenerate. * infcall.c (call_function_by_hand_dummy): Replace vars with enum. --- gdb/gdbarch.h | 23 +++++++++++++++++++++++ gdb/gdbarch.sh | 23 +++++++++++++++++++++++ gdb/infcall.c | 29 +++++++++++------------------ 3 files changed, 57 insertions(+), 18 deletions(-) diff --git a/gdb/gdbarch.h b/gdb/gdbarch.h index 2cb6961083..e8e35fbd01 100644 --- a/gdb/gdbarch.h +++ b/gdb/gdbarch.h @@ -102,6 +102,29 @@ typedef void (iterate_over_regset_sections_cb) (const char *sect_name, int supply_size, int collect_size, const struct regset *regset, const char *human_name, void *cb_data); =20 +/* For a function call, does the function return a value using a + normal value return or a structure return - passing a hidden + argument pointing to storage. For the latter, there are two + cases: language-mandated structure return and target ABI + structure return. */ + +enum function_call_return_method +{ + /* Standard value return. */ + return_method_normal =3D 0, + + /* Language ABI structure return. This is handled + by passing the return location as the first parameter to + the function, even preceding "this". */ + return_method_hidden_param, + + /* Target ABI struct return. This is target-specific; for instance, + on ia64 the first argument is passed in out0 but the hidden + structure return pointer would normally be passed in r8. */ + return_method_struct, +}; + + =20 /* The following are pre-initialized by GDBARCH. */ =20 diff --git a/gdb/gdbarch.sh b/gdb/gdbarch.sh index bbfa8d2205..1e895c3b7a 100755 --- a/gdb/gdbarch.sh +++ b/gdb/gdbarch.sh @@ -1327,6 +1327,29 @@ typedef int (iterate_over_objfiles_in_search_order_c= b_ftype) typedef void (iterate_over_regset_sections_cb) (const char *sect_name, int supply_size, int collect_size, const struct regset *regset, const char *human_name, void *cb_data); + +/* For a function call, does the function return a value using a + normal value return or a structure return - passing a hidden + argument pointing to storage. For the latter, there are two + cases: language-mandated structure return and target ABI + structure return. */ + +enum function_call_return_method +{ + /* Standard value return. */ + return_method_normal =3D 0, + + /* Language ABI structure return. This is handled + by passing the return location as the first parameter to + the function, even preceding "this". */ + return_method_hidden_param, + + /* Target ABI struct return. This is target-specific; for instance, + on ia64 the first argument is passed in out0 but the hidden + structure return pointer would normally be passed in r8. */ + return_method_struct, +}; + EOF =20 # function typedef's diff --git a/gdb/infcall.c b/gdb/infcall.c index 96d43704fa..0c875ea4b9 100644 --- a/gdb/infcall.c +++ b/gdb/infcall.c @@ -719,7 +719,7 @@ call_function_by_hand_dummy (struct value *function, { CORE_ADDR sp; struct type *target_values_type; - unsigned char struct_return =3D 0, hidden_first_param_p =3D 0; + function_call_return_method return_method =3D return_method_normal; CORE_ADDR struct_addr =3D 0; CORE_ADDR real_pc; CORE_ADDR bp_addr; @@ -876,20 +876,11 @@ call_function_by_hand_dummy (struct value *function, =20 values_type =3D check_typedef (values_type); =20 - /* Are we returning a value using a structure return (passing a - hidden argument pointing to storage) or a normal value return? - There are two cases: language-mandated structure return and - target ABI structure return. The variable STRUCT_RETURN only - describes the latter. The language version is handled by passing - the return location as the first parameter to the function, - even preceding "this". This is different from the target - ABI version, which is target-specific; for instance, on ia64 - the first argument is passed in out0 but the hidden structure - return pointer would normally be passed in r8. */ + /* Are we returning a value using a structure return? */ =20 if (gdbarch_return_in_first_hidden_param_p (gdbarch, values_type)) { - hidden_first_param_p =3D 1; + return_method =3D return_method_hidden_param; =20 /* Tell the target specific argument pushing routine not to expect a value. */ @@ -897,7 +888,8 @@ call_function_by_hand_dummy (struct value *function, } else { - struct_return =3D using_struct_return (gdbarch, function, values_typ= e); + if (using_struct_return (gdbarch, function, values_type)) + return_method =3D return_method_struct; target_values_type =3D values_type; } =20 @@ -1020,7 +1012,7 @@ call_function_by_hand_dummy (struct value *function, is being evaluated is OK because the thread is stopped until the expression is completely evaluated. */ =20 - if (struct_return || hidden_first_param_p + if (return_method !=3D return_method_normal || (stack_temporaries && class_or_union_p (values_type))) { if (gdbarch_inner_than (gdbarch, 1, 2)) @@ -1046,7 +1038,7 @@ call_function_by_hand_dummy (struct value *function, } =20 std::vector new_args; - if (hidden_first_param_p) + if (return_method =3D=3D return_method_hidden_param) { /* Add the new argument to the front of the argument list. */ new_args.push_back @@ -1060,8 +1052,9 @@ call_function_by_hand_dummy (struct value *function, presumably, the ABI code knows where, in the call dummy, the return address should be pointed. */ sp =3D gdbarch_push_dummy_call (gdbarch, function, get_current_regcache = (), - bp_addr, nargs, args, - sp, struct_return, struct_addr); + bp_addr, nargs, args, sp, + (return_method =3D=3D return_method_struct), + struct_addr); =20 /* Set up a frame ID for the dummy frame so we can pass it to set_momentary_breakpoint. We need to give the breakpoint a frame @@ -1157,7 +1150,7 @@ call_function_by_hand_dummy (struct value *function, sm =3D new_call_thread_fsm (current_ui, command_interp (), gdbarch, function, values_type, - struct_return || hidden_first_param_p, + return_method !=3D return_method_normal, struct_addr); =20 e =3D run_inferior_call (sm, call_thread.get (), real_pc); --=20 2.17.1 (Apple Git-112)