RE: [PATCH 4/4] gdb/mi: add a '-b' flag to the '-break-insert' cmd to force the condition

Aktemur, Tankut Baris via Gdb-patches
2021-04-07T16:05:26Z

On Wednesday, April 7, 2021 5:54 PM, Eli Zaretskii wrote:
> > From: "Aktemur, Tankut Baris" <tankut.baris.aktemur@intel.com>
> > CC: "gdb-patches@sourceware.org" <gdb-patches@sourceware.org>
> > Date: Wed, 7 Apr 2021 15:27:13 +0000
> >
> > > > + The MI -break-insert and -dprintf-insert commands now support a
> > > > + '-b' flag to forcibly define a condition even when the condition
> > > > + is invalid at all locations of the breakpoint. This is equivalent
> > > > + to the '--force-condition' flag of the CLI's "break" command.
> > >
> > > By "invalid at all locations" did you mean "invalid for some of the
> > > locations"? IOW, does this flag handle the case when the condition is
> > > valid for some locations and invalid for others, or is it specifically
> > > for the case when the condition is invalid for _all_ the locations?
> >
> > It is specifically for all the locations. If there are some locations at
> > which the condition is valid, the breakpoint is accepted. There is no need
> > for the '-b' flag then. The locations at which the condition is valid are
> > disabled.
>
> Then how about simply accepting the condition by default in that case,
> without any need for a special flag? IOW, it makes little sense to me
> to accept the condition if it is _sometimes_ invalid, but not if it is
> _always_ invalid. It sounds like a gratuitous limitation. Am I
> missing something?

There are two problems with that approach:

1. Backward compatibility would be broken.

2. (The more important one, IMHO) If the user makes a typo in the condition,
the breakpoint would still be accepted by making it disabled at all the locations.
The force flag is the user telling GDB "I'm sure about this condition expression,
it will be meaningful in the future, just accept it." I think this scenario is less
common than the user entering really bad conditions. Hence, it had made more sense
to reject the breakpoint in the default case.

-Baris

Intel Deutschland GmbH
Registered Address: Am Campeon 10, 85579 Neubiberg, Germany
Tel: +49 89 99 8853-0, www.intel.de <http://www.intel.de>
Managing Directors: Christin Eisenschmid, Sharon Heck, Tiffany Doon Silva
Chairperson of the Supervisory Board: Nicole Lau
Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928