From patchwork Wed Feb 21 03:54:33 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 25985 Received: (qmail 118736 invoked by alias); 21 Feb 2018 03:54:38 -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 118388 invoked by uid 89); 21 Feb 2018 03:54:37 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.9 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 autolearn=ham version=3.3.2 spammy= X-HELO: gateway33.websitewelcome.com Received: from gateway33.websitewelcome.com (HELO gateway33.websitewelcome.com) (192.185.146.87) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 21 Feb 2018 03:54:36 +0000 Received: from cm12.websitewelcome.com (cm12.websitewelcome.com [100.42.49.8]) by gateway33.websitewelcome.com (Postfix) with ESMTP id A243CA8EC for ; Tue, 20 Feb 2018 21:54:34 -0600 (CST) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id oLUIeBYJBzzFjoLUIemhNx; Tue, 20 Feb 2018 21:54:34 -0600 Received: from 174-29-60-18.hlrn.qwest.net ([174.29.60.18]:33240 helo=bapiya) by box5379.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.89) (envelope-from ) id 1eoLUI-001N2M-AN; Tue, 20 Feb 2018 21:54:34 -0600 From: Tom Tromey To: Tom Tromey Cc: Simon Marchi , gdb-patches@sourceware.org Subject: Re: [RFA] Remove a cleanup from call_function_by_hand_dummy References: <20180217161104.4909-1-tom@tromey.com> <87r2pj4a3x.fsf@tromey.com> Date: Tue, 20 Feb 2018 20:54:33 -0700 In-Reply-To: <87r2pj4a3x.fsf@tromey.com> (Tom Tromey's message of "Sat, 17 Feb 2018 13:47:14 -0700") Message-ID: <878tbnq9om.fsf@tromey.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.90 (gnu/linux) MIME-Version: 1.0 X-BWhitelist: no X-Source-L: No X-Exim-ID: 1eoLUI-001N2M-AN X-Source-Sender: 174-29-60-18.hlrn.qwest.net (bapiya) [174.29.60.18]:33240 X-Source-Auth: tom+tromey.com X-Email-Count: 2 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes Tom> Maybe I should avoid this entirely by using std::copy or something like Tom> that. How about this instead? Tom commit 7377e0d67ff5f26e9faed818a76e9b7b2727a963 Author: Tom Tromey Date: Fri Feb 16 16:11:29 2018 -0700 Remove a cleanup from call_function_by_hand_dummy This removes a cleanup from call_function_by_hand_dummy, replacing manual allocation with std::vector. Regression tested by the buildbot. gdb/ChangeLog 2018-02-16 Tom Tromey * infcall.c (call_function_by_hand_dummy): Use std::vector. diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 9f78ed33cc..8b91d73b0b 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,7 @@ +2018-02-16 Tom Tromey + + * infcall.c (call_function_by_hand_dummy): Use std::vector. + 2018-02-20 Simon Marchi * remote-sim.c (gdb_os_printf_filtered, gdb_os_vprintf_filtered, diff --git a/gdb/infcall.c b/gdb/infcall.c index 8b75297251..b7f4a176db 100644 --- a/gdb/infcall.c +++ b/gdb/infcall.c @@ -39,6 +39,7 @@ #include "top.h" #include "interps.h" #include "thread-fsm.h" +#include /* If we can't find a function's name from its address, we print this instead. */ @@ -732,7 +733,6 @@ call_function_by_hand_dummy (struct value *function, struct type *ftype = check_typedef (value_type (function)); CORE_ADDR bp_addr; struct frame_id dummy_id; - struct cleanup *args_cleanup; struct frame_info *frame; struct gdbarch *gdbarch; struct cleanup *terminate_bp_cleanup; @@ -1054,21 +1054,16 @@ call_function_by_hand_dummy (struct value *function, } } + std::vector new_args; if (hidden_first_param_p) { - struct value **new_args; - /* Add the new argument to the front of the argument list. */ - new_args = XNEWVEC (struct value *, nargs + 1); - new_args[0] = value_from_pointer (lookup_pointer_type (values_type), - struct_addr); - memcpy (&new_args[1], &args[0], sizeof (struct value *) * nargs); - args = new_args; + new_args.push_back + (value_from_pointer (lookup_pointer_type (values_type), struct_addr)); + std::copy (&args[0], &args[nargs], std::back_inserter (new_args)); + args = new_args.data (); nargs++; - args_cleanup = make_cleanup (xfree, args); } - else - args_cleanup = make_cleanup (null_cleanup, NULL); /* Create the dummy stack frame. Pass in the call dummy address as, presumably, the ABI code knows where, in the call dummy, the @@ -1077,8 +1072,6 @@ call_function_by_hand_dummy (struct value *function, bp_addr, nargs, args, sp, struct_return, struct_addr); - do_cleanups (args_cleanup); - /* 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 ID so that the breakpoint code can correctly re-identify the