From patchwork Mon Oct 9 23:47:57 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 23420 Received: (qmail 732 invoked by alias); 9 Oct 2017 23:48:37 -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 109323 invoked by uid 89); 9 Oct 2017 23:48:21 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-23.9 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: outbound-ss-1812.hostmonster.com Received: from gproxy1-pub.mail.unifiedlayer.com (HELO outbound-ss-1812.hostmonster.com) (69.89.25.95) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 09 Oct 2017 23:48:09 +0000 Received: from cmgw2 (cmgw3 [10.0.90.83]) by gproxy1.mail.unifiedlayer.com (Postfix) with ESMTP id 1A195175AD4 for ; Mon, 9 Oct 2017 17:48:07 -0600 (MDT) Received: from box522.bluehost.com ([74.220.219.122]) by cmgw2 with id Kbo41w0032f2jeq01bo7zi; Mon, 09 Oct 2017 17:48:07 -0600 X-Authority-Analysis: v=2.2 cv=dZfw5Tfe c=1 sm=1 tr=0 a=GsOEXm/OWkKvwdLVJsfwcA==:117 a=GsOEXm/OWkKvwdLVJsfwcA==:17 a=02M-m0pO-4AA:10 a=zstS-IiYAAAA:8 a=Mz73WAz5LvB5S_xjkPsA:9 a=9fYjyosxCTmhnc7C:21 a=LYdnyRcRYIFlpuON:21 a=4G6NA9xxw8l3yy4pmD5M:22 Received: from 184-96-33-178.hlrn.qwest.net ([184.96.33.178]:44720 helo=bapiya.localdomain) by box522.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.87) (envelope-from ) id 1e1hmF-0048rI-Sk; Mon, 09 Oct 2017 17:48:03 -0600 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [RFA 2/2] Remove prepare_re_set_context Date: Mon, 9 Oct 2017 17:47:57 -0600 Message-Id: <20171009234757.14624-3-tom@tromey.com> In-Reply-To: <20171009234757.14624-1-tom@tromey.com> References: <20171009234757.14624-1-tom@tromey.com> X-BWhitelist: no X-Exim-ID: 1e1hmF-0048rI-Sk X-Source-Sender: 184-96-33-178.hlrn.qwest.net (bapiya.localdomain) [184.96.33.178]:44720 X-Source-Auth: tom+tromey.com X-Email-Count: 4 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTIyLmJsdWVob3N0LmNvbQ== X-Local-Domain: yes prepare_re_set_context returns a null cleanup and doesn't seem generally useful. This patch removes it plus a few more cleanups; and changes breakpoint_re_set to use scoped_restore rather than its own manual mechanism. ChangeLog 2017-10-09 Tom Tromey * breakpoint.c (prepare_re_set_context): Remove. (breakpoint_re_set_one): Update. Don't use cleanups. (breakpoint_re_set): Use scoped_restore, std::string, and scoped_restore_current_language. --- gdb/ChangeLog | 7 +++++++ gdb/breakpoint.c | 36 ++++++++++-------------------------- 2 files changed, 17 insertions(+), 26 deletions(-) diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index e56858286c..2eba1e9c48 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -14088,17 +14088,6 @@ decode_location_default (struct breakpoint *b, return {}; } -/* Prepare the global context for a re-set of breakpoint B. */ - -static struct cleanup * -prepare_re_set_context (struct breakpoint *b) -{ - input_radix = b->input_radix; - set_language (b->language); - - return make_cleanup (null_cleanup, NULL); -} - /* Reset a breakpoint given it's struct breakpoint * BINT. The value we return ends up being the return value from catch_errors. Unused in this case. */ @@ -14108,11 +14097,11 @@ breakpoint_re_set_one (void *bint) { /* Get past catch_errs. */ struct breakpoint *b = (struct breakpoint *) bint; - struct cleanup *cleanups; - cleanups = prepare_re_set_context (b); + input_radix = b->input_radix; + set_language (b->language); + b->ops->re_set (b); - do_cleanups (cleanups); return 0; } @@ -14123,13 +14112,10 @@ void breakpoint_re_set (void) { struct breakpoint *b, *b_tmp; - enum language save_language; - int save_input_radix; - - save_language = current_language->la_language; - save_input_radix = input_radix; { + scoped_restore_current_language save_language; + scoped_restore save_input_radix = make_scoped_restore (&input_radix); scoped_restore_current_pspace_and_thread restore_pspace_thread; /* Note: we must not try to insert locations until after all @@ -14140,14 +14126,12 @@ breakpoint_re_set (void) ALL_BREAKPOINTS_SAFE (b, b_tmp) { /* Format possible error msg. */ - char *message = xstrprintf ("Error in re-setting breakpoint %d: ", - b->number); - struct cleanup *cleanups = make_cleanup (xfree, message); - catch_errors (breakpoint_re_set_one, b, message, RETURN_MASK_ALL); - do_cleanups (cleanups); + std::string message + = string_printf ("Error in re-setting breakpoint %d: ", + b->number); + catch_errors (breakpoint_re_set_one, b, message.c_str (), + RETURN_MASK_ALL); } - set_language (save_language); - input_radix = save_input_radix; jit_breakpoint_re_set (); }