From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 64741 invoked by alias); 3 Sep 2018 19:03:18 -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 64688 invoked by uid 89); 3 Sep 2018 19:03:18 -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,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=1986, trashed X-HELO: gateway22.websitewelcome.com Received: from gateway22.websitewelcome.com (HELO gateway22.websitewelcome.com) (192.185.47.109) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 03 Sep 2018 19:03:16 +0000 Received: from cm15.websitewelcome.com (cm15.websitewelcome.com [100.42.49.9]) by gateway22.websitewelcome.com (Postfix) with ESMTP id 346C58DE6 for ; Mon, 3 Sep 2018 14:03:15 -0500 (CDT) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id wu7hfhHQfbXuJwu7tf1hBL; Mon, 03 Sep 2018 14:03:14 -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=mh33HAigcoeeaNZbzkuT7cuw5Oonjid62rjuaF2gkqM=; b=IyVCqZQIdffv+ryBbzLyjocp+n MWvQnu0Dga3q55gqWPTQNubWjLHTrg+HrfkbWp6yHquwwJ+PVGlai5/29u+ewcE8iSvo2jzxgE9po btaa+23/pQFxPsL3pJeYZ7Gso; Received: from 75-166-85-72.hlrn.qwest.net ([75.166.85.72]:58120 helo=bapiya.Home) by box5379.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.91) (envelope-from ) id 1fwu7h-002juS-3P; Mon, 03 Sep 2018 14:02:53 -0500 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 4/4] Remove cleanup from try_open_exec_file Date: Mon, 03 Sep 2018 19:03:00 -0000 Message-Id: <20180903190250.11599-5-tom@tromey.com> In-Reply-To: <20180903190250.11599-1-tom@tromey.com> References: <20180903190250.11599-1-tom@tromey.com> X-SW-Source: 2018-09/txt/msg00029.txt.bz2 This removes a cleanup from try_open_exec_file, using std::string to manage the storage instead. gdb/ChangeLog 2018-09-03 Tom Tromey * exec.c (try_open_exec_file): Use std::string. --- gdb/ChangeLog | 4 ++++ gdb/exec.c | 11 +++++------ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/gdb/exec.c b/gdb/exec.c index 6e44b0e821b..615fb2b5dbc 100644 --- a/gdb/exec.c +++ b/gdb/exec.c @@ -149,11 +149,8 @@ void try_open_exec_file (const char *exec_file_host, struct inferior *inf, symfile_add_flags add_flags) { - struct cleanup *old_chain; struct gdb_exception prev_err = exception_none; - old_chain = make_cleanup (free_current_contents, &prev_err.message); - /* exec_file_attach and symbol_file_add_main may throw an error if the file cannot be opened either locally or remotely. @@ -165,6 +162,7 @@ try_open_exec_file (const char *exec_file_host, struct inferior *inf, Even without a symbol file, the remote-based debugging session should continue normally instead of ending abruptly. Hence we catch thrown errors/exceptions in the following code. */ + std::string saved_message; TRY { /* We must do this step even if exec_file_host is NULL, so that @@ -180,7 +178,10 @@ try_open_exec_file (const char *exec_file_host, struct inferior *inf, /* Save message so it doesn't get trashed by the catch below. */ if (err.message != NULL) - prev_err.message = xstrdup (err.message); + { + saved_message = err.message; + prev_err.message = saved_message.c_str (); + } } END_CATCH @@ -197,8 +198,6 @@ try_open_exec_file (const char *exec_file_host, struct inferior *inf, } END_CATCH } - - do_cleanups (old_chain); } /* See gdbcore.h. */ -- 2.13.6