From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 51157 invoked by alias); 18 Jul 2018 14:09:14 -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 51064 invoked by uid 89); 18 Jul 2018 14:09:14 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-25.4 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.195) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 18 Jul 2018 14:09:12 +0000 Received: from cm16.websitewelcome.com (cm16.websitewelcome.com [100.42.49.19]) by gateway33.websitewelcome.com (Postfix) with ESMTP id 6F1EA423100 for ; Wed, 18 Jul 2018 09:09:10 -0500 (CDT) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id fn8gfh8fCaSeyfn8gfJ2g1; Wed, 18 Jul 2018 09:09:10 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Sender:Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=8PUSjDK9te2uhCOijZmJ89E6JfR39uubL3i1qSjvJxo=; b=vGvonZWDZnalpSL2Y8ErubPp+L Tq9Qaw42dC7WDeWTz8LgYMxD1mMwxuYjxdDLGGL7m3mU4Pxtmw646lmg6WaLETu4gjn4KWF9D/Q71 g4lEte0QAwZfFbqwWUszhdHNY; Received: from 75-166-85-72.hlrn.qwest.net ([75.166.85.72]:57494 helo=pokyo.Home) by box5379.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.91) (envelope-from ) id 1ffn8g-000r59-8A; Wed, 18 Jul 2018 09:09:10 -0500 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [RFA v2 6/6] Make save_infcall_*_state return unique pointers Date: Wed, 18 Jul 2018 14:09:00 -0000 Message-Id: <20180718140904.16811-7-tom@tromey.com> In-Reply-To: <20180718140904.16811-1-tom@tromey.com> References: <20180718140904.16811-1-tom@tromey.com> X-SW-Source: 2018-07/txt/msg00547.txt.bz2 Simon pointed out that save_infcall_suspend_state and save_infcall_control_state could return unique pointers. This patch implements this idea. gdb/ChangeLog 2018-07-18 Tom Tromey * infrun.c (save_infcall_suspend_state): Return infcall_suspend_state_up. (save_infcall_control_state): Return infcall_control_state_up. * inferior.h (save_infcall_suspend_state) (save_infcall_control_state): Declare later. Return unique pointers. --- gdb/ChangeLog | 9 +++++++++ gdb/inferior.h | 7 ++++--- gdb/infrun.c | 13 ++++++------- 3 files changed, 19 insertions(+), 10 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index d786f1f3838..733b513c4b2 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,12 @@ +2018-07-18 Tom Tromey + + * infrun.c (save_infcall_suspend_state): Return + infcall_suspend_state_up. + (save_infcall_control_state): Return infcall_control_state_up. + * inferior.h (save_infcall_suspend_state) + (save_infcall_control_state): Declare later. Return unique + pointers. + 2018-07-18 Tom Tromey * infrun.c (struct stop_context): Declare constructor, diff --git a/gdb/inferior.h b/gdb/inferior.h index 02fb71e4b3e..e02500fdb1e 100644 --- a/gdb/inferior.h +++ b/gdb/inferior.h @@ -57,9 +57,6 @@ struct thread_info; struct infcall_suspend_state; struct infcall_control_state; -extern struct infcall_suspend_state *save_infcall_suspend_state (void); -extern struct infcall_control_state *save_infcall_control_state (void); - extern void restore_infcall_suspend_state (struct infcall_suspend_state *); extern void restore_infcall_control_state (struct infcall_control_state *); @@ -77,6 +74,8 @@ struct infcall_suspend_state_deleter typedef std::unique_ptr infcall_suspend_state_up; +extern infcall_suspend_state_up save_infcall_suspend_state (); + /* A deleter for infcall_control_state that calls restore_infcall_control_state. */ struct infcall_control_state_deleter @@ -91,6 +90,8 @@ struct infcall_control_state_deleter typedef std::unique_ptr infcall_control_state_up; +extern infcall_control_state_up save_infcall_control_state (); + extern void discard_infcall_suspend_state (struct infcall_suspend_state *); extern void discard_infcall_control_state (struct infcall_control_state *); diff --git a/gdb/infrun.c b/gdb/infrun.c index 15bdf004b1a..d74953e4417 100644 --- a/gdb/infrun.c +++ b/gdb/infrun.c @@ -8816,10 +8816,9 @@ struct infcall_suspend_state gdb::unique_xmalloc_ptr siginfo_data; }; -struct infcall_suspend_state * -save_infcall_suspend_state (void) +infcall_suspend_state_up +save_infcall_suspend_state () { - struct infcall_suspend_state *inf_state; struct thread_info *tp = inferior_thread (); struct regcache *regcache = get_current_regcache (); struct gdbarch *gdbarch = regcache->arch (); @@ -8840,7 +8839,7 @@ save_infcall_suspend_state (void) } } - inf_state = new struct infcall_suspend_state; + infcall_suspend_state_up inf_state (new struct infcall_suspend_state); if (siginfo_data) { @@ -8920,10 +8919,10 @@ struct infcall_control_state /* Save all of the information associated with the inferior<==>gdb connection. */ -struct infcall_control_state * -save_infcall_control_state (void) +infcall_control_state_up +save_infcall_control_state () { - struct infcall_control_state *inf_status = new struct infcall_control_state; + infcall_control_state_up inf_status (new struct infcall_control_state); struct thread_info *tp = inferior_thread (); struct inferior *inf = current_inferior (); -- 2.17.1