From: Simon Marchi <simon.marchi@polymtl.ca>
To: Joel Brobecker <brobecker@adacore.com>
Cc: gdb-patches@sourceware.org
Subject: Re: GDB 7.99.91 available for testing
Date: Tue, 16 May 2017 13:51:00 -0000 [thread overview]
Message-ID: <1f06c802305c02d92e0806b6174d7963@polymtl.ca> (raw)
In-Reply-To: <ca6c7e4f2801abfaa7e02a10fad7427d@polymtl.ca>
On 2017-05-15 17:11, Simon Marchi wrote:
> Hi Joel,
>
> Somebody reported on IRC that the command "tty" (an alias for "set
> inferior-tty") didn't work anymore. git bisect found one of my
> commits as the culprit:
>
> b593ecca856860a8b38deb808493bba4beef3aee
> Makefiles: Flatten and sort file lists
>
> This is likely due to the _initialize functions being called in a
> different order. I think this should block the 8.0 release. I'll
> have time to investigate this tonight or tomorrow.
>
> Thanks,
>
> Simon
Hi,
So indeed, the problem is due to the ordering of the _initialize
functions that changed, _initialize_printcmd used to be called before
_initialize_infcmd, now it's the reverse.
When it works, the timeline of events to be able to get the tty alias
working is the following:
1. The "set" command is registered as a prefix command in printcmd.c,
which adds it to the global command list (cmdlist). setlist is the list
of its subcommands.
2. The "set inferior-tty" command is added as a child of "set" (i.e.
it's inserted into setlist) in infcmd.c.
3. The "tty" alias is created for "set inferior-tty" in infcmd.c. This
looks up "set" in cmdlist, then "inferior-tty" in the subcommands of
"set". It's found and everyone is happy.
With the _initialize functions called in a different order, steps are
executed in the order 2-3-1. When we try to create the alias, the "set"
command has not been created and is therefore not part of cmdlist. We
can't find the "set inferior-tty" command, so the alias is not created.
I think the core issue is that it's currently possible to create
subcommands for prefixes that have not been created yet. We need some
way of ensuring some kind of ordering. Here are some ideas:
1. Force some kind of ordering through init.c
It's already done for at least one file, if you look at gdb/Makefile.in,
you'll see that the gdbtypes file is put at the beginning, so that it's
called first. We could do the same with printcmd. This is not a
solution I would like in the long term, but maybe it's good for the 8.0
release, as it would minimize the required changes.
2. Add dependencies between _initialize_functions
We could have a way for _initialize functions to call each other. For
example, since we know that _initialize_printcmd must be called before
_initialize_infcmd, the latter could call the former. A static flag in
each function could ensure that each is called only once.
I don't like this one very much, since the dependencies between
functions have to be manually deduced, they can become outdated and it's
easy to forget some.
3. Create prefix commands on demand
Right now, if you want to create a prefix command under "set", you just
refer to &setlist, regardless of whether the "set" command has been
created or not yet. Instead of referring directly to setlist, we could
call something like set_prefix_list, which would create the "set"
command if it hasn't been created yet, and return setlist. Something
like that:
cmd_list_element **set_prefix_list ()
{
static cmd_list_element *setlist = NULL;
bool initialized = false;
if (!initialized)
{
// Create the set command
add_prefix_cmd ("set", ..., &setlist, ...);
}
return &setlist;
}
References to &setlist would be changed to set_prefix_list (). This
encodes the dependencies directly in the code: if want to add a
subcommand to "set", you need to call set_prefix_list to obtain the list
of "set"'s children, ensuring that "set" has been created. So the deps
can't get stale, or you can't miss one by mistake.
So far this is the approach I like the most for the master branch.
There are many ways the code could be improved further (C++, better
encapsulation), but this would be a manageable first step. But for the
immediate needs of the imminent 8.0 release, I think #1 would be better.
Any comments?
Simon
next prev parent reply other threads:[~2017-05-16 13:51 UTC|newest]
Thread overview: 56+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-04 19:44 Joel Brobecker
2017-05-08 14:53 ` Eli Zaretskii
2017-05-17 11:36 ` Yao Qi
2017-05-17 14:39 ` Eli Zaretskii
2017-05-08 15:00 ` GDB 7.99.91 MinGW compilation error in cli-script.c Eli Zaretskii
2017-05-14 3:19 ` Simon Marchi
2017-05-14 14:13 ` Eli Zaretskii
2017-05-17 14:31 ` Joel Brobecker
2017-05-17 16:01 ` Eli Zaretskii
2017-05-19 9:10 ` Eli Zaretskii
2017-05-19 9:49 ` Pedro Alves
2017-05-19 11:17 ` Eli Zaretskii
2017-05-19 11:23 ` Pedro Alves
2017-05-21 15:33 ` Eli Zaretskii
2017-05-22 15:26 ` Pedro Alves
2017-05-22 18:43 ` Eli Zaretskii
2017-05-23 9:53 ` Pedro Alves
2017-05-24 2:44 ` Eli Zaretskii
2017-05-25 10:05 ` Pedro Alves
2017-05-26 7:57 ` Eli Zaretskii
2017-05-26 11:52 ` Pedro Alves
2017-05-26 12:57 ` Eli Zaretskii
2017-05-26 13:58 ` Pedro Alves
2017-05-24 18:28 ` Eli Zaretskii
2017-05-24 19:37 ` Joel Brobecker
2017-05-25 10:12 ` Pedro Alves
2017-05-26 7:47 ` Eli Zaretskii
2017-05-26 10:54 ` Pedro Alves
2017-05-26 13:03 ` Eli Zaretskii
2017-05-26 14:10 ` Pedro Alves
2017-05-26 14:35 ` Eli Zaretskii
2017-05-26 14:45 ` Pedro Alves
2017-05-08 15:02 ` GDB 7.99.91 MinGW compilation warning in tui.c Eli Zaretskii
2017-05-09 10:17 ` Yao Qi
2017-05-13 8:12 ` Eli Zaretskii
2017-05-17 16:26 ` Yao Qi
2017-05-17 16:45 ` Eli Zaretskii
2017-05-17 18:21 ` Joel Brobecker
2017-05-19 8:02 ` Eli Zaretskii
2017-05-19 9:54 ` Pedro Alves
2017-05-19 11:14 ` Eli Zaretskii
2017-05-19 11:25 ` Pedro Alves
2017-05-19 12:51 ` Eli Zaretskii
2017-05-19 13:58 ` Pedro Alves
2017-05-19 14:40 ` Eli Zaretskii
2017-05-19 17:50 ` DJ Delorie
2017-05-19 17:55 ` Eli Zaretskii
2017-05-15 21:11 ` GDB 7.99.91 available for testing Simon Marchi
2017-05-16 13:51 ` Simon Marchi [this message]
2017-05-16 20:50 ` Yao Qi
2017-05-16 21:22 ` Simon Marchi
2017-05-16 21:40 ` Yao Qi
2017-05-17 11:31 ` [PATCH master/8.0] Add alias command to cmd_list_element Yao Qi
2017-05-17 12:16 ` Simon Marchi
2017-05-17 13:36 ` Yao Qi
2017-05-16 14:28 ` GDB 7.99.91 available for testing Joel Brobecker
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1f06c802305c02d92e0806b6174d7963@polymtl.ca \
--to=simon.marchi@polymtl.ca \
--cc=brobecker@adacore.com \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox