From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 33834 invoked by alias); 24 Oct 2019 05:57:26 -0000 Mailing-List: contact gdb-testers-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-testers-owner@sourceware.org Received: (qmail 33818 invoked by uid 89); 24 Oct 2019 05:57:25 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-15.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_PASS autolearn=ham version=3.3.1 spammy= X-HELO: kwanyin.sergiodj.net Received: from kwanyin.sergiodj.net (HELO kwanyin.sergiodj.net) (158.69.185.54) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 24 Oct 2019 05:57:24 +0000 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [binutils-gdb] infcall: move assertions in 'call_function_by_hand_dummy' to an earlier spot From: gdb-buildbot@sergiodj.net To: gdb-testers@sourceware.org Message-Id: <39bcc47c7e94c746d5acdb52f20f9617a6473292@gdb-build> Date: Thu, 24 Oct 2019 05:57:00 -0000 X-SW-Source: 2019-q4/txt/msg01388.txt.bz2 *** TEST RESULTS FOR COMMIT 39bcc47c7e94c746d5acdb52f20f9617a6473292 *** commit 39bcc47c7e94c746d5acdb52f20f9617a6473292 Author: Tankut Baris Aktemur AuthorDate: Wed Oct 23 20:40:02 2019 +0200 Commit: Tankut Baris Aktemur CommitDate: Wed Oct 23 20:40:02 2019 +0200 infcall: move assertions in 'call_function_by_hand_dummy' to an earlier spot This is a refactoring that performs type assertions on the callee function at the beginning of 'call_function_by_hand_dummy' rather than at a later point so that - the checks are grouped together at the beginning of the function for improved readability, and - we don't have to align and push things on the stack only to find out later that the function call is illegal. gdb/ChangeLog: 2019-10-23 Tankut Baris Aktemur * infcall.c (call_function_by_hand_dummy): Refactor. Change-Id: I411ac083ac6a9ee6eb93c4b82393a81a4fc927be diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 53f50e2d85..6fafc4466e 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,7 @@ +2019-10-23 Tankut Baris Aktemur + + * infcall.c (call_function_by_hand_dummy): Refactor. + 2019-10-23 Tankut Baris Aktemur * MAINTAINERS (Write After Approval): Add Tankut Baris Aktemur. diff --git a/gdb/infcall.c b/gdb/infcall.c index 726f14d525..0d8d5b2178 100644 --- a/gdb/infcall.c +++ b/gdb/infcall.c @@ -746,6 +746,27 @@ call_function_by_hand_dummy (struct value *function, if (!gdbarch_push_dummy_call_p (gdbarch)) error (_("This target does not support function calls.")); + /* Find the function type and do a sanity check. */ + type *ftype; + type *values_type; + CORE_ADDR funaddr = find_function_addr (function, &values_type, &ftype); + + if (values_type == NULL) + values_type = default_return_type; + if (values_type == NULL) + { + const char *name = get_function_name (funaddr, + name_buf, sizeof (name_buf)); + error (_("'%s' has unknown return type; " + "cast the call to its declared return type"), + name); + } + + values_type = check_typedef (values_type); + + if (args.size () < TYPE_NFIELDS (ftype)) + error (_("Too few arguments in function call.")); + /* A holder for the inferior status. This is only needed while we're preparing the inferior function call. */ infcall_control_state_up inf_status (save_infcall_control_state ()); @@ -851,23 +872,6 @@ call_function_by_hand_dummy (struct value *function, } } - type *ftype; - type *values_type; - CORE_ADDR funaddr = find_function_addr (function, &values_type, &ftype); - - if (values_type == NULL) - values_type = default_return_type; - if (values_type == NULL) - { - const char *name = get_function_name (funaddr, - name_buf, sizeof (name_buf)); - error (_("'%s' has unknown return type; " - "cast the call to its declared return type"), - name); - } - - values_type = check_typedef (values_type); - /* Are we returning a value using a structure return? */ if (gdbarch_return_in_first_hidden_param_p (gdbarch, values_type)) @@ -945,9 +949,6 @@ call_function_by_hand_dummy (struct value *function, internal_error (__FILE__, __LINE__, _("bad switch")); } - if (args.size () < TYPE_NFIELDS (ftype)) - error (_("Too few arguments in function call.")); - for (int i = args.size () - 1; i >= 0; i--) { int prototyped;