From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 113900 invoked by alias); 30 Apr 2018 05:12:15 -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 113761 invoked by uid 89); 30 Apr 2018 05:12:14 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.8 required=5.0 tests=AWL,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=hooks X-HELO: gateway24.websitewelcome.com Received: from gateway24.websitewelcome.com (HELO gateway24.websitewelcome.com) (192.185.51.56) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 30 Apr 2018 05:12:13 +0000 Received: from cm17.websitewelcome.com (cm17.websitewelcome.com [100.42.49.20]) by gateway24.websitewelcome.com (Postfix) with ESMTP id 184A512109 for ; Mon, 30 Apr 2018 00:12:10 -0500 (CDT) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id D16gfPeMly2aLD16gfkdyy; Mon, 30 Apr 2018 00:12:10 -0500 X-Authority-Reason: nr=8 Received: from 97-122-176-117.hlrn.qwest.net ([97.122.176.117]:35688 helo=bapiya.Home) by box5379.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.89_1) (envelope-from ) id 1fD16f-0025zZ-RS; Mon, 30 Apr 2018 00:12:09 -0500 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [RFA 1/4] Use scoped_restore in a couple of interp-related places Date: Mon, 30 Apr 2018 05:12:00 -0000 Message-Id: <20180430051207.19979-2-tom@tromey.com> In-Reply-To: <20180430051207.19979-1-tom@tromey.com> References: <20180430051207.19979-1-tom@tromey.com> X-BWhitelist: no X-Source-L: No X-Exim-ID: 1fD16f-0025zZ-RS X-Source-Sender: 97-122-176-117.hlrn.qwest.net (bapiya.Home) [97.122.176.117]:35688 X-Source-Auth: tom+tromey.com X-Email-Count: 2 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-SW-Source: 2018-04/txt/msg00613.txt.bz2 While looking through the "interp" code I found a couple of spots that could use scoped_restore. ChangeLog 2018-04-29 Tom Tromey * cli/cli-interp.c (safe_execute_command): Ues scoped_restore. * interps.c (interp_exec): Use scoped_restore. --- gdb/ChangeLog | 5 +++++ gdb/cli/cli-interp.c | 8 ++------ gdb/interps.c | 13 +++---------- 3 files changed, 10 insertions(+), 16 deletions(-) diff --git a/gdb/cli/cli-interp.c b/gdb/cli/cli-interp.c index bbee809880..0663301c19 100644 --- a/gdb/cli/cli-interp.c +++ b/gdb/cli/cli-interp.c @@ -356,11 +356,10 @@ safe_execute_command (struct ui_out *command_uiout, const char *command, int from_tty) { struct gdb_exception e = exception_none; - struct ui_out *saved_uiout; /* Save and override the global ``struct ui_out'' builder. */ - saved_uiout = current_uiout; - current_uiout = command_uiout; + scoped_restore saved_uiout = make_scoped_restore (¤t_uiout, + command_uiout); TRY { @@ -372,9 +371,6 @@ safe_execute_command (struct ui_out *command_uiout, const char *command, } END_CATCH - /* Restore the global builder. */ - current_uiout = saved_uiout; - /* FIXME: cagney/2005-01-13: This shouldn't be needed. Instead the caller should print the exception. */ exception_print (gdb_stderr, e); diff --git a/gdb/interps.c b/gdb/interps.c index 61db7f4bdf..162cd838ec 100644 --- a/gdb/interps.c +++ b/gdb/interps.c @@ -354,18 +354,11 @@ interp_exec (struct interp *interp, const char *command_str) { struct ui_interp_info *ui_interp = get_current_interp_info (); - struct gdb_exception ex; - struct interp *save_command_interp; - /* See `command_interp' for why we do this. */ - save_command_interp = ui_interp->command_interpreter; - ui_interp->command_interpreter = interp; - - ex = interp->exec (command_str); - - ui_interp->command_interpreter = save_command_interp; + scoped_restore save_command_interp + = make_scoped_restore (&ui_interp->command_interpreter, interp); - return ex; + return interp->exec (command_str); } /* A convenience routine that nulls out all the common command hooks. -- 2.13.6