Re: [PATCH] gdb: use gdb_test_multiple in gdb_breakpoint

Lancelot SIX via Gdb-patches
2023-01-04T17:41:44Z

On Wed, Jan 04, 2023 at 11:22:55AM -0500, Simon Marchi via Gdb-patches wrote:
>
>
> On 1/4/23 11:18, Lancelot SIX wrote:
> >> Oh, right, I missed that. I folded the test name in the
> >> gdb_test_multiple call (removed the test_name var) and used
> >> $gdb_test_name in the fail call. I updated the patch locally. Should I
> >> add your Reviewed-By after those changes?
> >>
> >> Simon
> >>
> >
> > Yes, with those change, feel free to add
> >
> > Reviewed-By: Lancelot Six <lancelot.six@amd.com>
> >
> > Best,
> > Lancelot.
>
> Thanks, pushed!
>
> Simon

Hi,

I just saw the resulting patch, and is seems that $test_name is
(conditionally) used after the gdb_test_multiple:

diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index 135ace68d5e..ba16b2ab315 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -639,18 +639,15 @@ proc gdb_breakpoint { linespec args } {
set print_pass 1
}

- set test_name "gdb_breakpoint: set breakpoint at $linespec"
-
- send_gdb "$break_command $linespec\n"
# The first two regexps are what we get with -g, the third is without -g.
- gdb_expect 30 {
+ gdb_test_multiple "$break_command $linespec" "gdb_breakpoint: set breakpoint at $linespec" {
-re "$break_message \[0-9\]* at .*: file .*, line $decimal.\r\n$gdb_prompt $" {}
-re "$break_message \[0-9\]*: file .*, line $decimal.\r\n$gdb_prompt $" {}
-re "$break_message \[0-9\]* at .*$gdb_prompt $" {}
-re "$break_message \[0-9\]* \\(.*\\) pending.*$gdb_prompt $" {
if {$pending_response == "n"} {
if { $print_fail } {
- fail $test_name
+ fail $gdb_name_name
}
return 0
}
@@ -659,35 +656,6 @@ proc gdb_breakpoint { linespec args } {
send_gdb "$pending_response\n"
exp_continue
}
- -re "A problem internal to GDB has been detected" {
- if { $print_fail } {
- fail "$test_name (GDB internal error)"
- }
- gdb_internal_error_resync
- return 0
- }
- -re "$gdb_prompt $" {
- if { $print_fail } {
- fail $test_name
- }
- return 0
- }
- eof {
- perror "GDB process no longer exists"
- global gdb_spawn_id
- set wait_status [wait -i $gdb_spawn_id]
- verbose -log "GDB process exited with wait status $wait_status"
- if { $print_fail } {
- fail "$test_name (eof)"
- }
- return 0
- }
- timeout {
- if { $print_fail } {
- fail "$test_name (timeout)"
- }
- return 0
- }
}
if { $print_pass } {
pass $test_name

Just here ^ $test_name is used, but the patch does not set it anymore.
Looks like that it should become something like:

set test_name "gdb_breakpoint: set breakpoint at $linespec"
gdb_test_multiple "$break_command $linespec" $test_name {
# unchanged
}
if { $print_pass } {
pass $test_name
}

Sorry I missed that earlier.

Lancelot.