From patchwork Wed Feb 27 20:18:32 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 31648 Received: (qmail 114284 invoked by alias); 27 Feb 2019 20:18:57 -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 114195 invoked by uid 89); 27 Feb 2019 20:18:56 -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: gateway21.websitewelcome.com Received: from gateway21.websitewelcome.com (HELO gateway21.websitewelcome.com) (192.185.45.43) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 27 Feb 2019 20:18:55 +0000 Received: from cm16.websitewelcome.com (cm16.websitewelcome.com [100.42.49.19]) by gateway21.websitewelcome.com (Postfix) with ESMTP id 34928400DC96D for ; Wed, 27 Feb 2019 14:18:54 -0600 (CST) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id z5fKgYLhw4FKpz5fKgqAJB; Wed, 27 Feb 2019 14:18:54 -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=EV+SZ1laszYWG5ZldtzIc72coS1+ho7K9FCROpT/a70=; b=Mx3dkoOaz7jgvrB2eBbjiTH0XF 5q1OMx1Z/ZY20qqNL3wE7/Po1ZXI5Jsmw3Gp4tfQhX38v775HCX5MQuCcS/7YHWfjHzJ3SBDxJHea l31VeWoPJLROEEc5wBq9FV9bS; 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 1gz5fJ-004Fi1-Vg; Wed, 27 Feb 2019 14:18:54 -0600 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH v2 05/22] Remove last cleanup from gdbserver Date: Wed, 27 Feb 2019 13:18:32 -0700 Message-Id: <20190227201849.32210-6-tom@tromey.com> In-Reply-To: <20190227201849.32210-1-tom@tromey.com> References: <20190227201849.32210-1-tom@tromey.com> This removes the last cleanup from gdbserver, replacing it with SCOPE_EXIT. This could perhaps be done in a different way, but this approach was direct and obviously correct. gdb/gdbserver/ChangeLog 2019-02-27 Tom Tromey * server.c (detach_or_kill_for_exit_cleanup): Remove parameter. (captured_main): Use SCOPE_EXIT. --- gdb/gdbserver/ChangeLog | 5 +++++ gdb/gdbserver/server.c | 11 ++++++----- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/gdb/gdbserver/server.c b/gdb/gdbserver/server.c index e960c10d402..25c62aad830 100644 --- a/gdb/gdbserver/server.c +++ b/gdb/gdbserver/server.c @@ -43,6 +43,7 @@ #include "common/pathstuff.h" #include "common/selftest.h" +#include "common/scope-exit.h" #define require_running_or_return(BUF) \ if (!target_running ()) \ @@ -3545,17 +3546,16 @@ detach_or_kill_for_exit (void) /* Value that will be passed to exit(3) when gdbserver exits. */ static int exit_code; -/* Cleanup version of detach_or_kill_for_exit. */ +/* Wrapper for detach_or_kill_for_exit that catches and prints + errors. */ static void -detach_or_kill_for_exit_cleanup (void *ignore) +detach_or_kill_for_exit_cleanup () { - TRY { detach_or_kill_for_exit (); } - CATCH (exception, RETURN_MASK_ALL) { fflush (stdout); @@ -3832,7 +3832,8 @@ captured_main (int argc, char *argv[]) cs.last_status.value.integer = 0; cs.last_ptid = minus_one_ptid; } - make_cleanup (detach_or_kill_for_exit_cleanup, NULL); + + SCOPE_EXIT { detach_or_kill_for_exit_cleanup (); }; /* Don't report shared library events on the initial connection, even if some libraries are preloaded. Avoids the "stopped by