On 11/17/2011 08:07 PM, Pedro Alves wrote: >> > Because gdb_test_multiple doesn't match pattern in output when "Ending >> > remote debugging" appeared in the output. We have to resort to >> > send_gdb/gdb_expect here. > Hmm, I'm confused. In this new revision the test is now: > > send_gdb "disconnect\n" > gdb_expect { > -re "warning: Pending tracepoints will not be resolved while GDB is disconnected.*Trace is running but will stop on detach; detach anyway\\? \\(y or n\\) $" { > pass "disconnect with pending tracepoint" > > send_gdb "y\n" > } > timeout {fail "(timeout) disconnect with pending tracepoint"} > } > > No "Ending remote debugging" in sight. GDB outputs that string > after the "detach anyway" query, so I think gdb_test_multiple > should just work. Also, we should always make sure to eat the prompt > after the "y", so that it doesn't remain in expect's buffer and > confuse following tests. Something like: This is a good tip. > > set test "disconnect with pending tracepoint" > gdb_test_multiple "disconnect" $test { > -re "warning: Pending tracepoints will not be resolved while GDB is disconnected.*Trace is running but will stop on detach; detach anyway\\? \\(y or n\\) $" { > pass $test > > set test "disconnected" > gdb_test_multiple "y" $test { > -re "$gdb_prompt $" { > pass "$test" > } > } > } > } My original attempt on using gdb_test is like this, set test "disconnect with pending tracepoint" gdb_test "disconnect" \ "warning: Pending tracepoint will not be resolved while GDB is disconnected" \ $test \ "Trace is running but will stop on detach; detach anyway\\? \\(y or n\\) $" \ "y" in proc gdb_test return [gdb_test_multiple $command $message { -re "\[\r\n\]*($pattern)\[\r\n\]+$gdb_prompt $" { if ![string match "" $message] then { pass "$message" } } -re "(${question_string})$" { send_gdb "$response_string\n"; exp_continue; } }] Query comes out prior to "warning:", so query matches, and there is no PASS and FAIL in gdb.sum. PATTERN passed to gdb_test is for matching the output _after_ query, and I used gdb_test in a wrong way. > > Note that "$gdb_prompt $" match takes precedence over > gdb_test_multiple's internal "Ending remote debugging.*$gdb_prompt $" > match. Is this precedence determined by the order of appending ${code} in proc gdb_test_multiple? > > Want to try that? Sure, they work. Updated patch as you suggested. -- Yao (齐尧)