From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15505 invoked by alias); 20 Oct 2016 21:46:50 -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 15496 invoked by uid 89); 20 Oct 2016 21:46:50 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.3 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_NONE,RCVD_IN_SORBS_SPAM,SPF_PASS autolearn=no version=3.3.2 spammy=briefly, H*RU:sk:gproxy1, HX-HELO:sk:gproxy1, Hx-spam-relays-external:sk:gproxy1 X-HELO: gproxy10-pub.mail.unifiedlayer.com Received: from gproxy10-pub.mail.unifiedlayer.com (HELO gproxy10-pub.mail.unifiedlayer.com) (69.89.20.226) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with SMTP; Thu, 20 Oct 2016 21:46:40 +0000 Received: (qmail 7108 invoked by uid 0); 20 Oct 2016 21:46:38 -0000 Received: from unknown (HELO CMOut01) (10.0.90.82) by gproxy10.mail.unifiedlayer.com with SMTP; 20 Oct 2016 21:46:38 -0000 Received: from box522.bluehost.com ([74.220.219.122]) by CMOut01 with id xxmZ1t00x2f2jeq01xmc02; Thu, 20 Oct 2016 15:46:36 -0600 X-Authority-Analysis: v=2.1 cv=beT4Do/B 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=CH0kA5CcgfcA:10 a=zstS-IiYAAAA:8 a=JkwltBFiMzo1WeoW0gMA:9 a=4G6NA9xxw8l3yy4pmD5M:22 Received: from 174-16-143-211.hlrn.qwest.net ([174.16.143.211]:55876 helo=bapiya) by box522.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.86_1) (envelope-from ) id 1bxLAZ-0003rx-6e; Thu, 20 Oct 2016 15:46:35 -0600 From: Tom Tromey To: Tom Tromey Cc: Pedro Alves , gdb-patches@sourceware.org Subject: Re: [RFA v2 12/17] Remove make_cleanup_restore_current_uiout References: <1476393012-29987-1-git-send-email-tom@tromey.com> <1476393012-29987-13-git-send-email-tom@tromey.com> <87r37iliuw.fsf@tromey.com> Date: Thu, 20 Oct 2016 21:46:00 -0000 In-Reply-To: <87r37iliuw.fsf@tromey.com> (Tom Tromey's message of "Fri, 14 Oct 2016 15:29:43 -0600") Message-ID: <87pomuhex4.fsf@tromey.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-BWhitelist: no X-Exim-ID: 1bxLAZ-0003rx-6e X-Source-Sender: 174-16-143-211.hlrn.qwest.net (bapiya) [174.16.143.211]:55876 X-Source-Auth: tom+tromey.com X-Email-Count: 2 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTIyLmJsdWVob3N0LmNvbQ== X-SW-Source: 2016-10/txt/msg00621.txt.bz2 Pedro> I wonder if you had a reasoning that led to deciding when Pedro> to use two-argument form? A couple places looked like obvious Pedro> candidates. My reasoning would be: if the assignment is right Pedro> after the scoped_restore creation. Tom> I tried to use them everywhere, but I just forgot to restore it in this Tom> patch when I added the two-arg form back. I'll fix this up. Here's the updated patch. Tom diff --git a/gdb/ChangeLog b/gdb/ChangeLog index f2743fe..d2ab393 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,13 @@ 2016-10-20 Tom Tromey + * stack.c (print_stack_frame_to_uiout): Use scoped_restore. + * ui-out.c (make_cleanup_restore_current_uiout) + (restore_current_uiout_cleanup): Remove. + * infrun.c (print_stop_event): Use scoped_restore. + * ui-out.h (make_cleanup_restore_current_uiout): Don't declare. + +2016-10-20 Tom Tromey + * elfread.c (elf_read_minimal_symbols): Use gdb::unique_ptr. 2016-10-20 Tom Tromey diff --git a/gdb/infrun.c b/gdb/infrun.c index 3069b2d..00bba16 100644 --- a/gdb/infrun.c +++ b/gdb/infrun.c @@ -8084,22 +8084,20 @@ print_stop_location (struct target_waitstatus *ws) void print_stop_event (struct ui_out *uiout) { - struct cleanup *old_chain; struct target_waitstatus last; ptid_t last_ptid; struct thread_info *tp; get_last_target_status (&last_ptid, &last); - old_chain = make_cleanup_restore_current_uiout (); - current_uiout = uiout; - - print_stop_location (&last); + { + scoped_restore save_uiout = make_scoped_restore (¤t_uiout, uiout); - /* Display the auto-display expressions. */ - do_displays (); + print_stop_location (&last); - do_cleanups (old_chain); + /* Display the auto-display expressions. */ + do_displays (); + } tp = inferior_thread (); if (tp->thread_fsm != NULL diff --git a/gdb/python/python.c b/gdb/python/python.c index e478ec9..d6bd6bf 100644 --- a/gdb/python/python.c +++ b/gdb/python/python.c @@ -648,7 +648,7 @@ execute_gdb_command (PyObject *self, PyObject *args, PyObject *kw) scoped_restore save_async = make_scoped_restore (¤t_ui->async, 0); - make_cleanup_restore_current_uiout (); + scoped_restore save_uiout = make_scoped_restore (¤t_uiout); /* Use the console interpreter uiout to have the same print format for console or MI. */ diff --git a/gdb/stack.c b/gdb/stack.c index 706dd51..823433d 100644 --- a/gdb/stack.c +++ b/gdb/stack.c @@ -149,15 +149,9 @@ print_stack_frame_to_uiout (struct ui_out *uiout, struct frame_info *frame, int print_level, enum print_what print_what, int set_current_sal) { - struct cleanup *old_chain; - - old_chain = make_cleanup_restore_current_uiout (); - - current_uiout = uiout; + scoped_restore save_uiout = make_scoped_restore (¤t_uiout, uiout); print_stack_frame (frame, print_level, print_what, set_current_sal); - - do_cleanups (old_chain); } /* Show or print a stack frame FRAME briefly. The output is formatted diff --git a/gdb/ui-out.c b/gdb/ui-out.c index f6d6050..932cf12 100644 --- a/gdb/ui-out.c +++ b/gdb/ui-out.c @@ -952,24 +952,6 @@ ui_out_destroy (struct ui_out *uiout) xfree (uiout); } -/* Cleanup that restores a previous current uiout. */ - -static void -restore_current_uiout_cleanup (void *arg) -{ - struct ui_out *saved_uiout = (struct ui_out *) arg; - - current_uiout = saved_uiout; -} - -/* See ui-out.h. */ - -struct cleanup * -make_cleanup_restore_current_uiout (void) -{ - return make_cleanup (restore_current_uiout_cleanup, current_uiout); -} - /* Standard gdb initialization hook. */ void diff --git a/gdb/ui-out.h b/gdb/ui-out.h index 6a4d78a..9e1e74d 100644 --- a/gdb/ui-out.h +++ b/gdb/ui-out.h @@ -247,8 +247,4 @@ extern void ui_out_destroy (struct ui_out *uiout); extern int ui_out_redirect (struct ui_out *uiout, struct ui_file *outstream); -/* Make a cleanup that restores the previous current uiout. */ - -extern struct cleanup *make_cleanup_restore_current_uiout (void); - #endif /* UI_OUT_H */