From patchwork Wed Jan 23 15:21:22 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pedro Alves X-Patchwork-Id: 31186 Received: (qmail 64874 invoked by alias); 23 Jan 2019 15:21:45 -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 64762 invoked by uid 89); 23 Jan 2019 15:21:45 -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, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 23 Jan 2019 15:21:43 +0000 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 71FB88B101; Wed, 23 Jan 2019 15:21:42 +0000 (UTC) Received: from localhost.localdomain (ovpn04.gateway.prod.ext.ams2.redhat.com [10.39.146.4]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9A69E67141; Wed, 23 Jan 2019 15:21:41 +0000 (UTC) From: Pedro Alves To: gdb-patches@sourceware.org Cc: Tom Tromey , Andrew Burgess Subject: [PATCH v3 08/17] Remove delete_just_stopped_threads_infrun_breakpoints_cleanup Date: Wed, 23 Jan 2019 15:21:22 +0000 Message-Id: <20190123152131.29893-9-palves@redhat.com> In-Reply-To: <20190123152131.29893-1-palves@redhat.com> References: <20190123152131.29893-1-palves@redhat.com> From: Tom Tromey v3: sorted earlier in the series, and replaces the cleanup in fetch_inferior_event here too instead of in some other patch. This removes delete_just_stopped_threads_infrun_breakpoints_cleanup, replacing it with uses of scope_exit. gdb/ChangeLog: yyyy-mm-dd Tom Tromey Pedro Alves * infrun.c: Include "common/scope-exit.h" (delete_just_stopped_threads_infrun_breakpoints_cleanup): Remove. (wait_for_inferior): Use SCOPE_EXIT. (fetch_inferior_event): Use scope_exit. --- gdb/infrun.c | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-) diff --git a/gdb/infrun.c b/gdb/infrun.c index 150288264f..065fbf06d8 100644 --- a/gdb/infrun.c +++ b/gdb/infrun.c @@ -67,6 +67,7 @@ #include "progspace-and-thread.h" #include "common/gdb_optional.h" #include "arch-utils.h" +#include "common/scope-exit.h" /* Prototypes for local functions */ @@ -3247,14 +3248,6 @@ delete_just_stopped_threads_single_step_breakpoints (void) for_each_just_stopped_thread (delete_single_step_breakpoints); } -/* A cleanup wrapper. */ - -static void -delete_just_stopped_threads_infrun_breakpoints_cleanup (void *arg) -{ - delete_just_stopped_threads_infrun_breakpoints (); -} - /* See infrun.h. */ void @@ -3538,15 +3531,11 @@ prepare_for_detach (void) void wait_for_inferior (void) { - struct cleanup *old_cleanups; - if (debug_infrun) fprintf_unfiltered (gdb_stdlog, "infrun: wait_for_inferior ()\n"); - old_cleanups - = make_cleanup (delete_just_stopped_threads_infrun_breakpoints_cleanup, - NULL); + SCOPE_EXIT { delete_just_stopped_threads_infrun_breakpoints (); }; /* If an error happens while handling the event, propagate GDB's knowledge of the executing state to the frontend/user running @@ -3583,8 +3572,6 @@ wait_for_inferior (void) /* No error, don't finish the state yet. */ finish_state.release (); - - do_cleanups (old_cleanups); } /* Cleanup that reinstalls the readline callback handler, if the @@ -3760,7 +3747,8 @@ fetch_inferior_event (void *client_data) still for the thread which has thrown the exception. */ struct cleanup *ts_old_chain = make_bpstat_clear_actions_cleanup (); - make_cleanup (delete_just_stopped_threads_infrun_breakpoints_cleanup, NULL); + auto defer_delete_threads + = make_scope_exit (delete_just_stopped_threads_infrun_breakpoints); /* Now figure out what to do with the result of the result. */ handle_inferior_event (ecs); @@ -3813,6 +3801,7 @@ fetch_inferior_event (void *client_data) } } + defer_delete_threads.release (); discard_cleanups (ts_old_chain); /* No error, don't finish the thread states yet. */