From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 69951 invoked by alias); 13 Feb 2019 21:53:47 -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 69941 invoked by uid 89); 13 Feb 2019 21:53:47 -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: gateway32.websitewelcome.com Received: from gateway32.websitewelcome.com (HELO gateway32.websitewelcome.com) (192.185.145.170) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 13 Feb 2019 21:53:45 +0000 Received: from cm12.websitewelcome.com (cm12.websitewelcome.com [100.42.49.8]) by gateway32.websitewelcome.com (Postfix) with ESMTP id C05403CF79B for ; Wed, 13 Feb 2019 15:29:36 -0600 (CST) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id u264gulp0iQeru264gA29T; Wed, 13 Feb 2019 15:29:36 -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=ZrF0Q55k/NdzT9fTjgY/K0GNGd83SGFITors3o8xKpc=; b=E/FMPvIwzfuUcL/LUi/mNAp9X8 xrGOGSYRAZ/PwJlG1Lo767DP7GnaEdwzqBaX0PsviVjVwg0T9T+K4ztP2YOm1NUYGFUm4EOvvRAsu PJPN/icvCa7NDxTmWhfIsIMH3; Received: from 75-166-72-210.hlrn.qwest.net ([75.166.72.210]:42554 helo=bapiya.Home) by box5379.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.91) (envelope-from ) id 1gu264-001UWe-Ia; Wed, 13 Feb 2019 15:29:36 -0600 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 19/20] Use SCOPE_EXIT in write_gcore_file Date: Wed, 13 Feb 2019 21:53:00 -0000 Message-Id: <20190213212927.9474-20-tom@tromey.com> In-Reply-To: <20190213212927.9474-1-tom@tromey.com> References: <20190213212927.9474-1-tom@tromey.com> X-SW-Source: 2019-02/txt/msg00209.txt.bz2 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-13 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 0684ac17c33..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 (struct gdb_exception_RETURN_MASK_ALL &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. -- 2.17.2