From patchwork Fri Oct 18 13:53:24 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Simon Marchi (Code Review)" X-Patchwork-Id: 35138 Received: (qmail 108499 invoked by alias); 18 Oct 2019 13:53:31 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 108432 invoked by uid 89); 18 Oct 2019 13:53:30 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-19.5 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3 autolearn=ham version=3.3.1 spammy= X-HELO: mx1.osci.io Received: from polly.osci.io (HELO mx1.osci.io) (8.43.85.229) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 18 Oct 2019 13:53:29 +0000 Received: by mx1.osci.io (Postfix, from userid 994) id 5BCD0208F2; Fri, 18 Oct 2019 09:53:27 -0400 (EDT) Received: from gnutoolchain-gerrit.osci.io (gnutoolchain-gerrit.osci.io [8.43.85.239]) by mx1.osci.io (Postfix) with ESMTP id 86A3F20905 for ; Fri, 18 Oct 2019 09:53:24 -0400 (EDT) Received: from localhost (localhost [127.0.0.1]) by gnutoolchain-gerrit.osci.io (Postfix) with ESMTP id 6E94A21926 for ; Fri, 18 Oct 2019 09:53:24 -0400 (EDT) X-Gerrit-PatchSet: 1 Date: Fri, 18 Oct 2019 09:53:24 -0400 From: "Tankut Baris Aktemur (Code Review)" To: gdb-patches@sourceware.org Message-ID: Auto-Submitted: auto-generated X-Gerrit-MessageType: newchange Subject: [review] infcall: move assertions in 'call_function_by_hand_dummy' to an earli... X-Gerrit-Change-Id: I411ac083ac6a9ee6eb93c4b82393a81a4fc927be X-Gerrit-Change-Number: 139 X-Gerrit-ChangeURL: X-Gerrit-Commit: 36ec4e04bb56dca32d147449d58428143836ddc6 References: Reply-To: tankut.baris.aktemur@intel.com, gdb-patches@sourceware.org MIME-Version: 1.0 Content-Disposition: inline User-Agent: Gerrit/3.0.3 Tankut Baris Aktemur has uploaded a new change for review. Change URL: https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/139 ...................................................................... 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. gdb/ChangeLog: 2019-MM-DD Tankut Baris Aktemur * infcall.c (call_function_by_hand_dummy): Refactor. Change-Id: I411ac083ac6a9ee6eb93c4b82393a81a4fc927be --- M gdb/infcall.c 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/gdb/infcall.c b/gdb/infcall.c index a342310..629a83c 100644 --- a/gdb/infcall.c +++ b/gdb/infcall.c @@ -782,6 +782,27 @@ 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 ()); @@ -887,23 +908,6 @@ } } - 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)) @@ -981,9 +985,6 @@ 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;