From patchwork Wed Feb 27 20:18:30 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 31647 Received: (qmail 114194 invoked by alias); 27 Feb 2019 20:18:56 -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 114169 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=do_cleanups, prototypes, Resume 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:18:54 +0000 Received: from cm11.websitewelcome.com (cm11.websitewelcome.com [100.42.49.5]) by gateway33.websitewelcome.com (Postfix) with ESMTP id 9961F426B7 for ; Wed, 27 Feb 2019 14:18:53 -0600 (CST) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id z5fJg8rXHdnCez5fJg58XR; Wed, 27 Feb 2019 14:18:53 -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=NZYu8bT9oictwuYWN7oLEimJHaV0u2VvqhXTWX9jrPQ=; b=DoISaG/o+A7ZEn46jZHxqoYb8I 3Dqkxl7G2/fgLxhMq48t7dOH8JSkyX2E6zzA/XBMln6y74TOD9oD882rUhEUoFk7nEg35sXFTA7QG h3JrwzjIycNLOYaVDvqAoTwhe; 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-CZ; Wed, 27 Feb 2019 14:18:53 -0600 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH v2 03/22] Change displaced_step_clear_cleanup with a forward_scope_exit Date: Wed, 27 Feb 2019 13:18:30 -0700 Message-Id: <20190227201849.32210-4-tom@tromey.com> In-Reply-To: <20190227201849.32210-1-tom@tromey.com> References: <20190227201849.32210-1-tom@tromey.com> This changes displaced_step_clear_cleanup to be a forward_scope_exit and updates the callers. gdb/ChangeLog 2019-02-27 Tom Tromey * infrun.c (displaced_step_clear_cleanup): Now a forward_scope_exit type. (displaced_step_prepare_throw): Update. (displaced_step_fixup): Update. --- gdb/ChangeLog | 7 +++++++ gdb/infrun.c | 30 +++++++++++------------------- 2 files changed, 18 insertions(+), 19 deletions(-) diff --git a/gdb/infrun.c b/gdb/infrun.c index b32635fc422..582c1f77008 100644 --- a/gdb/infrun.c +++ b/gdb/infrun.c @@ -68,6 +68,7 @@ #include "common/gdb_optional.h" #include "arch-utils.h" #include "common/scope-exit.h" +#include "common/forward-scope-exit.h" /* Prototypes for local functions */ @@ -1598,14 +1599,9 @@ displaced_step_clear (struct displaced_step_inferior_state *displaced) displaced->step_closure = NULL; } -static void -displaced_step_clear_cleanup (void *arg) -{ - struct displaced_step_inferior_state *state - = (struct displaced_step_inferior_state *) arg; - - displaced_step_clear (state); -} +/* A cleanup that wraps displaced_step_clear. */ +using displaced_step_clear_cleanup + = FORWARD_SCOPE_EXIT (displaced_step_clear); /* Dump LEN bytes at BUF in hex to FILE, followed by a newline. */ void @@ -1754,13 +1750,14 @@ displaced_step_prepare_throw (thread_info *tp) displaced->step_original = original; displaced->step_copy = copy; - cleanup *ignore_cleanups - = make_cleanup (displaced_step_clear_cleanup, displaced); + { + displaced_step_clear_cleanup cleanup (displaced); - /* Resume execution at the copy. */ - regcache_write_pc (regcache, copy); + /* Resume execution at the copy. */ + regcache_write_pc (regcache, copy); - discard_cleanups (ignore_cleanups); + cleanup.release (); + } if (debug_displaced) fprintf_unfiltered (gdb_stdlog, "displaced: displaced pc to %s\n", @@ -1850,7 +1847,6 @@ displaced_step_restore (struct displaced_step_inferior_state *displaced, static int displaced_step_fixup (thread_info *event_thread, enum gdb_signal signal) { - struct cleanup *old_cleanups; struct displaced_step_inferior_state *displaced = get_displaced_stepping_state (event_thread->inf); int ret; @@ -1859,7 +1855,7 @@ displaced_step_fixup (thread_info *event_thread, enum gdb_signal signal) if (displaced->step_thread != event_thread) return 0; - old_cleanups = make_cleanup (displaced_step_clear_cleanup, displaced); + displaced_step_clear_cleanup cleanup (displaced); displaced_step_restore (displaced, displaced->step_thread->ptid); @@ -1894,10 +1890,6 @@ displaced_step_fixup (thread_info *event_thread, enum gdb_signal signal) ret = -1; } - do_cleanups (old_cleanups); - - displaced->step_thread = nullptr; - return ret; }