From patchwork Thu Oct 26 09:04:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guinevere Larsen X-Patchwork-Id: 78547 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 E27A9385B537 for ; Thu, 26 Oct 2023 09:05:26 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id C81713858D37 for ; Thu, 26 Oct 2023 09:05:05 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C81713858D37 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org C81713858D37 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1698311108; cv=none; b=l5mBU9YMH5kT9ndWBHG8HUPQSjUHE6ymbLU7r0DDUAO4p22Oa6cSlv6qp1fJ3X7m+3aDCzMvd9P1w8t5bUYUBjXeeyG/mNxvjE5CkIrMSQfidEA6bCloKjN7QorOdsu5eVKxuTjWesgcOJuv+25tFMJymAZBIoRnrPyMhAyy/88= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1698311108; c=relaxed/simple; bh=0Fp1vIgWv8F6Ykv/Twv5AEJ27kYsdrx72wHwy0BbAQ8=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=xL4bkR+Qz2sRko4Bq0GvNQqIK8ldGL6reotlsu++7a9iB40bzEWwqwM+585PUXo5OCIKXGHqMQHsB2oyY0KXK0GDcm9MEPFYfPSyQUOPt9Z+7petbJZDZ+rZT22N7NO+VBbLfSmCUzcQXvOWRbPNJxxEjLcggFmwdbjpOZ3mdx8= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1698311105; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=JNZcAAzCznkb348I2cMUrd3vuZ/GuUh82ifQEjKJ9HM=; b=AK/KolKC2VQau6Hzb8MgQ7OqWBqofVa8+U6jHJmbJ+cF03NHOnS7wiTAoqsIC1K6t2WJu+ sNLfZHQthwNEH4xVnz3g0EU96SMmIl2Cmg5P9/Fgp5LKLHOYLSU5TW+vU1AfUqy9GkQtnf Jss3Q9R4WFsEjxe1SRtUq3YLOoSMUXA= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-251-pPECP-2wNpC_5UWa_Nzm7A-1; Thu, 26 Oct 2023 05:05:02 -0400 X-MC-Unique: pPECP-2wNpC_5UWa_Nzm7A-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (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 mimecast-mx02.redhat.com (Postfix) with ESMTPS id A701C101A54C for ; Thu, 26 Oct 2023 09:05:02 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.45.226.65]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2D9ED2166B26; Thu, 26 Oct 2023 09:05:02 +0000 (UTC) From: Guinevere Larsen To: gdb-patches@sourceware.org Cc: Guinevere Larsen Subject: [PATCH] gdb/testsuite: Work around clang fails in gdb.base/watchpoint.exp Date: Thu, 26 Oct 2023 11:04:48 +0200 Message-ID: <20231026090448.1182959-1-blarsen@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.6 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-11.5 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP 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 as mentioned in commit def86538a46f7ce6fbb215cfb184e23015b5d538, clang doesn't use the CFA information for variable locations, making it so software watchpoints get false hits when exiting a function. Differently to that commit, however, gdb.base/watchpoint.exp also needs to be explicitly continued so the inferior will remain in sync with what the exp file expects, so this commit uses gdb_test_multiple to identify that situation. I also chose to keep the test passing in that scenario because the GDB feature being tested, software watchpoints, is working as expected. --- gdb/testsuite/gdb.base/watchpoint.exp | 82 +++++++++++++++++++++++++-- 1 file changed, 76 insertions(+), 6 deletions(-) diff --git a/gdb/testsuite/gdb.base/watchpoint.exp b/gdb/testsuite/gdb.base/watchpoint.exp index 70864655c6d..5d8d6b9cb31 100644 --- a/gdb/testsuite/gdb.base/watchpoint.exp +++ b/gdb/testsuite/gdb.base/watchpoint.exp @@ -30,6 +30,11 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {deb return -1 } +set using_clang 0 +if {[test_compiler_info "clang-*"]} { + set using_clang 1 +} + # True if we're forcing no hardware watchpoints. set no_hw 0 @@ -486,6 +491,20 @@ proc test_complex_watchpoint {} { } fail $test } + -re -wrap ".*Continuing.*\[Ww\]atchpoint.*" { + global no_hw + global using_clang + # Clang doesn't use the CFA, so software watchpoints get one + # false hit here. Detect if we're in that situation and + # ignore the false hit. For more info, see: + # https://github.com/llvm/llvm-project/issues/64390 + if {$using_clang == 1 && $no_hw == 1} { + send_gdb "cont\n" + exp_continue + } else { + fail $gdb_test_name + } + } } gdb_continue_to_breakpoint "func2 breakpoint here, second time" @@ -501,8 +520,25 @@ proc test_complex_watchpoint {} { "trigger1 partially local watch" gdb_test "cont" "Continuing.*\[Ww\]atchpoint .*: local_a . ival5.*" \ "trigger2 partially local watch" - gdb_test "cont" "Continuing.*\[Ww\]atchpoint .* deleted because the program has left the block in.*which its expression is valid.*" \ - "self-delete partially local watch" + gdb_test_multiple "cont" "self-delete partially local watch" { + -re -wrap "Continuing.*\[Ww\]atchpoint .* deleted because the program has left the block in.*which its expression is valid.*" { + pass $gdb_test_name + } + -re -wrap ".*Continuing.*\[Ww\]atchpoint.*" { + global no_hw + global using_clang + # Clang doesn't use the CFA, so software watchpoints get one + # false hit here. Detect if we're in that situation and + # ignore the false hit. For more info, see: + # https://github.com/llvm/llvm-project/issues/64390 + if {$using_clang == 1 && $no_hw == 1} { + send_gdb "cont\n" + exp_continue + } else { + fail $gdb_test_name + } + } + } # We should be in "func2" again now. Test a watch of a # static (non-stack-based) local. Since this has scope @@ -535,8 +571,25 @@ proc test_complex_watchpoint {} { "set local watch in recursive call" gdb_test "cont" "Continuing.*\[Ww\]atchpoint .*: local_x.*New value = 2.*" \ "trigger local watch in recursive call" - gdb_test "cont" "Continuing.*\[Ww\]atchpoint .* deleted because the program has left the block in.*which its expression is valid.*" \ - "self-delete local watch in recursive call" + gdb_test_multiple "cont" "self-delete local watch in recursive call" { + -re -wrap "Continuing.*\[Ww\]atchpoint .* deleted because the program has left the block in.*which its expression is valid.*" { + pass $gdb_test_name + } + -re -wrap ".*Continuing.*\[Ww\]atchpoint.*" { + global no_hw + global using_clang + # Clang doesn't use the CFA, so software watchpoints get one + # false hit here. Detect if we're in that situation and + # ignore the false hit. For more info, see: + # https://github.com/llvm/llvm-project/issues/64390 + if {$using_clang == 1 && $no_hw == 1} { + send_gdb "cont\n" + exp_continue + } else { + fail $gdb_test_name + } + } + } } # Repeat the preceding test, but this time use "recurser::local_x" as @@ -551,8 +604,25 @@ proc test_complex_watchpoint {} { "set local watch in recursive call with explicit scope" gdb_test "cont" "Continuing.*\[Ww\]atchpoint .*: recurser::local_x.*New value = 2.*" \ "trigger local watch with explicit scope in recursive call" - gdb_test "cont" "Continuing.*\[Ww\]atchpoint .* deleted because the program has left the block in.*which its expression is valid.*" \ - "self-delete local watch with explicit scope in recursive call (2)" + gdb_test_multiple "cont" "self-delete local watch with explicit scope in recursive call (2)" { + -re -wrap "Continuing.*\[Ww\]atchpoint .* deleted because the program has left the block in.*which its expression is valid.*" { + pass $gdb_test_name + } + -re -wrap ".*Continuing.*\[Ww\]atchpoint.*" { + global no_hw + global using_clang + # Clang doesn't use the CFA, so software watchpoints get one + # false hit here. Detect if we're in that situation and + # ignore the false hit. For more info, see: + # https://github.com/llvm/llvm-project/issues/64390 + if {$using_clang == 1 && $no_hw == 1} { + send_gdb "cont\n" + exp_continue + } else { + fail $gdb_test_name + } + } + } } # Disable everything so we can finish the program at full speed