From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1726) id 72AFB3858C20; Sat, 4 Feb 2023 16:19:17 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 72AFB3858C20 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1675527557; bh=QME/+LUXvwLBN3k5eJL4owGYhHPMIFdsu6hw/J4/hxc=; h=From:To:Subject:Date:From; b=gBguZsczvIAYxM8WS0Zz9gZYWbqwnaa2QdaiWoDVW8OZV1+WYqJXEcZdaCXkIpi4U 0P+TT5ip+N/w28l++JKvMPugqk6znu57IuFqqHUm8bs9D+7ON3TEKOyDVEepCqEd78 vL1rpm0+KKZ/gY5NWJa3wGEUcXl2XMg6AlBHZXKQ= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Andrew Burgess To: gdb-cvs@sourceware.org Subject: [binutils-gdb] gdb/testsuite: don't try to set non-stop mode on a running target X-Act-Checkin: binutils-gdb X-Git-Author: Andrew Burgess X-Git-Refname: refs/heads/master X-Git-Oldrev: ba268471bf9a2b76efc0d7a9c05291f7e8cd4424 X-Git-Newrev: 79436bfc5aa71973f154b855f7440ed62ddd9582 Message-Id: <20230204161917.72AFB3858C20@sourceware.org> Date: Sat, 4 Feb 2023 16:19:17 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D79436bfc5aa7= 1973f154b855f7440ed62ddd9582 commit 79436bfc5aa71973f154b855f7440ed62ddd9582 Author: Andrew Burgess Date: Thu Nov 24 19:36:23 2022 +0000 gdb/testsuite: don't try to set non-stop mode on a running target =20 The test gdb.threads/thread-specific-bp.exp tries to set non-stop mode on a running target, something which the manual makes clear is not allowed. =20 This commit restructures the test a little, we now set the non-stop mode as part of the GDBFLAGS, so the mode will be set before GDB connects to the target. As a consequence I'm able to move the with_test_prefix out of the check_thread_specific_breakpoint proc. The check_thread_specific_breakpoint proc is now called within a loop. =20 After this commit the gdb.threads/thread-specific-bp.exp test still has some failures, this is because of an issue GDB currently has printing "Thread ... exited" messages. This problem should be addressed by this patch: =20 https://sourceware.org/pipermail/gdb-patches/2022-December/194694.html =20 when it is merged. Diff: --- gdb/testsuite/gdb.threads/thread-specific-bp.exp | 138 +++++++++++--------= ---- 1 file changed, 67 insertions(+), 71 deletions(-) diff --git a/gdb/testsuite/gdb.threads/thread-specific-bp.exp b/gdb/testsui= te/gdb.threads/thread-specific-bp.exp index f603b24fa31..f440574d780 100644 --- a/gdb/testsuite/gdb.threads/thread-specific-bp.exp +++ b/gdb/testsuite/gdb.threads/thread-specific-bp.exp @@ -24,8 +24,6 @@ if {[gdb_compile_pthreads \ return -1 } =20 -clean_restart ${binfile} - # Extract and return the thread ID of the thread stopped at function # FUNC. =20 @@ -45,86 +43,84 @@ proc get_thread_id {func} { return $thre } =20 -proc check_thread_specific_breakpoint {mode} { - with_test_prefix "$mode" { - global gdb_prompt +proc check_thread_specific_breakpoint {non_stop} { + global gdb_prompt =20 - if ![runto_main] { - return -1 - } + if { ![runto_main] } { + return -1 + } =20 - set main_thre [get_thread_id "main"] - if { $main_thre < 0 } { - return -1 - } + set main_thre [get_thread_id "main"] + if { $main_thre < 0 } { + return -1 + } =20 - gdb_breakpoint "start" - gdb_continue_to_breakpoint "start" + gdb_breakpoint "start" + gdb_continue_to_breakpoint "start" =20 - set start_thre [get_thread_id "start"] - if { $start_thre < 0 } { - return -1 - } + set start_thre [get_thread_id "start"] + if { $start_thre < 0 } { + return -1 + } =20 - # Set a thread-specific breakpoint at "main". This can't ever - # be hit, but that's OK. - gdb_breakpoint "main thread $start_thre" - gdb_test "info break" ".*breakpoint.*thread $start_thre" "breakpoint set" - - # Set breakpoint at a place only reacheable after the "start" - # thread exits. - gdb_breakpoint "end" - - # Switch back to the main thread, and resume all threads. The - # "start" thread exits, and the main thread reaches "end". - gdb_test "thread $main_thre" \ - "Switching to thread $main_thre.*" \ - "thread $main_thre selected" - - if { $mode =3D=3D "non-stop" } { - set cmd "continue -a" - } else { - set cmd "continue" - } - set test "continue to end" - set thread_exited 0 - set prompt 0 - gdb_test_multiple "$cmd" $test -lbl { - -re "(^|\r\n)\\\[Thread \[^\r\n\]* exited](?=3D\r\n)" { - if { $prompt } { - pass $gdb_test_name - } else { - set thread_exited 1 - exp_continue - } + # Set a thread-specific breakpoint at "main". This can't ever + # be hit, but that's OK. + gdb_breakpoint "main thread $start_thre" + gdb_test "info break" ".*breakpoint.*thread $start_thre" "breakpoint s= et" + + # Set breakpoint at a place only reacheable after the "start" + # thread exits. + gdb_breakpoint "end" + + # Switch back to the main thread, and resume all threads. The + # "start" thread exits, and the main thread reaches "end". + gdb_test "thread $main_thre" \ + "Switching to thread $main_thre.*" \ + "thread $main_thre selected" + + if { $non_stop } { + set cmd "continue -a" + } else { + set cmd "continue" + } + set test "continue to end" + set thread_exited 0 + set prompt 0 + gdb_test_multiple "$cmd" $test -lbl { + -re "(^|\r\n)\\\[Thread \[^\r\n\]* exited](?=3D\r\n)" { + if { $prompt } { + pass $gdb_test_name + } else { + set thread_exited 1 + exp_continue } - -re "\r\n$gdb_prompt " { - if { $thread_exited } { - pass $gdb_test_name - } else { - set prompt 1 - exp_continue - } + } + -re "\r\n$gdb_prompt " { + if { $thread_exited } { + pass $gdb_test_name + } else { + set prompt 1 + exp_continue } } + } =20 - set test "thread-specific breakpoint was deleted" - gdb_test_multiple "info breakpoint" $test { - -re "thread $start_thre\n$gdb_prompt $" { - fail $test - } - -re "$gdb_prompt $" { - pass $test - } + set test "thread-specific breakpoint was deleted" + gdb_test_multiple "info breakpoint" $test { + -re "thread $start_thre\n$gdb_prompt $" { + fail $test + } + -re "$gdb_prompt $" { + pass $test } } } =20 -# Test all-stop mode. -check_thread_specific_breakpoint "all-stop" - -clean_restart ${binfile} +foreach_with_prefix non_stop {on off} { + save_vars { GDBFLAGS } { + append GDBFLAGS " -ex \"set non-stop $non_stop\"" + clean_restart $binfile + } =20 -# Test non-stop mode. -gdb_test_no_output "set non-stop on" "set non-stop mode" -check_thread_specific_breakpoint "non-stop" + check_thread_specific_breakpoint $non_stop +}