From patchwork Wed Oct 23 19:05:04 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: 35263 Received: (qmail 116312 invoked by alias); 23 Oct 2019 19:05:10 -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 116238 invoked by uid 89); 23 Oct 2019 19:05:09 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=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; Wed, 23 Oct 2019 19:05:08 +0000 Received: by mx1.osci.io (Postfix, from userid 994) id 9B3962018B; Wed, 23 Oct 2019 15:05:06 -0400 (EDT) Received: from gnutoolchain-gerrit.osci.io (gnutoolchain-gerrit.osci.io [IPv6:2620:52:3:1:5054:ff:fe06:16ca]) by mx1.osci.io (Postfix) with ESMTP id 8A108202DF; Wed, 23 Oct 2019 15:05:04 -0400 (EDT) Received: from localhost (localhost [127.0.0.1]) by gnutoolchain-gerrit.osci.io (Postfix) with ESMTP id 73D7B238BC; Wed, 23 Oct 2019 15:05:04 -0400 (EDT) X-Gerrit-PatchSet: 2 Date: Wed, 23 Oct 2019 15:05:04 -0400 From: "Sourceware to Gerrit sync (Code Review)" To: Tankut Baris Aktemur , gdb-patches@sourceware.org Cc: Tom Tromey Auto-Submitted: auto-generated X-Gerrit-MessageType: merged Subject: [pushed] infcall: refactor 'call_function_by_hand_dummy' X-Gerrit-Change-Id: I8938ef4134aff68a0a21724aaa2406bfe453438a X-Gerrit-Change-Number: 138 X-Gerrit-ChangeURL: X-Gerrit-Commit: 12e7c35ec3c09793ed9613cdf696b9f0f4dd86ec In-Reply-To: References: Reply-To: noreply@gnutoolchain-gerrit.osci.io, tankut.baris.aktemur@intel.com, tromey@sourceware.org, gdb-patches@sourceware.org MIME-Version: 1.0 Content-Disposition: inline User-Agent: Gerrit/3.0.3 Message-Id: <20191023190504.73D7B238BC@gnutoolchain-gerrit.osci.io> Sourceware to Gerrit sync has submitted this change. Change URL: https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/138 ...................................................................... infcall: refactor 'call_function_by_hand_dummy' Extract out the code region that reserves stack space to a separate function. Fix the comment of 'call_function_by_hand_dummy' to remove reference to the NARGS argument that was removed in commit (e71585ffe2e "Use gdb:array_view in call_function_by_hand & friends"). gdb/ChangeLog: 2019-10-23 Tankut Baris Aktemur * infcall.c (call_function_by_hand_dummy): Fix the function comment. And extract out a code section into... (reserve_stack_space): ...this new function. Change-Id: I8938ef4134aff68a0a21724aaa2406bfe453438a --- M gdb/ChangeLog M gdb/infcall.c 2 files changed, 45 insertions(+), 25 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 52aea37..a976d8f 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,11 @@ 2019-10-23 Tankut Baris Aktemur + * infcall.c (call_function_by_hand_dummy): Fix the function + comment. And extract out a code section into... + (reserve_stack_space): ...this new function. + +2019-10-23 Tankut Baris Aktemur + * infcall.c (value_arg_coerce): Remove an unused parameter. (call_function_by_hand_dummy): Update the call to 'value_arg_coerce'. diff --git a/gdb/infcall.c b/gdb/infcall.c index b83f1bf..583f0de 100644 --- a/gdb/infcall.c +++ b/gdb/infcall.c @@ -668,6 +668,42 @@ return caught_error; } +/* Reserve space on the stack for a value of the given type. + Return the address of the allocated space. + Make certain that the value is correctly aligned. + The SP argument is modified. */ + +static CORE_ADDR +reserve_stack_space (const type *values_type, CORE_ADDR &sp) +{ + struct frame_info *frame = get_current_frame (); + struct gdbarch *gdbarch = get_frame_arch (frame); + CORE_ADDR addr = 0; + + if (gdbarch_inner_than (gdbarch, 1, 2)) + { + /* Stack grows downward. Align STRUCT_ADDR and SP after + making space. */ + sp -= TYPE_LENGTH (values_type); + if (gdbarch_frame_align_p (gdbarch)) + sp = gdbarch_frame_align (gdbarch, sp); + addr = sp; + } + else + { + /* Stack grows upward. Align the frame, allocate space, and + then again, re-align the frame??? */ + if (gdbarch_frame_align_p (gdbarch)) + sp = gdbarch_frame_align (gdbarch, sp); + addr = sp; + sp += TYPE_LENGTH (values_type); + if (gdbarch_frame_align_p (gdbarch)) + sp = gdbarch_frame_align (gdbarch, sp); + } + + return addr; +} + /* See infcall.h. */ struct value * @@ -689,7 +725,7 @@ making dummy frames be different from normal frames, consider that. */ /* Perform a function call in the inferior. - ARGS is a vector of values of arguments (NARGS of them). + ARGS is a vector of values of arguments. FUNCTION is a value, the function to be called. Returns a value representing what the function returned. May fail to return, if a breakpoint or signal is hit @@ -989,8 +1025,7 @@ } /* Reserve space for the return structure to be written on the - stack, if necessary. Make certain that the value is correctly - aligned. + stack, if necessary. While evaluating expressions, we reserve space on the stack for return values of class type even if the language ABI and the target @@ -1005,28 +1040,7 @@ if (return_method != return_method_normal || (stack_temporaries && class_or_union_p (values_type))) - { - if (gdbarch_inner_than (gdbarch, 1, 2)) - { - /* Stack grows downward. Align STRUCT_ADDR and SP after - making space for the return value. */ - sp -= TYPE_LENGTH (values_type); - if (gdbarch_frame_align_p (gdbarch)) - sp = gdbarch_frame_align (gdbarch, sp); - struct_addr = sp; - } - else - { - /* Stack grows upward. Align the frame, allocate space, and - then again, re-align the frame??? */ - if (gdbarch_frame_align_p (gdbarch)) - sp = gdbarch_frame_align (gdbarch, sp); - struct_addr = sp; - sp += TYPE_LENGTH (values_type); - if (gdbarch_frame_align_p (gdbarch)) - sp = gdbarch_frame_align (gdbarch, sp); - } - } + struct_addr = reserve_stack_space (values_type, sp); std::vector new_args; if (return_method == return_method_hidden_param)