From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id UO9FFnQaAmi3qjkAWB0awg (envelope-from ) for ; Fri, 18 Apr 2025 05:25:08 -0400 Authentication-Results: simark.ca; dkim=pass (1024-bit key; unprotected) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=XT/oaSyo; dkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=GtwqG6uV; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=XT/oaSyo; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=GtwqG6uV; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 571721E0C3; Fri, 18 Apr 2025 05:25:08 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-5.4 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham autolearn_force=no version=4.0.1 Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id C13C71E0C0 for ; Fri, 18 Apr 2025 05:25:07 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 719B43857013 for ; Fri, 18 Apr 2025 09:25:07 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 719B43857013 Authentication-Results: sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=XT/oaSyo; dkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=GtwqG6uV; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=XT/oaSyo; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=GtwqG6uV Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2a07:de40:b251:101:10:150:64:2]) by sourceware.org (Postfix) with ESMTPS id 211DC385AC22 for ; Fri, 18 Apr 2025 09:23:30 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 211DC385AC22 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 211DC385AC22 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a07:de40:b251:101:10:150:64:2 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1744968210; cv=none; b=VKTxOyTK8bnYk63Q7Oqmiw7lGuCstoRl110uCZk0sNV1iaIDPRvyhVmVEbgOGlgxFMNF0ZB79CDXN5cPemFs9oL+AGlz9A+08QL8re48Pt4a8sw9jPjzkICpjw6JVHEv9X2iqKEa0RyKVPJN4+N9j9VFK8xlUKu1RPDjlkeRMwQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1744968210; c=relaxed/simple; bh=Cp16iHmAGE/C2aLMTVfOd8uAQ1ohFIvt1rE/gmD2MQs=; h=DKIM-Signature:DKIM-Signature:DKIM-Signature:DKIM-Signature:From: To:Subject:Date:Message-ID:MIME-Version; b=CVosvWVhGOOaQBC/gr5OoL7OSJZEAdOZn8QTD4AhF4LnBPA5m6Af/Q/x4SeNpNacxhdTYY+OXt/+dNIJlNDs0elpw31hb485FDz+bH1y03csHAqFiIL5/Fwj1nCvQ4dTtztItJqCTH0pZ5ZIQzNW852lim5pwgoMU1hY6N7Ziwk= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 211DC385AC22 Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id CBA291F443 for ; Fri, 18 Apr 2025 09:23:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1744968202; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=g+3ZETWNQAPHD9FT4b26JKoHx2NlvjGarEC9p3Yp1RM=; b=XT/oaSyoJ30bNYJUXfj1aohM78uiaztdiim0IPgVs7CmTHd7rw9Q4b7xp4GlHI77cLp12V O/7wEmOZ9EIUJ4qIHCJ5ZrNJRs7srJW9ppGWTo20zQMIDEybIO57/TxwrYmNp2WY5Y5a6t FvHTdsod0UOIyxf+odH308PcjmXHhP8= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1744968202; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=g+3ZETWNQAPHD9FT4b26JKoHx2NlvjGarEC9p3Yp1RM=; b=GtwqG6uV9f1RjV6ZwzBt3DetRdBfGDG8X9RJgSbo2R59/nk+NblJSwg8gyKrFYeMDXpI/C EKTBb5G9nlIyA4Bw== Authentication-Results: smtp-out2.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b="XT/oaSyo"; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=GtwqG6uV DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1744968202; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=g+3ZETWNQAPHD9FT4b26JKoHx2NlvjGarEC9p3Yp1RM=; b=XT/oaSyoJ30bNYJUXfj1aohM78uiaztdiim0IPgVs7CmTHd7rw9Q4b7xp4GlHI77cLp12V O/7wEmOZ9EIUJ4qIHCJ5ZrNJRs7srJW9ppGWTo20zQMIDEybIO57/TxwrYmNp2WY5Y5a6t FvHTdsod0UOIyxf+odH308PcjmXHhP8= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1744968202; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=g+3ZETWNQAPHD9FT4b26JKoHx2NlvjGarEC9p3Yp1RM=; b=GtwqG6uV9f1RjV6ZwzBt3DetRdBfGDG8X9RJgSbo2R59/nk+NblJSwg8gyKrFYeMDXpI/C EKTBb5G9nlIyA4Bw== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id AF66A13A84 for ; Fri, 18 Apr 2025 09:23:22 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id ILRwKQoaAmi+GwAAD6G6ig (envelope-from ) for ; Fri, 18 Apr 2025 09:23:22 +0000 From: Tom de Vries To: gdb-patches@sourceware.org Subject: [PATCH 2/2] [gdb/testsuite] Make gdb.threads/inf-thr-count.exp more readable Date: Fri, 18 Apr 2025 11:23:56 +0200 Message-ID: <20250418092356.4579-3-tdevries@suse.de> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250418092356.4579-1-tdevries@suse.de> References: <20250418092356.4579-1-tdevries@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: CBA291F443 X-Spamd-Result: default: False [-3.01 / 50.00]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; MID_CONTAINS_FROM(1.00)[]; R_MISSING_CHARSET(0.50)[]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; ASN(0.00)[asn:25478, ipnet:::/0, country:RU]; MIME_TRACE(0.00)[0:+]; FROM_HAS_DN(0.00)[]; PREVIOUSLY_DELIVERED(0.00)[gdb-patches@sourceware.org]; RCVD_TLS_ALL(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:dkim,suse.de:mid]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FUZZY_BLOCKED(0.00)[rspamd.com]; TO_DN_NONE(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; RCPT_COUNT_ONE(0.00)[1]; DKIM_TRACE(0.00)[suse.de:+] X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Rspamd-Action: no action X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~public-inbox=simark.ca@sourceware.org While investigating a timeout in gdb.threads/inf-thr-count.exp I noticed that it uses quite some escaping, resulting in hard-to-parse regexps like "\\\$$::decimal". Fix this by reducing the escaping using: - quoting strings using {} instead of "", and - string_to_regexp. Also use multi_line to split up long multi-line regexps. Tested on x86_64-linux. --- gdb/testsuite/gdb.threads/inf-thr-count.exp | 55 +++++++++++++-------- 1 file changed, 34 insertions(+), 21 deletions(-) diff --git a/gdb/testsuite/gdb.threads/inf-thr-count.exp b/gdb/testsuite/gdb.threads/inf-thr-count.exp index 9f52655364a..1174326f2c6 100644 --- a/gdb/testsuite/gdb.threads/inf-thr-count.exp +++ b/gdb/testsuite/gdb.threads/inf-thr-count.exp @@ -43,7 +43,7 @@ if {[build_executable "failed to prepare" $testfile $srcfile \ # Start GDB. Ensure we are in non-stop mode as we need to read from # the inferior while it is running. save_vars {GDBFLAGS} { - append GDBFLAGS " -ex \"set non-stop on\"" + append GDBFLAGS { -ex "set non-stop on"} clean_restart $binfile } @@ -54,22 +54,20 @@ if ![runto_main] { gdb_breakpoint breakpt gdb_continue_to_breakpoint "first breakpt call" +set re_var [string_to_regexp "$"]$decimal + # Check we can see a single thread to begin with. -gdb_test "p \$_inferior_thread_count" \ - "^\\\$$::decimal = 1" \ - "only one thread in \$_inferior_thread_count" +gdb_test {p $_inferior_thread_count} \ + "^$re_var = 1" \ + {only one thread in $_inferior_thread_count} # We don't want thread events, it makes it harder to match GDB's # output. gdb_test_no_output "set print thread-events off" # Continue the program in the background. -set test "continue&" -gdb_test_multiple "continue&" $test { - -re "Continuing\\.\r\n$gdb_prompt " { - pass $test - } -} +gdb_test -no-prompt-anchor "continue&" \ + [string_to_regexp "Continuing."] # Read the 'stage' flag from the inferior. This is initially 0, but # will be set to 1 once the extra thread has been created, and then 2 @@ -88,8 +86,17 @@ proc wait_for_stage { num } { set failure_count 0 set cmd "print /d stage" set stage_flag 0 + + set re_int [string_to_regexp "-"]?$::decimal + + set re_msg \ + [multi_line \ + "Cannot execute this command while the target is running" \ + {Use the "interrupt" command to stop the target} \ + [string_to_regexp "and then try again."]] + gdb_test_multiple "$cmd" "wait for 'stage' flag to be $num" { - -re -wrap "^Cannot execute this command while the target is running\\.\r\nUse the \"interrupt\" command to stop the target\r\nand then try again\\." { + -re -wrap ^$re_msg { fail "$gdb_test_name (can't read asynchronously)" gdb_test_no_output "interrupt" @@ -101,7 +108,7 @@ proc wait_for_stage { num } { } } - -re -wrap "^\\$\[0-9\]* = (\[-\]*\[0-9\]*).*" { + -re -wrap "^$::re_var = ($re_int).*" { set stage_flag $expect_out(1,string) if {$stage_flag != $num} { set stage_flag 0 @@ -131,8 +138,8 @@ if {![wait_for_stage 1]} { if {[target_info exists gdb_protocol] && ([target_info gdb_protocol] == "remote" || [target_info gdb_protocol] == "extended-remote")} { - set new_thread_re "\\\[New Thread \[^\r\n\]+\\\]\r\n" - set exit_thread_re "\\\[Thread \[^\r\n\]+ exited\\\]\r\n" + set new_thread_re {\[New Thread [^\r\n]+\]\r\n} + set exit_thread_re {\[Thread [^\r\n]+ exited\]\r\n} } else { set new_thread_re "" set exit_thread_re "" @@ -141,9 +148,9 @@ if {[target_info exists gdb_protocol] # This is the test we actually care about. Check that the # $_inferior_thread_count convenience variable shows the correct # thread count; the new thread should be visible. -gdb_test "with print thread-events on -- p \$_inferior_thread_count" \ - "^${new_thread_re}\\\$$::decimal = 2" \ - "second thread visible in \$_inferior_thread_count" +gdb_test {with print thread-events on -- p $_inferior_thread_count} \ + "^${new_thread_re}$re_var = 2" \ + {second thread visible in $_inferior_thread_count} # Set a variable in the inferior, this will cause the second thread to # exit. @@ -157,9 +164,9 @@ if {![wait_for_stage 2]} { } # Check that the second thread has gone away. -gdb_test "with print thread-events on -- p \$_inferior_thread_count" \ - "^${exit_thread_re}\\\$$::decimal = 1" \ - "back to one thread visible in \$_inferior_thread_count" +gdb_test {with print thread-events on -- p $_inferior_thread_count} \ + "^${exit_thread_re}$re_var = 1" \ + {back to one thread visible in $_inferior_thread_count} # Set a variable in the inferior, this will cause the second thread to # exit. @@ -168,8 +175,14 @@ gdb_test_no_output -no-prompt-anchor "set variable spin = 0" \ # When the second thread exits, the main thread joins with it, and # then proceeds to hit the breakpt function again. +set re_breakpt [string_to_regexp "breakpt ()"] +set re \ + [multi_line \ + "Thread 1 \[^\r\n\]+ hit Breakpoint $decimal, $re_breakpt\[^\r\n\]+" \ + "\[^\r\n\]+" \ + ""] gdb_test_multiple "" "wait for main thread to stop" { - -re "Thread 1 \[^\r\n\]+ hit Breakpoint $decimal, breakpt \\(\\)\[^\r\n\]+\r\n\[^\r\n\]+\r\n" { + -re $re { pass $gdb_test_name } } -- 2.43.0