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

Simon Marchi via Gdb-patches
2021-04-21T14:26:43Z

On 2021-04-21 9:49 a.m., Aktemur, Tankut Baris wrote:> On Wednesday, April 21, 2021 3:37 PM, Simon Marchi wrote:
>>> diff --git a/gdb/testsuite/gdb.mi/mi-break.exp b/gdb/testsuite/gdb.mi/mi-break.exp
>>> index e46a6cc0ec6..5f1c6810389 100644
>>> --- a/gdb/testsuite/gdb.mi/mi-break.exp
>>> +++ b/gdb/testsuite/gdb.mi/mi-break.exp
>>> @@ -408,6 +408,30 @@ proc_with_prefix test_explicit_breakpoints {} {
>>> ".*Source filename requires function, label, or line offset.*"
>>> }
>>>
>>> +# Test forcing an invalid condition.
>>> +
>>> +proc_with_prefix test_forced_conditions {} {
>>> + set warning ".*warning: failed to validate condition .* disabling.*"
>>> +
>>> + # Define a plain breakpoint first, and a condition later.
>>> + mi_create_breakpoint "callme" "define a bp" ""
>>> + mi_gdb_test "-break-condition --force \$bpnum bad" \
>>> + "${warning}\\^done" \
>>> + "invalid condition is forced"
>>
>> This literally sends
>>
>> -break-condition --force $bpnum bad
>>
>> But I don't understand what $bpnum refers to, can you explain? I'm a bit lost.
>
> It's GDB's internal variable that refers to the last-defined breakpoint's number.
> It was my attempt to avoid hard-coding the breakpoint number.

Ah! Good idea. I just didn't remember $bpnum (and will probably forget
it promptly again).

>>> + mi_gdb_test "-dprintf-insert -c bad --force-condition callme 123" \
>>> + "${warning}\\^done,$bp" \
>>> + "dprintf with forced condition"
>>
>> It's really just a nit because it doesn't affect the test, but a dprintf
>> would normally take a format string, so I guess you meant:
>>
>> -dprintf-insert -c bad --force-condition callme "%d" 123
>>
>> Or something like that.
>
> I meant "123" as a dummy format string that takes no parameters.
> I'll convert it to `"%d" 123` to avoid confusion.

Ah, makes sense. Well, what you had is ok. I'd put it between quotes
just to be clear, or use "Hello" or something. Not a big deal in any
case.

Simon