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 03A33383583B for ; Mon, 17 May 2021 20:43:21 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 03A33383583B 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 14HKhFkI008329 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 17 May 2021 16:43:20 -0400 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp.polymtl.ca 14HKhFkI008329 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 8E9C61E54D; Mon, 17 May 2021 16:43:15 -0400 (EDT) Subject: Re: [PATCH] gdb: add build mode to reverse order of _initialize function calls To: Andrew Burgess Cc: gdb-patches@sourceware.org References: <20210517180003.2147187-1-simon.marchi@polymtl.ca> <20210517192618.GO3067949@embecosm.com> From: Simon Marchi Message-ID: <2213f2ae-ccfd-3b06-aa5e-f15bd0ecd564@polymtl.ca> Date: Mon, 17 May 2021 16:43:15 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.10.1 MIME-Version: 1.0 In-Reply-To: <20210517192618.GO3067949@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 Mon, 17 May 2021 20:43:15 +0000 X-Spam-Status: No, score=-4.1 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: Mon, 17 May 2021 20:43:23 -0000 On 2021-05-17 3:26 p.m., Andrew Burgess wrote: > * Simon Marchi via Gdb-patches [2021-05-17 14:00:03 -0400]: > >> We should not assume any order in which the _initialize functions get >> called. However, since their order comes from the order of source files >> baked into the Makefile, it's possible for such dependencies to creep in >> and for us not to notice. >> >> I think that a good way to test for such dependencies is to reverse the >> order of the calls. Add an option in the Makefile to do this. It can >> be used as: >> >> $ make REVERSE_INIT_FILES=1 >> >> before init.c gets generated (if you want to re-generate init.c, either >> do a "make clean" or remove stamp-init). > > Instead of making this a build option, did you consider modifying > initialize_all_files to something like this totally untested code: > > void > initialize_all_files (bool reverse_p) > { > std::vector func = { > _initialize_arc_linux_tdep, > _initialize_arc_tdep, > _initialize_arm_fbsd_tdep, > _initialize_arm_linux_tdep, > _initialize_arm_netbsd_tdep, > _initialize_armobsd_tdep, > ... etc ... > }; > > if (reverse_p) > std::reverse(func.begin(), func.end()); > > for (auto f : func) > f (); > } > > then all you'd need is to add a new command line flag which controls > reverse_p. > > The benefit as I see it is that (a) we can add a test that is run in > every run of the testsuite that starts GDB with this new command line > flag, and does a few basic tests, and (b) we can easily pass the new > command line flag to the testsuite from the command line, and so run > _all_ tests with the reverse init order. > > Just a thought. That sounds much better indeed! I'll give it a shot eventually. Simon