From patchwork Wed Feb 27 20:18:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 31659 Received: (qmail 116501 invoked by alias); 27 Feb 2019 20:19:11 -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 115729 invoked by uid 89); 27 Feb 2019 20:19:06 -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, 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.145.82) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 27 Feb 2019 20:19:01 +0000 Received: from cm16.websitewelcome.com (cm16.websitewelcome.com [100.42.49.19]) by gateway33.websitewelcome.com (Postfix) with ESMTP id 4F957432AC for ; Wed, 27 Feb 2019 14:19:00 -0600 (CST) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id z5fQgYLpB4FKpz5fQgqAQN; Wed, 27 Feb 2019 14:19:00 -0600 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=sYSxK/r6duRKZr3AravFRSnoMNuAI7qQuQ7KzIfmm58=; b=UtcEip+2Of5QQ5yvqWAJkKrmeY CVfKAqgPJ3RAr1lrx1wMsJQWiv69wSeGzW/08A17uNWnSRRG2ebFHew+F3HLUhWVzPOUNRGpWT8mF cWHJAintXTsl6MNgZ9X56vdX4; Received: from 75-166-85-218.hlrn.qwest.net ([75.166.85.218]:36364 helo=bapiya.Home) by box5379.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.91) (envelope-from ) id 1gz5fQ-004Fi1-3P; Wed, 27 Feb 2019 14:19:00 -0600 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH v2 21/22] Use SCOPE_EXIT in write_gcore_file Date: Wed, 27 Feb 2019 13:18:48 -0700 Message-Id: <20190227201849.32210-22-tom@tromey.com> In-Reply-To: <20190227201849.32210-1-tom@tromey.com> References: <20190227201849.32210-1-tom@tromey.com> This replaces a try/catch in write_gcore_file with a use of SCOPE_EXIT instead. I find that this is simpler to understand. gdb/ChangeLog 2019-02-27 Tom Tromey * gcore.c (write_gcore_file): Use SCOPE_EXIT. --- gdb/ChangeLog | 4 ++++ gdb/gcore.c | 19 +++---------------- 2 files changed, 7 insertions(+), 16 deletions(-) diff --git a/gdb/gcore.c b/gdb/gcore.c index 0e4596241b7..21d9ee88671 100644 --- a/gdb/gcore.c +++ b/gdb/gcore.c @@ -37,6 +37,7 @@ #include #include "common/gdb_unlinker.h" #include "common/byte-vector.h" +#include "common/scope-exit.h" /* The largest amount of memory to read from the target at once. We must throttle it to limit the amount of memory used by GDB during @@ -114,23 +115,9 @@ write_gcore_file_1 (bfd *obfd) void write_gcore_file (bfd *obfd) { - struct gdb_exception except = exception_none; - target_prepare_to_generate_core (); - - try - { - write_gcore_file_1 (obfd); - } - catch (const struct gdb_exception &e) - { - except = e; - } - - target_done_generating_core (); - - if (except.reason < 0) - throw_exception (except); + SCOPE_EXIT { target_done_generating_core (); }; + write_gcore_file_1 (obfd); } /* gcore_command -- implements the 'gcore' command.