RE: [PATCH v4 2/2] gdb/mi: add a '--force' flag to the '-break-condition' command

Aktemur, Tankut Baris via Gdb-patches
2021-04-22T14:48:28Z

On Thursday, April 22, 2021 4:36 PM, Aktemur, Tankut Baris wrote:
> Add a '--force' flag to the '-break-condition' command to be
> able to force conditions.
>
> gdb/ChangeLog:
> 2021-04-21 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com>
>
> * mi/mi-cmd-break.c (mi_cmd_break_condition): New function.
> * mi/mi-cmds.c: Change the binding of "-break-condition" to
> mi_cmd_break_condition.
> * mi/mi-cmds.h (mi_cmd_break_condition): Declare.
> * breakpoint.h (set_breakpoint_condition): Declare a new
> overload.
> * breakpoint.c (set_breakpoint_condition): New overloaded function
> extracted out from ...
> (condition_command): ... this.
> * NEWS: Mention the change.
>
> gdb/testsuite/ChangeLog:
> 2021-04-21 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com>
>
> * gdb.mi/mi-break.exp (test_forced_conditions): Add a test
> for the -break-condition command's "--force" flag.
>
> gdb/doc/ChangeLog:
> 2021-04-21 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com>
>
> * gdb.texinfo (GDB/MI Breakpoint Commands): Mention the
> '--force' flag of the '-break-condition' command.

> diff --git a/gdb/testsuite/gdb.mi/mi-break.exp b/gdb/testsuite/gdb.mi/mi-break.exp
> index 3b264ecdebd..b6ef3483004 100644
> --- a/gdb/testsuite/gdb.mi/mi-break.exp
> +++ b/gdb/testsuite/gdb.mi/mi-break.exp
> @@ -424,6 +424,17 @@ proc_with_prefix test_forced_conditions {} {
> mi_gdb_test "-dprintf-insert -c bad --force-condition callme \"Hello\"" \
> "${warning}\\^done,$bp" \
> "dprintf with forced condition"
> +
> + # Define a plain breakpoint first, and a condition later.
> + mi_create_breakpoint "callme" "define a bp" ""
> + mi_gdb_test "-break-condition --force 16 bad == 42" \

In the previous revision I was using $bpnum to avoid having to
hard-code the breakpoint number. This was fine because the command
arguments were being passed to the CLI command's function directly.
The CLI command parses and converts $bpnum to an integer.
Here, I had to hardcode the number, which is common in this test file.

Thanks
-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