From patchwork Wed Aug 2 15:02:16 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 21844 Received: (qmail 24745 invoked by alias); 2 Aug 2017 15:02:43 -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 24713 invoked by uid 89); 2 Aug 2017 15:02:42 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.9 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, 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; Wed, 02 Aug 2017 15:02:40 +0000 Received: from CMOut01 (cmgw2 [10.0.90.82]) by gproxy1.mail.unifiedlayer.com (Postfix) with ESMTP id 9A168175D06 for ; Wed, 2 Aug 2017 09:02:39 -0600 (MDT) Received: from box522.bluehost.com ([74.220.219.122]) by CMOut01 with id sF2c1v01d2f2jeq01F2fnU; Wed, 02 Aug 2017 09:02:39 -0600 X-Authority-Analysis: v=2.2 cv=XMVAcUpE c=1 sm=1 tr=0 a=GsOEXm/OWkKvwdLVJsfwcA==:117 a=GsOEXm/OWkKvwdLVJsfwcA==:17 a=KeKAF7QvOSUA:10 a=zstS-IiYAAAA:8 a=D7xREXuaSmSUlEX2HPcA:9 a=4G6NA9xxw8l3yy4pmD5M:22 Received: from 174-29-39-24.hlrn.qwest.net ([174.29.39.24]:54692 helo=bapiya.Home) by box522.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.87) (envelope-from ) id 1dcvAS-002dpC-CK; Wed, 02 Aug 2017 09:02:36 -0600 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [RFA v3 12/23] Replace tui_restore_gdbout with scoped_restore Date: Wed, 2 Aug 2017 09:02:16 -0600 Message-Id: <20170802150227.24460-13-tom@tromey.com> In-Reply-To: <20170802150227.24460-1-tom@tromey.com> References: <20170802150227.24460-1-tom@tromey.com> X-BWhitelist: no X-Exim-ID: 1dcvAS-002dpC-CK X-Source-Sender: 174-29-39-24.hlrn.qwest.net (bapiya.Home) [174.29.39.24]:54692 X-Source-Auth: tom+tromey.com X-Email-Count: 13 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTIyLmJsdWVob3N0LmNvbQ== X-Local-Domain: yes This patch replaces tui_restore_gdbout (a cleaup function) with a use of scoped_restore. This one is broken out into its own patch because it might slightly change the behavior of gdb: it saves and restores pagination_enabled, whereas the tui_restore_gdbout unconditionally set pagination_enabled to 1; and I think this warrants closer review. ChangeLog 2017-08-02 Tom Tromey * tui/tui-regs.c (tui_restore_gdbout): Remove. (tui_register_format): Use scoped_restore. --- gdb/ChangeLog | 5 +++++ gdb/tui/tui-regs.c | 26 ++++++-------------------- 2 files changed, 11 insertions(+), 20 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 831851b..41095af 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,10 @@ 2017-08-02 Tom Tromey + * tui/tui-regs.c (tui_restore_gdbout): Remove. + (tui_register_format): Use scoped_restore. + +2017-08-02 Tom Tromey + * reverse.c (exec_direction_default): Remove. (exec_reverse_once): Use scoped_restore. * remote.c (restore_remote_timeout): Remove. diff --git a/gdb/tui/tui-regs.c b/gdb/tui/tui-regs.c index c418203..217fff2 100644 --- a/gdb/tui/tui-regs.c +++ b/gdb/tui/tui-regs.c @@ -707,13 +707,6 @@ TUI command to control the register window."), tuicmd); ** STATIC LOCAL FUNCTIONS ** ******************************************/ -static void -tui_restore_gdbout (void *ui) -{ - gdb_stdout = (struct ui_file*) ui; - pagination_enabled = 1; -} - /* Get the register from the frame and return a printable representation of it. */ @@ -721,17 +714,14 @@ static char * tui_register_format (struct frame_info *frame, int regnum) { struct gdbarch *gdbarch = get_frame_arch (frame); - struct ui_file *old_stdout; - struct cleanup *cleanups; - char *p, *s; - char *ret; string_file stream; - pagination_enabled = 0; - old_stdout = gdb_stdout; - gdb_stdout = &stream; - cleanups = make_cleanup (tui_restore_gdbout, (void*) old_stdout); + scoped_restore save_pagination + = make_scoped_restore (&pagination_enabled, 0); + scoped_restore save_stdout + = make_scoped_restore (&gdb_stdout, &stream); + gdbarch_print_registers_info (gdbarch, &stream, frame, regnum, 1); /* Remove the possible \n. */ @@ -740,11 +730,7 @@ tui_register_format (struct frame_info *frame, int regnum) str.resize (str.size () - 1); /* Expand tabs into spaces, since ncurses on MS-Windows doesn't. */ - ret = tui_expand_tabs (str.c_str (), 0); - - do_cleanups (cleanups); - - return ret; + return tui_expand_tabs (str.c_str (), 0); } /* Get the register value from the given frame and format it for the