From patchwork Tue Sep 27 04:08:32 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 16053 Received: (qmail 94003 invoked by alias); 27 Sep 2016 04:47:35 -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 93963 invoked by uid 89); 27 Sep 2016 04:47:34 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.1 required=5.0 tests=AWL, BAYES_05, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=no version=3.3.2 spammy=H*r:4.86_1, Events, H*RU:10.0.90.82, H*r:CMOut01 X-HELO: gproxy8-pub.mail.unifiedlayer.com Received: from gproxy8-pub.mail.unifiedlayer.com (HELO gproxy8-pub.mail.unifiedlayer.com) (67.222.33.93) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with SMTP; Tue, 27 Sep 2016 04:47:27 +0000 Received: (qmail 6608 invoked by uid 0); 27 Sep 2016 04:47:26 -0000 Received: from unknown (HELO CMOut01) (10.0.90.82) by gproxy8.mail.unifiedlayer.com with SMTP; 27 Sep 2016 04:47:26 -0000 Received: from box522.bluehost.com ([74.220.219.122]) by CMOut01 with id oUnM1t00V2f2jeq01UnQ2t; Mon, 26 Sep 2016 22:47:24 -0600 X-Authority-Analysis: v=2.1 cv=OPq0g0qB c=1 sm=1 tr=0 a=GsOEXm/OWkKvwdLVJsfwcA==:117 a=GsOEXm/OWkKvwdLVJsfwcA==:17 a=L9H7d07YOLsA:10 a=9cW_t1CCXrUA:10 a=s5jvgZ67dGcA:10 a=GW1xBdLrtEIA:10 a=zstS-IiYAAAA:8 a=2Jq7SzdAO3LGmTyVaHQA:9 a=4G6NA9xxw8l3yy4pmD5M:22 Received: from 71-218-192-86.hlrn.qwest.net ([71.218.192.86]:56110 helo=bapiya.Home) by box522.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.86_1) (envelope-from ) id 1bojhO-0006Nj-1h; Mon, 26 Sep 2016 22:08:54 -0600 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [RFA 04/22] Use scoped_restore for current_ui Date: Mon, 26 Sep 2016 22:08:32 -0600 Message-Id: <1474949330-4307-5-git-send-email-tom@tromey.com> In-Reply-To: <1474949330-4307-1-git-send-email-tom@tromey.com> References: <1474949330-4307-1-git-send-email-tom@tromey.com> X-BWhitelist: no X-Exim-ID: 1bojhO-0006Nj-1h X-Source-Sender: 71-218-192-86.hlrn.qwest.net (bapiya.Home) [71.218.192.86]:56110 X-Source-Auth: tom+tromey.com X-Email-Count: 23 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTIyLmJsdWVob3N0LmNvbQ== This changes most uses of make_cleanup_restore_current_ui to use scoped_restore. The use in switch_thru_all_uis_init still remains; that can be dealt with by replacing this iterator with a real class. 2016-09-26 Tom Tromey * top.c (new_ui_command, wait_sync_command_done) (gdb_readline_wrapper): Use scoped_restore. * infrun.c (fetch_inferior_event): Use scoped_restore. * infcall.c (call_thread_fsm_should_stop): Use scoped_restore. --- gdb/ChangeLog | 7 +++++++ gdb/infcall.c | 8 +------- gdb/infrun.c | 3 +-- gdb/top.c | 44 ++++++++++++++++++++++---------------------- 4 files changed, 31 insertions(+), 31 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index da69ce8..42c432d 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,12 @@ 2016-09-26 Tom Tromey + * top.c (new_ui_command, wait_sync_command_done) + (gdb_readline_wrapper): Use scoped_restore. + * infrun.c (fetch_inferior_event): Use scoped_restore. + * infcall.c (call_thread_fsm_should_stop): Use scoped_restore. + +2016-09-26 Tom Tromey + * utils.c (make_cleanup_restore_ui_file, do_restore_ui_file) (struct restore_ui_file_closure): Remove. * utils.h (make_cleanup_restore_ui_file): Don't declare. diff --git a/gdb/infcall.c b/gdb/infcall.c index 3c33c11..60b0a70 100644 --- a/gdb/infcall.c +++ b/gdb/infcall.c @@ -519,8 +519,6 @@ call_thread_fsm_should_stop (struct thread_fsm *self, if (stop_stack_dummy == STOP_STACK_DUMMY) { - struct cleanup *old_chain; - /* Done. */ thread_fsm_set_finished (self); @@ -530,13 +528,9 @@ call_thread_fsm_should_stop (struct thread_fsm *self, f->return_value = get_call_return_value (&f->return_meta_info); /* Break out of wait_sync_command_done. */ - old_chain = make_cleanup_restore_current_ui (); - current_ui = f->waiting_ui; + scoped_restore save_ui (¤t_ui, f->waiting_ui); target_terminal_ours (); f->waiting_ui->prompt_state = PROMPT_NEEDED; - - /* This restores the previous UI. */ - do_cleanups (old_chain); } return 1; diff --git a/gdb/infrun.c b/gdb/infrun.c index 7832a5d..6d96af9 100644 --- a/gdb/infrun.c +++ b/gdb/infrun.c @@ -3903,8 +3903,7 @@ fetch_inferior_event (void *client_data) /* Events are always processed with the main UI as current UI. This way, warnings, debug output, etc. are always consistently sent to the main console. */ - make_cleanup_restore_current_ui (); - current_ui = main_ui; + scoped_restore save_ui (¤t_ui, main_ui); /* End up with readline processing input, if necessary. */ make_cleanup (reinstall_readline_callback_handler_cleanup, NULL); diff --git a/gdb/top.c b/gdb/top.c index d782466..77845c0 100644 --- a/gdb/top.c +++ b/gdb/top.c @@ -386,33 +386,35 @@ new_ui_command (char *args, int from_tty) interpreter_name = argv[0]; tty_name = argv[1]; - make_cleanup_restore_current_ui (); + { + scoped_restore save_ui (¤t_ui); - failure_chain = make_cleanup (null_cleanup, NULL); + failure_chain = make_cleanup (null_cleanup, NULL); - /* Open specified terminal, once for each of - stdin/stdout/stderr. */ - for (i = 0; i < 3; i++) - { - stream[i] = open_terminal_stream (tty_name); - make_cleanup_fclose (stream[i]); - } + /* Open specified terminal, once for each of + stdin/stdout/stderr. */ + for (i = 0; i < 3; i++) + { + stream[i] = open_terminal_stream (tty_name); + make_cleanup_fclose (stream[i]); + } - ui = new_ui (stream[0], stream[1], stream[2]); - make_cleanup (delete_ui_cleanup, ui); + ui = new_ui (stream[0], stream[1], stream[2]); + make_cleanup (delete_ui_cleanup, ui); - ui->async = 1; + ui->async = 1; - current_ui = ui; + current_ui = ui; - set_top_level_interpreter (interpreter_name); + set_top_level_interpreter (interpreter_name); - interp_pre_command_loop (top_level_interpreter ()); + interp_pre_command_loop (top_level_interpreter ()); - discard_cleanups (failure_chain); + discard_cleanups (failure_chain); - /* This restores the previous UI and frees argv. */ - do_cleanups (success_chain); + /* This restores the previous UI and frees argv. */ + do_cleanups (success_chain); + } printf_unfiltered ("New UI allocated\n"); } @@ -562,14 +564,12 @@ void wait_sync_command_done (void) { /* Processing events may change the current UI. */ - struct cleanup *old_chain = make_cleanup_restore_current_ui (); + scoped_restore save_ui (¤t_ui); struct ui *ui = current_ui; while (gdb_do_one_event () >= 0) if (ui->prompt_state != PROMPT_BLOCKED) break; - - do_cleanups (old_chain); } /* See top.h. */ @@ -1031,7 +1031,7 @@ gdb_readline_wrapper (const char *prompt) back_to = make_cleanup (gdb_readline_wrapper_cleanup, cleanup); /* Processing events may change the current UI. */ - make_cleanup_restore_current_ui (); + scoped_restore save_ui (¤t_ui); if (cleanup->target_is_async_orig) target_async (0);