Re: [PATCH] gdb: use gdb_test_multiple in gdb_breakpoint

Simon Marchi via Gdb-patches
2023-01-10T15:51:04Z

On 1/10/23 10:33, Pedro Alves wrote:
> On 2023-01-05 4:28 p.m., Simon Marchi via Gdb-patches wrote:
>
>> ---
>> gdb/testsuite/lib/gdb.exp | 6 ++++++
>> 1 file changed, 6 insertions(+)
>>
>> diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
>> index e17eace4cb13..af538e5c8fbd 100644
>> --- a/gdb/testsuite/lib/gdb.exp
>> +++ b/gdb/testsuite/lib/gdb.exp
>> @@ -657,6 +657,12 @@ proc gdb_breakpoint { linespec args } {
>> send_gdb "$pending_response\n"
>> exp_continue
>> }
>> + -re "$gdb_prompt $" {
>> + if { $print_fail } {
>> + fail $test_name
>> + }
>> + return 0
>> + }
>> }
>
> The other removed "-re" cases also considered $print_fail, so if their replacement
> inside gdb_test_multiple is hit, they'll produce a FAIL. Was that intended?
> Should we instead add a "-nofail" option to gdb_test / gdb_test_multiple ?

Good point, this is a change in behavior. Does this change cause you an
unexpected FAIL in practice? I was actually planning on removing that
message / no-message option to gdb_breakpoint [1] to simplify it. I
don't see any use for the current behavior, I'd rather have it log a
test result all the time. I can kind of see when that would maybe be
useful: if you wanted to set a breakpoint, and it could legitimately not
work (you could do something with gdb_breakpoint's return value). But
you could also use the break command directly, like many places do
already, so it's not really needed. Anyway, all of this to say that I
could fix what you pointed out by pruning / simplifying code rather than
adding more.

Simon

[1] https://review.lttng.org/c/binutils-gdb/+/7158/6