From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2205) id E3C4C385842F; Mon, 11 Mar 2024 09:56:57 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E3C4C385842F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1710151017; bh=7kxhK4WV6V/heaQI6Gmjf+rrbRhb8h/YwhJjJfIRLxc=; h=From:To:Subject:Date:From; b=hhT/WSJuC3vKda7Gl5TZBNenY31KC3vMpcWdgjYMK9C3I5Zeg/v+pmLetGJiFT6fH uYO7cXgHoiXiXG+0qzNti1mbfF/eDYH+dcqmnQu+aZkq4zwZv2+YIeQghIgeIT+XBw U+xskhTSrBbqzuiq8qdhPC6uJ0eTzke74fwBg8/A= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Tom de Vries To: gdb-cvs@sourceware.org Subject: [binutils-gdb] gdb/testsuite: Fix gdb.threads/threadcrash.exp with check-readmore X-Act-Checkin: binutils-gdb X-Git-Author: Tom de Vries X-Git-Refname: refs/heads/master X-Git-Oldrev: 85041a8d518b4e0625b2bb1d007838dfd5cbe421 X-Git-Newrev: 72ab7ac8be993e29f8a393b72dc681d627b12d19 Message-Id: <20240311095657.E3C4C385842F@sourceware.org> Date: Mon, 11 Mar 2024 09:56:57 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D72ab7ac8be99= 3e29f8a393b72dc681d627b12d19 commit 72ab7ac8be993e29f8a393b72dc681d627b12d19 Author: Tom de Vries Date: Mon Mar 11 10:57:31 2024 +0100 gdb/testsuite: Fix gdb.threads/threadcrash.exp with check-readmore =20 With check-readmore, I run into: ... FAIL: gdb.threads/threadcrash.exp: test_corefile: \ $thread_count =3D=3D [llength $test_list] ... =20 The problem is that the clauses in the gdb_test_multiple for "thread apply all backtrace" intent to match one line, but actually can match more than one line, and consequently a match for one type of thre= ad can consume a line that was supposed to match another thread. =20 For instance, there's this regexp: ... -re "\[^\n\]*syscall_task .location=3DSIGNAL_ALT_STACK\[^\n= \]*" { ... =20 It's limited at the end by \[^\n\]*, meaning the match stops at the end= of the line. =20 But it doesn't start with a ^, and consequently can match more than one= line. The "\[^\n\]*" at the start doesn't prevent this, there's an implicit .= * at the start of each pattern, unless it's anchored using a ^. =20 Fix this by rewriting the regexps in a "^\r\n$hs$regexp$hs$eol" style, = where: - hs is: \[^\n\]* (horizontal space), and - eol is (?=3D\r\n) (look-ahead end-of-line). =20 It also turned out to be necessary to drop the -lbl switch, and introdu= ce a corresponding explicit clause. The -lbl clause is placed ALAP, and consequently allowed the default fail clause to trigger. =20 Tested on arm-linux and x86_64-linux. Diff: --- gdb/testsuite/gdb.threads/threadcrash.exp | 29 +++++++++++++++++++--------= -- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/gdb/testsuite/gdb.threads/threadcrash.exp b/gdb/testsuite/gdb.= threads/threadcrash.exp index 3d269ec88c5..592098b9c38 100644 --- a/gdb/testsuite/gdb.threads/threadcrash.exp +++ b/gdb/testsuite/gdb.threads/threadcrash.exp @@ -53,13 +53,19 @@ proc thread_apply_all {} { =20 set unwind_fail false =20 + set eol "(?=3D\r\n)" + set hs "\[^\r\n\]*" + set cmd "thread apply all backtrace" - gdb_test_multiple $cmd "Get thread information" -lbl { - -re "#\[0-9\]+\\\?\\\?\[^\n\]*" { + gdb_test_multiple $cmd "Get thread information" { + -re "^$cmd$eol" { + exp_continue + } + -re "^\r\n#$::decimal\\\?\\\?$hs$eol" { set unwind_fail true exp_continue } - -re "\[^\n\]*syscall_task .location=3DSIGNAL_ALT_STACK\[^\n\]*" { + -re "^\r\n${hs}syscall_task .location=3DSIGNAL_ALT_STACK$hs$eol" { lappend test_list [multi_line ".*sleep.*" \ ".*do_syscall_task .location=3DSIGNAL_ALT_STACK.*" \ ".*signal_handler.*" \ @@ -68,7 +74,7 @@ proc thread_apply_all {} { ".*thread_function.*"] exp_continue } - -re "\[^\n\]*syscall_task .location=3DSIGNAL_HANDLER\[^\n\]*" { + -re "^\r\n${hs}syscall_task .location=3DSIGNAL_HANDLER$hs$eol" { lappend test_list [multi_line ".*sleep.*" \ ".*do_syscall_task .location=3DSIGNAL_HANDLER.*" \ ".*signal_handler.*" \ @@ -77,13 +83,13 @@ proc thread_apply_all {} { ".*thread_function.*"] exp_continue } - -re "\[^\n\]*syscall_task .location=3DNORMAL\[^\n\]*" { + -re "^\r\n${hs}syscall_task .location=3DNORMAL$hs$eol" { lappend test_list [multi_line ".*sleep.*" \ ".*do_syscall_task .location=3DNORMAL.*" \ ".*thread_function.*"] exp_continue } - -re "\[^\n\]*spin_task .location=3DSIGNAL_ALT_STACK\[^\n\]*" { + -re "^\r\n${hs}spin_task .location=3DSIGNAL_ALT_STACK$hs$eol" { lappend test_list [multi_line ".*do_spin_task .location=3DSIGNAL_ALT_= STACK.*" \ ".*signal_handler.*" \ ".*signal handler called.*" \ @@ -91,7 +97,7 @@ proc thread_apply_all {} { ".*thread_function.*"] exp_continue } - -re "\[^\n\]*spin_task .location=3DSIGNAL_HANDLER\[^\n\]*" { + -re "^\r\n${hs}spin_task .location=3DSIGNAL_HANDLER$hs$eol" { lappend test_list [multi_line ".*do_spin_task .location=3DSIGNAL_HAND= LER.*" \ ".*signal_handler.*" \ ".*signal handler called.*" \ @@ -99,16 +105,19 @@ proc thread_apply_all {} { ".*thread_function.*"] exp_continue } - -re "\[^\n\]*spin_task .location=3DNORMAL\[^\n\]*" { + -re "^\r\n${hs}spin_task .location=3DNORMAL$hs$eol" { lappend test_list [multi_line ".*do_spin_task .location=3DNORMAL..*" \ ".*thread_function.*"] exp_continue } - -re "\[^\n\]*main\[^\n\]*" { + -re "^\r\n${hs}main$hs$eol" { lappend test_list ".*main.*" exp_continue } - -re "$::gdb_prompt " { + -re "^\r\n$hs$eol" { + exp_continue + } + -re "^\r\n$::gdb_prompt $" { pass $gdb_test_name } }