From 05f32b5c30d52bd46dc671e923c38becdf7227b5 Mon Sep 17 00:00:00 2001 From: Pedro Alves Date: Thu, 17 Apr 2025 22:55:25 +0100 Subject: [PATCH 4/4] gdb_test_multiple: Anchor prompt match if -lbl This is the original patch (rebased on the thingy). If we make the built-in prompt have an anchor as well, then it won't match prematurely, and our own prompt match overrides it. So now we get a clean pass: (gdb) command prefix meant-to-be-matched-by-lbl-1 prefix foo prefix bar meant-to-be-matched-by-lbl-2 prefix prefix meant-to-be-matched-by-lbl-3 (gdb) PASS: gdb.testsuite/gdb-test-multiple.exp: command PASS: gdb.testsuite/gdb-test-multiple.exp: $saw_command == 1 PASS: gdb.testsuite/gdb-test-multiple.exp: $saw_prompt == 1 PASS: gdb.testsuite/gdb-test-multiple.exp: $saw_prefix == 3 PASS: gdb.testsuite/gdb-test-multiple.exp: $saw_prefix_foo == 1 PASS: gdb.testsuite/gdb-test-multiple.exp: $saw_prefix_bar == 1 saw_prompt: 1 saw_prefix: 3 saw_prefix_foo: 1 saw_prefix_bar: 1 Change-Id: Ic2571ec793d856a89ee0d533ec363e2ac6036ea2 --- gdb/testsuite/lib/gdb.exp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp index cd920d2624c..6e97d7a35d9 100644 --- a/gdb/testsuite/lib/gdb.exp +++ b/gdb/testsuite/lib/gdb.exp @@ -1124,6 +1124,7 @@ proc gdb_test_multiple { command message args } { global any_spawn_id set line_by_line 0 + set lbl_anchor_re "" set prompt_regexp "" set prompt_anchor 1 for {set i 0} {$i < [llength $args]} {incr i} { @@ -1133,6 +1134,7 @@ proc gdb_test_multiple { command message args } { set prompt_regexp [lindex $args $i] } elseif { $arg == "-lbl" } { set line_by_line 1 + set lbl_anchor_re "^" } elseif { $arg == "-no-prompt-anchor" } { set prompt_anchor 0 } else { @@ -1391,7 +1393,7 @@ proc gdb_test_multiple { command message args } { fail "$errmsg" set result -1 } - -re "\r\n$prompt_regexp" { + -re "${lbl_anchor_re}\r\n$prompt_regexp" { verbose -log "" if {![string match "" $message]} { fail "$message" -- 2.49.0