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

Simon Marchi via Gdb-patches
2021-04-07T22:26:21Z

On 2021-04-07 10:55 a.m., Tankut Baris Aktemur via Gdb-patches wrote:
> @@ -203,6 +205,7 @@ mi_cmd_break_insert_1 (int dprintf, const char *command, char **argv, int argc)
> {"f", PENDING_OPT, 0},
> {"d", DISABLE_OPT, 0},
> {"a", TRACEPOINT_OPT, 0},
> + {"b", FORCE_CONDITION_OPT, 0},
> {"-qualified", QUALIFIED_OPT, 0},
> {"-source" , EXPLICIT_SOURCE_OPT, 1},
> {"-function", EXPLICIT_FUNC_OPT, 1},

Hi, it's me nitpicking names again: instead of choosing a meaningless
single letter, could we use --force-condition? It would just be more
obvious to any human reading MI logs, and machines don't really care
about the extra typing.

> +proc test_forced_conditions {} {
> + # Test forcing an invalid condition.
> + mi_gdb_test "info break"
> + mi_gdb_test "-break-condition -force 15 bad" \
> + ".*warning: failed to validate condition at location 15.1, disabling:.*" \
> + "invalid condition is forced"
> +
> + mi_gdb_test "-break-insert -c bad -b callme" \
> + ".*warning: failed to validate condition at location 1, disabling:.*" \
> + "breakpoint with bad condition is forced"
> +
> + mi_gdb_test "-dprintf-insert -c bad -b callme 123" \
> + ".*warning: failed to validate condition at location 1, disabling:.*" \
> + "dprintf with bad condition is forced"

It would be good to validate at least that the commands succeed (output ^done).

At least for the -break-insert case, it might be a good idea to improve
(to be able to pass the -b/--force-condition flag) and use
mi_create_breakpoint_multi. You could then validate what the command
outputs (one location with enabled="N").

Simon