From patchwork Wed May 3 22:46: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: 20251 Received: (qmail 52245 invoked by alias); 3 May 2017 22:46:40 -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 52107 invoked by uid 89); 3 May 2017 22:46:39 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.2 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=H*RU:sk:outboun, 7086, Hx-spam-relays-external:sk:outboun, HX-HELO:sk:outboun 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, 03 May 2017 22:46:36 +0000 Received: from cmgw3 (cmgw4 [10.0.90.84]) by gproxy1.mail.unifiedlayer.com (Postfix) with ESMTP id 03B72175B22 for ; Wed, 3 May 2017 16:46:38 -0600 (MDT) Received: from box522.bluehost.com ([74.220.219.122]) by cmgw3 with id Fyma1v00T2f2jeq01ymdK1; Wed, 03 May 2017 16:46:38 -0600 X-Authority-Analysis: v=2.2 cv=VKStp5HX c=1 sm=1 tr=0 a=GsOEXm/OWkKvwdLVJsfwcA==:117 a=GsOEXm/OWkKvwdLVJsfwcA==:17 a=tJ8p9aeEuA8A:10 a=zstS-IiYAAAA:8 a=D7xREXuaSmSUlEX2HPcA:9 a=4G6NA9xxw8l3yy4pmD5M:22 Received: from 75-166-63-71.hlrn.qwest.net ([75.166.63.71]:53090 helo=bapiya.Home) by box522.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.87) (envelope-from ) id 1d632Y-00051x-Pd; Wed, 03 May 2017 16:46:34 -0600 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [RFA 13/23] Replace tui_restore_gdbout with scoped_restore Date: Wed, 3 May 2017 16:46:16 -0600 Message-Id: <20170503224626.2818-14-tom@tromey.com> In-Reply-To: <20170503224626.2818-1-tom@tromey.com> References: <20170503224626.2818-1-tom@tromey.com> X-BWhitelist: no X-Exim-ID: 1d632Y-00051x-Pd X-Source-Sender: 75-166-63-71.hlrn.qwest.net (bapiya.Home) [75.166.63.71]:53090 X-Source-Auth: tom+tromey.com X-Email-Count: 20 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTIyLmJsdWVob3N0LmNvbQ== 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. 2017-05-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 d288de4..daa7dae 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,10 @@ 2017-05-02 Tom Tromey + * tui/tui-regs.c (tui_restore_gdbout): Remove. + (tui_register_format): Use scoped_restore. + +2017-05-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 3f9a007..ade9cd6 100644 --- a/gdb/tui/tui-regs.c +++ b/gdb/tui/tui-regs.c @@ -708,13 +708,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. */ @@ -722,17 +715,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. */ @@ -741,11 +731,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