This is the mail archive of the
gdb@sources.redhat.com
mailing list for the GDB project.
filtering of commands during async operation
- From: Doug Evans <dje at transmeta dot com>
- To: "Newman, Mark (N-Superior Technical Resource Inc)" <mark dot newman at lmco dot com>
- Cc: gdb at sources dot redhat dot com
- Date: Wed, 5 Nov 2003 13:52:31 -0800 (PST)
- Subject: filtering of commands during async operation
- References: <F56FBA314E8E5A41895F0DA8F6716A6D02A535@EMSS04M11.us.lmco.com>
Newman, Mark (N-Superior Technical Resource Inc) writes:
>
> In top.c there is an attempt to filter what commands can be issued during async operation. That code is not filtering (at least under RH on an Intel box). The code is
>
> if (event_loop_p && target_can_async_p () && target_executing)
> if (!strcmp (c->name, "help")
> && !strcmp (c->name, "pwd")
> && !strcmp (c->name, "show")
> && !strcmp (c->name, "stop"))
> error ("Cannot execute this command while the target is running.");
Good example of why it's useful to avoid using ! with strcmp.
> The code should be:
>
> if (event_loop_p && target_can_async_p () && target_executing) {
> if (!(strcmp (c->name, "help") == 0)
> && !(strcmp (c->name, "pwd") == 0)
> && !(strcmp (c->name, "show") == 0)
> && !(strcmp (c->name, "stop") == 0)) {
> error ("Cannot execute this command while the target is running.");
> }
> }
>
> Unless someone objects I am going to put in a bug report and a patch.
Why not just strcmp () != 0