From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5719 invoked by alias); 10 Sep 2011 12:46:37 -0000 Received: (qmail 5710 invoked by uid 22791); 10 Sep 2011 12:46:37 -0000 X-SWARE-Spam-Status: No, hits=-2.6 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW X-Spam-Check-By: sourceware.org Received: from mail-yw0-f41.google.com (HELO mail-yw0-f41.google.com) (209.85.213.41) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sat, 10 Sep 2011 12:46:23 +0000 Received: by ywe9 with SMTP id 9so494293ywe.0 for ; Sat, 10 Sep 2011 05:46:22 -0700 (PDT) MIME-Version: 1.0 Received: by 10.236.173.98 with SMTP id u62mr4688273yhl.107.1315658782473; Sat, 10 Sep 2011 05:46:22 -0700 (PDT) Received: by 10.236.201.33 with HTTP; Sat, 10 Sep 2011 05:46:22 -0700 (PDT) In-Reply-To: <201108042110.45405.pedro@codesourcery.com> References: <201108042110.45405.pedro@codesourcery.com> Date: Sat, 10 Sep 2011 12:51:00 -0000 Message-ID: Subject: Re: Eliminate tui_command_loop From: Matt Rice To: Pedro Alves Cc: gdb-patches@sourceware.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes 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 X-SW-Source: 2011-09/txt/msg00175.txt.bz2 On Thu, Aug 4, 2011 at 1:10 PM, Pedro Alves wrote: > On Wednesday 03 August 2011 19:10:41, Pedro Alves wrote: >> Looking at the differences between tui/tui-interp.c:tui_command_loop >> and event-top.c:cli_event_loop, >> thinking of getting rid of tui_command_loop, the only difference is >> that tui_command_loop inlines event-loop.c:start_event_loop, and >> adds this bit: >> >> + =A0 =A0 =A0/* Update gdb output according to TUI mode. =A0Since catch_= errors >> + =A0 =A0 =A0 =A0 preserves the uiout from changing, this must be done a= t top >> + =A0 =A0 =A0 =A0 level of event loop. =A0*/ >> + =A0 =A0 =A0if (tui_active) >> + =A0 =A0 =A0 =A0current_uiout =3D tui_out; >> + =A0 =A0 =A0else >> + =A0 =A0 =A0 =A0current_uiout =3D tui_old_uiout; >> >> I thought, "why don't we just use TRY_CATCH instead of >> catch_errors then?". =A0Turns out we can't as is, because it is >> TRY_CATCH itself that preserves the uiout from changing... > > TRY_CATCH no longer does that. =A0I've applied the > patch below that conceptually does: Sorry to report that there is an issue here, Unforunately the story with this current_uiout frobbing doesn't really end at catch_errors/TRY_CATCH. because interps.c:interp_set goes: current_uiout =3D interp->interpreter_out; and tui/tui-io.c:tui_initialize_io goes: tui_old_uiout =3D current_uiout =3D cli_out_new (gdb_stdout); so after tui_initialize_io, we have a situation where interp->interpreter_out !=3D current_uiout then, in 'interpreter_exec_cmd' old_interp =3D current_interpreter; .... interp_set (old_interp, 0); and now current_uiout has now reverted interpreter->interpreter_out. this then leads to some issue in the future when we try to output something. saving and restoring current_uiout in interpreter_exec_cmd seems to work, but I fear its just a piece of bubble gum holding things together (and further breaks the already broken abstraction), this comment from captured_mi_execute_command leads me to think that if the command does actually want to modify the uiout restoring it to whatever was the current_uiout could be incorrect.. /* Print the result if there were no errors. Remember that on the way out of executing a command, you have to directly use the mi_interp's uiout, since the command could have reset the interpreter, in which case the current uiout will most likely crash in the mi_out_* routines. */ I suppose the right thing to do is add interp_set_uiout(interp, uiout) so tui can control whatever its current_interpreter->interpreter_out field = is.