From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp.polymtl.ca (smtp.polymtl.ca [132.207.4.11]) by sourceware.org (Postfix) with ESMTPS id C9C8C385041F for ; Wed, 24 Mar 2021 13:51:47 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org C9C8C385041F Received: from simark.ca (simark.ca [158.69.221.121]) (authenticated bits=0) by smtp.polymtl.ca (8.14.7/8.14.7) with ESMTP id 12ODpML4002642 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 24 Mar 2021 09:51:27 -0400 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp.polymtl.ca 12ODpML4002642 Received: from [10.0.0.11] (192-222-157-6.qc.cable.ebox.net [192.222.157.6]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id 5BD571E789; Wed, 24 Mar 2021 09:51:22 -0400 (EDT) Subject: Re: [PATCH] gdb: Change init order so pretty printers are set in new_objfile event To: Andrew Burgess Cc: Michael Weghorn , gdb-patches@sourceware.org References: <20210210154053.82927-1-m.weghorn@posteo.de> <20210211094234.GM265215@embecosm.com> <20210324094523.GI5520@embecosm.com> From: Simon Marchi Message-ID: Date: Wed, 24 Mar 2021 09:51:21 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.7.1 MIME-Version: 1.0 In-Reply-To: <20210324094523.GI5520@embecosm.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Poly-FromMTA: (simark.ca [158.69.221.121]) at Wed, 24 Mar 2021 13:51:22 +0000 X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, NICE_REPLY_A, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 24 Mar 2021 13:51:49 -0000 >> I had similar crazy thoughts once. Except it wouldn't use arbitrary >> numerical values. It can be a bit obscure why a certain value is >> assigned to a given observer. >> >> Instead, when attaching an observer you tell which other observer you'd >> like to run after. So let's say subsystem bar uses features from >> subsystem foo (so it necessarily knows about foo already), foo would do: >> >> // In foo.h >> extern observer_key foo_new_objfile_observer; >> >> // In foo.c, in _initialize_foo >> foo_new_objfile_observer = gdb::observers::new_objfile.attach (foo_new_objfile); >> >> // In bar.c, in _initialize_bar >> gdb::observers::new_objfile.attach (bar_new_objfile, &foo_new_objfile_observer); > > That's fine, but I ran into a case just a couple of days ago where I > wanted observer ordering, but in that case there are two observers > that I would have wanted to be ordered before. > > I guess we could chain the dependencies, but I suspect this would > break if observers are detached (e.g. tui observers). > > I think the only reliable solution would be to allow for a vector of > dependencies, how would that sound? Do you mean using a vector to be able to specify multiple dependencies on attach, like this? std::vector deps {&foo1_new_objfile_observer, &foo2_new_objfile_observer}; gdb::observers::new_objfile.attach (bar_new_objfile, deps); ? If so, yes I think that makes sense. Simon