From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm1-f41.google.com (mail-wm1-f41.google.com [209.85.128.41]) by sourceware.org (Postfix) with ESMTPS id 143AD3858C2D for ; Wed, 30 Mar 2022 14:21:42 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 143AD3858C2D Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=palves.net Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-wm1-f41.google.com with SMTP id 123-20020a1c1981000000b0038b3616a71aso46474wmz.4 for ; Wed, 30 Mar 2022 07:21:41 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=oCh0Y28fd+6TZoEi1t/35+EgkDRStamcU+ftaSVl6uI=; b=n04uGkPB2XsxSWxWbDKmT+1Yf4bvcLpK1Ffd2J06BJLI+1ZVRklg6SFWs8Cq0EhIA2 KCUCbK3KOP9boccZKM4HZrOPxnF/vu/o6t80/VL9HwEvc2EbusWicZSLanCkQhJ1XvN4 rtbF5njU3XatlC6VradNpc4TK73kfGUIybT9d2NhJcxNnKtdz4ISftEeioYZQ+CeBIMz IdZLLx3bl1gakyzH0gIKg8fuZxOQlFuwuMrNmkbCxa6VrNyn8uFS1DfPCBEASKvl5oqY uPFy/jV1TvVa0isVlUNqx0hx7pyz6/CIC22B72HRIXZsuZkaTb9cksKLbBNwJ1V+wCue Bggw== X-Gm-Message-State: AOAM530+8H+avndJrHA8OL5f1saFUE7sd19cta6qvVcfz4x2Vi9ey0Ox onvR/LWyAl9wb8DSJI+Vjp1Jk0qiuG8= X-Google-Smtp-Source: ABdhPJzoVwaHv5vW4bNtZVImLJpPqou9mBdEy9C94niuR4y1XSpqqmVQSAamjkBi8Uzh8/x7Yc0YVg== X-Received: by 2002:a05:600c:1553:b0:38c:90fb:d3ca with SMTP id f19-20020a05600c155300b0038c90fbd3camr4865257wmg.158.1648650100691; Wed, 30 Mar 2022 07:21:40 -0700 (PDT) Received: from ?IPV6:2001:8a0:f924:2600:209d:85e2:409e:8726? ([2001:8a0:f924:2600:209d:85e2:409e:8726]) by smtp.gmail.com with ESMTPSA id v18-20020adfc5d2000000b0020589b76704sm18494194wrg.70.2022.03.30.07.21.39 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 30 Mar 2022 07:21:39 -0700 (PDT) Message-ID: Date: Wed, 30 Mar 2022 15:21:38 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.7.0 Subject: Re: [PATCH] gdb/testsuite: Fix race in gdb.dwarf2/calling-convention.exp Content-Language: en-US To: Lancelot SIX , gdb-patches@sourceware.org Cc: lsix@lancelotsix.com References: <20220330125013.137768-1-lancelot.six@amd.com> From: Pedro Alves In-Reply-To: <20220330125013.137768-1-lancelot.six@amd.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-3.7 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, NICE_REPLY_A, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org 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: , X-List-Received-Date: Wed, 30 Mar 2022 14:21:44 -0000 On 2022-03-30 13:50, Lancelot SIX via Gdb-patches wrote: > Pedro Alves warned me that there is a race in > gdb.dwarf2/calling-convention.exp making the test sometimes fail on his > setup. This can be reliably reproduced using : > > make check-read1 TESTS="gdb.dwarf2/calling-convention.exp" > > The relevant part of the gdb.log file is: > > return 35 > Function 'foo' does not follow the target calling convention. > If you continue, setting the return value will probably lead to unpredictable behaviors. > Make foo return now? (y or n) PASS: gdb.dwarf2/calling-convention.exp: return 35 > n > Not confirmed > (gdb) FAIL: gdb.dwarf2/calling-convention.exp: finish > > The issue is that when doing the test for "return 35", the DejaGnu test > sends "n" (to tell GDB not to perform the return action) but never > consumes the "Not confirmed" acknowledgment sent by GDB. Later, when > trying to do the next test, DejaGnu tries to match the leftover output > from the "return" test. As this output is not expected, the test fails. > > Fix this by consuming the "Not confirmed\r\n$gdb_prompt " output. > > While at cleaning up this test, also improve the regex for the return > test: > - Remove the leading ".*" pattern. > - Replace the "$" (end of line marker) with "\$" because it does not > identify a TCL variable. I don't think the latter is necessary. If it was, then the >3k instances we have would be problematic: $ grep -rn " $\"" testsuite/ | wc -l 3497 > gdb_test_multiple "return 35" "" { > - -re ".*Function 'foo' does not follow the target calling convention.\r\nIf you continue, setting the return value will probably lead to unpredictable behaviors.\r\nMake foo return now?.*\\(y or n\\) $" { > - send_gdb "n\n" > + -re "Function 'foo' does not follow the target calling convention.\r\nIf you continue, setting the return value will probably lead to unpredictable behaviors.\r\nMake foo return now?.*\\(y or n\\) \$" { This should escape the "?" in "now?" too, as '?' has special meaning in regexps. The ".*" just before (y or n) isn't needed, right? > pass $gdb_test_name > + gdb_test "n" "Not confirmed" "Cancel return" Lowercase messages please. Note gdb_test can handle this itself, it supports two extra arguments to handle questions. Like so: gdb_test "return 35" \ "Not confirmed" \ "return 35" \ "Function 'foo' does not follow the target calling convention.\r\nIf you continue, setting the return value will probably lead to unpredictable behaviors.\r\nMake foo return now\\? \\(y or n\\) $" \ "n" Note that if gdb doesn't print the question and prints "Not confirmed" straight away, the test will still pass, because the question is optional. IMHO that's a gdb_test misfeature, though, which can lead to regressions without us noticing. I wrote a patch to change that, and it caught a number of wrong things in the testsuite. I'll send it a bit later.