From patchwork Fri Mar 8 09:33:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom de Vries X-Patchwork-Id: 86970 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id C72A6385DC06 for ; Fri, 8 Mar 2024 12:06:25 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2a07:de40:b251:101:10:150:64:1]) by sourceware.org (Postfix) with ESMTPS id 4AA8D3858D38 for ; Fri, 8 Mar 2024 12:06:00 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 4AA8D3858D38 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 4AA8D3858D38 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a07:de40:b251:101:10:150:64:1 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1709899562; cv=none; b=NIwpqqtaz3on5HcYJc4YGf7YvEdQ0CFNl03ENoAw57ajlWn0UxjtkqV2UTYcL7/SpTgEpEp7FZbf0Zyf25dX+R+s+xige74Mf+ljNWdCuw6YbRdPv4Exbs37xxEpFKonhTGC/8Og5mH8MLfcgZRiwJ+YsWrVu0TKmEmtzyMYEnM= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1709899562; c=relaxed/simple; bh=xruwDQc9YTNLL8kosJ1V8Em+fS3O+DxPS/P/Kn6G8E4=; h=DKIM-Signature:DKIM-Signature:DKIM-Signature:DKIM-Signature:From: To:Subject:Date:Message-Id:MIME-Version; b=q3ZliI7Pcs5H7e+NOvogANq1BQzkqe89NnGfQ+hUllEBWbM68fAdncPvPkRtp4pDJ9ujFzujNqmisa1OnNdrluoDvc06/8fxOWA8ckUD/JHjPI6bfs5I4IgyLAFafH3Kjh/srJje/RcN83ERWx+5daStlw9in6PP1km3TyPz4Eg= ARC-Authentication-Results: i=1; server2.sourceware.org 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-out1.suse.de (Postfix) with ESMTPS id 59A991715A for ; Fri, 8 Mar 2024 09:33:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1709890386; 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=MqZoqKqloAGayzfNCARmH5VrZtWXyH0aQCZ7ZvMrGfo=; b=My6Y3uod/3t11qjFWHGIBbz66VDPyisT949V4n/QHgadPffHns53syAW8wzknk+dn2stKE D9j0ltHic7Gk7M3+e3GXCBLGmZqvG6PS5q0i2lyDjK2BI51XE2KBjwDoDtprl9JG9Pnd9G AX38zL0VfmJGNVOBt450VtfNjdnYX6E= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1709890386; 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=MqZoqKqloAGayzfNCARmH5VrZtWXyH0aQCZ7ZvMrGfo=; b=XY2P6h5es0QA2SFRIc2znPLajC3iy22/i+jQC09gVBf67KVec/iojKiTZSKHpRG4b+tAcU NeGtqh4vHTpp53AQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1709890386; 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=MqZoqKqloAGayzfNCARmH5VrZtWXyH0aQCZ7ZvMrGfo=; b=My6Y3uod/3t11qjFWHGIBbz66VDPyisT949V4n/QHgadPffHns53syAW8wzknk+dn2stKE D9j0ltHic7Gk7M3+e3GXCBLGmZqvG6PS5q0i2lyDjK2BI51XE2KBjwDoDtprl9JG9Pnd9G AX38zL0VfmJGNVOBt450VtfNjdnYX6E= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1709890386; 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=MqZoqKqloAGayzfNCARmH5VrZtWXyH0aQCZ7ZvMrGfo=; b=XY2P6h5es0QA2SFRIc2znPLajC3iy22/i+jQC09gVBf67KVec/iojKiTZSKHpRG4b+tAcU NeGtqh4vHTpp53AQ== 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 32AC71378C for ; Fri, 8 Mar 2024 09:33:05 +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 UOc1C1Hb6mWLYAAAD6G6ig (envelope-from ) for ; Fri, 08 Mar 2024 09:33:05 +0000 From: Tom de Vries To: gdb-patches@sourceware.org Subject: [PATCH v4 2/6] gdb/testsuite: Fix gdb.threads/threadcrash.exp with check-readmore Date: Fri, 8 Mar 2024 10:33:38 +0100 Message-Id: <20240308093342.26745-3-tdevries@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20240308093342.26745-1-tdevries@suse.de> References: <20240308093342.26745-1-tdevries@suse.de> MIME-Version: 1.0 X-Spam-Level: Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=My6Y3uod; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=XY2P6h5e X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Spamd-Result: default: False [-1.51 / 50.00]; RCVD_VIA_SMTP_AUTH(0.00)[]; RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:106:10:150:64:167:received]; R_MISSING_CHARSET(2.50)[]; TO_DN_NONE(0.00)[]; BROKEN_CONTENT_TYPE(1.50)[]; RCVD_COUNT_THREE(0.00)[3]; DKIM_TRACE(0.00)[suse.de:+]; MX_GOOD(-0.01)[]; NEURAL_HAM_SHORT(-0.20)[-1.000]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; BAYES_HAM(-3.00)[100.00%]; ARC_NA(0.00)[]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FROM_HAS_DN(0.00)[]; DWL_DNSWL_MED(-2.00)[suse.de:dkim]; TO_MATCH_ENVRCPT_ALL(0.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; MIME_GOOD(-0.10)[text/plain]; PREVIOUSLY_DELIVERED(0.00)[gdb-patches@sourceware.org]; RCPT_COUNT_ONE(0.00)[1]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; MID_CONTAINS_FROM(1.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:dkim]; FUZZY_BLOCKED(0.00)[rspamd.com]; RCVD_TLS_ALL(0.00)[] X-Spam-Score: -1.51 X-Rspamd-Queue-Id: 59A991715A X-Spam-Status: No, score=-12.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org 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+patchwork=sourceware.org@sourceware.org With check-readmore, I run into: ... FAIL: gdb.threads/threadcrash.exp: test_corefile: \ $thread_count == [llength $test_list] ... 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 thread can consume a line that was supposed to match another thread. For instance, there's this regexp: ... -re "\[^\n\]*syscall_task .location=SIGNAL_ALT_STACK\[^\n\]*" { ... It's limited at the end by \[^\n\]*, meaning the match stops at the end of the line. 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 ^. Fix this by rewriting the regexps in a "^\r\n$hs$regexp$hs$eol" style, where: - hs is: \[^\n\]* (horizontal space), and - eol is (?=\r\n) (look-ahead end-of-line). It also turned out to be necessary to drop the -lbl switch, and introduce a corresponding explicit clause. The -lbl clause is placed ALAP, and consequently allowed the default fail clause to trigger. Tested on arm-linux and x86_64-linux. --- 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 {} { set unwind_fail false + set eol "(?=\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=SIGNAL_ALT_STACK\[^\n\]*" { + -re "^\r\n${hs}syscall_task .location=SIGNAL_ALT_STACK$hs$eol" { lappend test_list [multi_line ".*sleep.*" \ ".*do_syscall_task .location=SIGNAL_ALT_STACK.*" \ ".*signal_handler.*" \ @@ -68,7 +74,7 @@ proc thread_apply_all {} { ".*thread_function.*"] exp_continue } - -re "\[^\n\]*syscall_task .location=SIGNAL_HANDLER\[^\n\]*" { + -re "^\r\n${hs}syscall_task .location=SIGNAL_HANDLER$hs$eol" { lappend test_list [multi_line ".*sleep.*" \ ".*do_syscall_task .location=SIGNAL_HANDLER.*" \ ".*signal_handler.*" \ @@ -77,13 +83,13 @@ proc thread_apply_all {} { ".*thread_function.*"] exp_continue } - -re "\[^\n\]*syscall_task .location=NORMAL\[^\n\]*" { + -re "^\r\n${hs}syscall_task .location=NORMAL$hs$eol" { lappend test_list [multi_line ".*sleep.*" \ ".*do_syscall_task .location=NORMAL.*" \ ".*thread_function.*"] exp_continue } - -re "\[^\n\]*spin_task .location=SIGNAL_ALT_STACK\[^\n\]*" { + -re "^\r\n${hs}spin_task .location=SIGNAL_ALT_STACK$hs$eol" { lappend test_list [multi_line ".*do_spin_task .location=SIGNAL_ALT_STACK.*" \ ".*signal_handler.*" \ ".*signal handler called.*" \ @@ -91,7 +97,7 @@ proc thread_apply_all {} { ".*thread_function.*"] exp_continue } - -re "\[^\n\]*spin_task .location=SIGNAL_HANDLER\[^\n\]*" { + -re "^\r\n${hs}spin_task .location=SIGNAL_HANDLER$hs$eol" { lappend test_list [multi_line ".*do_spin_task .location=SIGNAL_HANDLER.*" \ ".*signal_handler.*" \ ".*signal handler called.*" \ @@ -99,16 +105,19 @@ proc thread_apply_all {} { ".*thread_function.*"] exp_continue } - -re "\[^\n\]*spin_task .location=NORMAL\[^\n\]*" { + -re "^\r\n${hs}spin_task .location=NORMAL$hs$eol" { lappend test_list [multi_line ".*do_spin_task .location=NORMAL..*" \ ".*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 } }