RE: [PATCH v4 2/2] gdb/breakpoint: add flags to 'condition' and 'break' commands to force condition

Aktemur, Tankut Baris via Gdb-patches
2020-11-10T19:51:35Z

On Thursday, October 29, 2020 6:30 PM, Pedro Alves wrote:
> On 10/13/20 1:25 PM, Tankut Baris Aktemur via Gdb-patches wrote:
> > @@ -9192,10 +9207,25 @@ find_condition_and_thread (const char *tok, CORE_ADDR pc,
> > if (toklen >= 1 && strncmp (tok, "if", toklen) == 0)
> > {
> > tok = cond_start = end_tok + 1;
> > - parse_exp_1 (&tok, pc, block_for_pc (pc), 0);
> > + try
> > + {
> > + parse_exp_1 (&tok, pc, block_for_pc (pc), 0);
> > + }
> > + catch (const gdb_exception_error &)
> > + {
> > + if (!force)
> > + throw;
> > + else
> > + tok = tok + strlen (tok);
> > + }
> > cond_end = tok;
> > *cond_string = savestring (cond_start, cond_end - cond_start);
> > }
> > + else if (toklen >= 1 && strncmp (tok, "-force-condition", toklen) == 0)
> > + {
> > + tok = cond_start = end_tok + 1;
> > + force = true;
> > + }
> > else if (toklen >= 1 && strncmp (tok, "thread", toklen) == 0)
> > {
> > const char *tmptok;
>
> Is it important to handle "-force-condition" in this position, as opposed
> to making it another option handled by string_to_explicit_location ?
>
> As is, this doesn't work, for example:
>
> (gdb) b -function main -force<TAB>
>
> nor does:
>
> (gdb) b -force-condition main if 0
> invalid explicit location argument, "-force-condition"

There is another case where it doesn't work:

(gdb) break main -force-condition thread 1 if foo
Function "main -force-condition" not defined.
Make breakpoint pending on future shared library load? (y or [n])

This is because the commit required "-force-condition" to always be followed
by an "if". It seems unnecessarily restrictive. I'll submit a patch to relax
the requirement.

Regards
-Baris

Intel Deutschland GmbH
Registered Address: Am Campeon 10-12, 85579 Neubiberg, Germany
Tel: +49 89 99 8853-0, www.intel.de
Managing Directors: Christin Eisenschmid, Gary Kershaw
Chairperson of the Supervisory Board: Nicole Lau
Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928