From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id ETiJFKsL9V9PTgAAWB0awg (envelope-from ) for ; Tue, 05 Jan 2021 20:00:27 -0500 Received: by simark.ca (Postfix, from userid 112) id 43DD71F0AA; Tue, 5 Jan 2021 20:00:27 -0500 (EST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,RDNS_NONE,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.2 Received: from sourceware.org (unknown [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 055BC1E590 for ; Tue, 5 Jan 2021 20:00:26 -0500 (EST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 8DD943851C16; Wed, 6 Jan 2021 01:00:25 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8DD943851C16 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1609894825; bh=q7+nE9ftzj1cXeN4kvSovmeKtvtH1AP8fHxJsPQmewU=; h=Subject:To:References:Date:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=V4P0BqRk/ZpJLz/KNMq+vaBrGWpxjtxcYKObvyg1ntoHlkEjk0T87rv6U7ep3sQB4 MiCNQMLzg/YHM17lWy5dmaxtgWnq11JuQTzmoYT1wPN7Kdb+EKPVRcGKRm4zIjI/IN ynCs17CTzsXpnobkqqaxvxBiuQZFE368hxdun6Os= Received: from smtp.polymtl.ca (smtp.polymtl.ca [132.207.4.11]) by sourceware.org (Postfix) with ESMTPS id B831A3851C16 for ; Wed, 6 Jan 2021 01:00:19 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org B831A3851C16 Received: from simark.ca (simark.ca [158.69.221.121]) (authenticated bits=0) by smtp.polymtl.ca (8.14.7/8.14.7) with ESMTP id 10610Dtu023209 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 5 Jan 2021 20:00:18 -0500 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp.polymtl.ca 10610Dtu023209 Received: from [10.0.0.213] (192-222-157-6.qc.cable.ebox.net [192.222.157.6]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id 507821E590; Tue, 5 Jan 2021 20:00:13 -0500 (EST) Subject: Re: [PATCH v2 3/3] gdb: introduce scoped debug prints To: Simon Marchi , tdevries References: <20201216204737.900975-1-simon.marchi@efficios.com> <20201216204737.900975-3-simon.marchi@efficios.com> <3ad3b11f-8a72-cd1d-a138-59c47300f147@polymtl.ca> <66ff5e72-f002-ed4f-075a-3054d17e7862@suse.de> <97ef7c08-c281-963e-96ba-0ba64a123980@polymtl.ca> <13cd76a6-9bce-706d-f98e-aa34f61cad2c@polymtl.ca> <42caafa7-b5b1-f828-3eaf-76e314f334ac@efficios.com> Message-ID: Date: Tue, 5 Jan 2021 20:00:13 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.6.0 MIME-Version: 1.0 In-Reply-To: <42caafa7-b5b1-f828-3eaf-76e314f334ac@efficios.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit X-Poly-FromMTA: (simark.ca [158.69.221.121]) at Wed, 6 Jan 2021 01:00:13 +0000 X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Simon Marchi via Gdb-patches Reply-To: Simon Marchi Cc: gdb-patches@sourceware.org Errors-To: gdb-patches-bounces@sourceware.org Sender: "Gdb-patches" On 2021-01-05 4:54 p.m., Simon Marchi wrote: > On 2021-01-05 4:26 p.m., tdevries wrote: >> Yeah, that's not a bad idea. >> >> The only bit that concerns me is that there's already a -prompt switch for gdb_test_multiple, which does not add on the terminating '$', while this version does. >> >> It's probably a good idea to have the -prompt switch to behave the same in both cases. > > Hmm I see. Intuitively, I'd try to make gdb_test_multiple add > the terminating $. Do you foresee some problems with that? > > The prompt passed to gdb_test_multiple only appears to be used > for the various failing cases, so I don't expect that to change > any passing test (I'll give it a try). Well, now that I think of it a bit more, it would be much easier and safer to just make my gdb_test_sequence's -prompt work like gdb_test_multiple's -prompt, and have the caller add the $ itself. Updated patch below. >From 23d207b6f391312f82fcaeae9936c97470461415 Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Tue, 05 Jan 2021 11:02:07 -0500 Subject: [PATCH] gdb/testsuite: fix race in gdb.threads/signal-while-stepping-over-bp-other-thread.exp Commit 3ec3145c5dd6 ("gdb: introduce scoped debug prints") updated some tests using "set debug infrun" to handle the fact that a debug print is now shown after the prompt, after an inferior stop. The same issue happens in gdb.threads/signal-while-stepping-over-bp-other-thread.exp. If I run it in a loop, it eventually fails like these other tests. The problem is that the testsuite expects to see $gdb_prompt followed by the end of the buffer. It happens that expect reads $gdb_prompt and the debug print at the same time, in which case the regexp never matches and we get a timeout. The fix is the same as was done in 3ec3145c5dd6, make the testsuite believe that the prompt is the standard GDB prompt followed by that debug print. Since that test uses gdb_test_sequence, and the expected prompt is in gdb_test_sequence, add a -prompt switch to gdb_test_sequence to override the prompt used for that call. gdb/testsuite/ChangeLog: * lib/gdb.exp (gdb_test_sequence): Accept -prompt switch. * gdb.threads/signal-while-stepping-over-bp-other-thread.exp: Pass prompt containing debug print to gdb_test_sequence. Change-Id: I33161c53ddab45cdfeadfd50b964f8dc3caa9729 --- diff --git a/gdb/testsuite/gdb.threads/signal-while-stepping-over-bp-other-thread.exp b/gdb/testsuite/gdb.threads/signal-while-stepping-over-bp-other-thread.exp index fe84253..2807485 100644 --- a/gdb/testsuite/gdb.threads/signal-while-stepping-over-bp-other-thread.exp +++ b/gdb/testsuite/gdb.threads/signal-while-stepping-over-bp-other-thread.exp @@ -102,7 +102,7 @@ gdb_test "set debug infrun 1" set test "step" -gdb_test_sequence $test $test { +gdb_test_sequence $test $test -prompt "$gdb_prompt \\\[infrun\\\] fetch_inferior_event: exit\r\n$" { "need to step-over" "resume_1: step=1," "signal arrived while stepping over breakpoint" diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp index 3f61da8..140e396 100644 --- a/gdb/testsuite/lib/gdb.exp +++ b/gdb/testsuite/lib/gdb.exp @@ -1401,6 +1401,9 @@ # EXPECTED_OUTPUT_LIST is a list of regexps of expected output, which are # processed in order, and all must be present in the output. # +# The -prompt switch can be used to override the prompt expected at the end of +# the output sequence. +# # It is unnecessary to specify ".*" at the beginning or end of any regexp, # there is an implicit ".*" between each element of EXPECTED_OUTPUT_LIST. # There is also an implicit ".*" between the last regexp and the gdb prompt. @@ -1413,16 +1416,32 @@ # 0 if the test passes, # -1 if there was an internal error. -proc gdb_test_sequence { command test_name expected_output_list } { +proc gdb_test_sequence { args } { global gdb_prompt + + parse_args {{prompt ""}} + + if { $prompt == "" } { + set prompt "$gdb_prompt $" + } + + if { [llength $args] != 3 } { + error "Unexpected # of arguments, expecting: COMMAND TEST_NAME EXPECTED_OUTPUT_LIST" + } + + lassign $args command test_name expected_output_list + if { $test_name == "" } { set test_name $command } + lappend expected_output_list ""; # implicit ".*" before gdb prompt + if { $command != "" } { send_gdb "$command\n" } - return [gdb_expect_list $test_name "$gdb_prompt $" $expected_output_list] + + return [gdb_expect_list $test_name $prompt $expected_output_list] }