From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 106200 invoked by alias); 26 May 2016 18:12:00 -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 106164 invoked by uid 89); 26 May 2016 18:11:56 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.3 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=tackle, Traverse, traverse, restores X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Thu, 26 May 2016 18:11:55 +0000 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 952A485540; Thu, 26 May 2016 18:11:54 +0000 (UTC) Received: from [127.0.0.1] (ovpn01.gateway.prod.ext.ams2.redhat.com [10.39.146.11]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u4QIBrWR004797; Thu, 26 May 2016 14:11:53 -0400 Subject: Re: [PATCH v3 07/34] Make the intepreters output to all UIs To: Simon Marchi , gdb-patches@sourceware.org References: <1462538104-19109-1-git-send-email-palves@redhat.com> <1462538104-19109-8-git-send-email-palves@redhat.com> <573DD8A7.60806@ericsson.com> From: Pedro Alves Message-ID: <0976acfe-4de8-c7f4-768b-217ec36e0c10@redhat.com> Date: Thu, 26 May 2016 18:12:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.1.0 MIME-Version: 1.0 In-Reply-To: <573DD8A7.60806@ericsson.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-SW-Source: 2016-05/txt/msg00466.txt.bz2 On 05/19/2016 04:15 PM, Simon Marchi wrote: > On 16-05-06 08:34 AM, Pedro Alves wrote: >> + /* Traverse through all UI, and switch the current UI to the one >> + being iterated. */ >> +#define SWITCH_THRU_ALL_UIS(STATE) \ >> + for (switch_thru_all_uis_init (&STATE); \ >> + switch_thru_all_uis_cond (&STATE); \ >> + switch_thru_all_uis_next (&STATE)) \ > > The last backslash is not necessary I think. Thanks, indeed. I've removed it. > > I was wondering why you did not name this "ALL_UIS", using the same pattern > as ALL_INFERIORS & al, but then I realized it's because this one actually > sets current_ui before each iteration (and restores it at the end). Exactly. > > I guess the reason you need to do this is because, again, everything relies on > accessing the global current_ui, whereas it should be passed down as a parameter. It goes deeper than straight access of current_ui directly. It goes all the way to gdb_stdout, etc., which are really fields of current_ui. I don't ever see us passing down a current_ui to _all_ functions that might want to do I/O. That'd mean passing it around _everywhere_. So basically, if you're calling a function that may do output, and you want that output to be duplicated to all UIs, you need to use SWITCH_THRU_ALL_UIS. Note, we can't just call such functions once, with output redirected to a buffer, and then print that buffer on all UI's streams, because each UI's ui_out may want to print differently, and also run through distinct code paths, due to ui_out_is_mi_like_p. > I am not saying it should be done in this series (it's a big task in itself), but > we can probably tackle it after. They way you did things should make it easy to > improve things later on. Thanks, Pedro Alves