[PATCH] gdb: add build mode to reverse order of _initialize function calls
Simon Marchi
simon.marchi@polymtl.ca
Mon May 17 20:43:15 GMT 2021
On 2021-05-17 3:26 p.m., Andrew Burgess wrote:
> * Simon Marchi via Gdb-patches <gdb-patches@sourceware.org> [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<void (*) (void)> 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
More information about the Gdb-patches
mailing list