From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id SKgjJ58c7GZDJzAAWB0awg (envelope-from ) for ; Thu, 19 Sep 2024 08:44:15 -0400 Authentication-Results: simark.ca; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=YbQgEt1F; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 8AE581E353; Thu, 19 Sep 2024 08:44:15 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-12.8 required=5.0 tests=ARC_SIGNED,ARC_VALID, BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU, MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI,RCVD_IN_VALIDITY_CERTIFIED, RCVD_IN_VALIDITY_RPBL,RCVD_IN_VALIDITY_SAFE,URIBL_BLOCKED, URIBL_DBL_BLOCKED_OPENDNS autolearn=ham autolearn_force=no version=4.0.0 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 E65F81E05C for ; Thu, 19 Sep 2024 08:44:14 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 5F6513858C31 for ; Thu, 19 Sep 2024 12:44:14 +0000 (GMT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTP id B9A2B3858D28 for ; Thu, 19 Sep 2024 12:43:49 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B9A2B3858D28 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 B9A2B3858D28 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=1726749832; cv=none; b=FxLE9aJTJYGlfOHFfPyv78G05lblPSWSJGmwRydajSvQBuHme30PSsbcVD/KcmFB2NkBaBWsyiJgKQ7pMLE04MotUkWZhlzbCIRQ0B1Q+Gf6SaHP50bsgwANwv4Kl3C+7AsxE/F7ph+rfk3LwEY4GvXZ+aSCKuxlbZ2GrRxudeo= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1726749832; c=relaxed/simple; bh=Fi1ld6894SIX4arHhP0kjinKMg0iqjnzfXuJRe/m3LM=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=GlX/C9WqdGe+MFXQoo0cLRgCZPC+Q38zv4F7Pcf43OINlGDTY+b4OZCEZhg7l/SPKoMcnE9uLf6+7/8erhr2x0nOW7m7FDYhHYmK0stuEGWwXhn2hdJHcxG881DAAcNVwODeC9HZ6blfZLSI9PU155sIswohtd2EFjpg1F5m9hY= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1726749829; 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=UnlvCIVKzXzWJSHl3/LvbCVM2SUTlfTNzzEhu2joJok=; b=YbQgEt1Fp7sAbCoK8m+FXISF+TIipwchm855u4tEST5uSmfh2m9q7M8csHAFBPnVOxP9o1 J1Uxh66cHRjukMw5fTcGHk+a/l1XpFWbhDVpuPWZAa2xOh+MvupLeETgHYNUspbS5G3rpu wIVf6zVfTPRyRvvj8jf0tZKDuY/Tumk= Received: from mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-627-rlOEVs8kMbShck2ggm5SlQ-1; Thu, 19 Sep 2024 08:43:48 -0400 X-MC-Unique: rlOEVs8kMbShck2ggm5SlQ-1 Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (unknown [10.30.177.15]) (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 mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 64D4919792D3 for ; Thu, 19 Sep 2024 12:43:47 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.96.134.13]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id BF5141955DEA; Thu, 19 Sep 2024 12:43:37 +0000 (UTC) From: Guinevere Larsen To: gdb-patches@sourceware.org Cc: Guinevere Larsen Subject: [PATCH] gdb/testsuite: rework bp-cond-failure to not depend on inlining Date: Thu, 19 Sep 2024 09:42:04 -0300 Message-ID: <20240919124204.1465834-1-blarsen@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true 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 The test gdb.base/bp-cond-failure is implicitly expecting that the function foo will be inlined twice and gdb will be able to find 2 locations to place a breakpoint. When clang is used, gdb only finds one location which causes the test to fail. Since the test is not worried about handling breakpoints on inlined functions, but rather on the format of the message on a breakpoint condition fail, this seems like a false fail report. This commit reworks the test to be in c++, and uses function overloading to ensure that 2 locations will always be found. Empirical testing showed that, for clang, we will land on location 2 with the currest exp commands, no matter the order of the functions declared, whereas for gcc it depends on the order that functions were declared, so they are ordered to always land on the second location, this way we are able to hardcode it and check for it. --- gdb/testsuite/gdb.base/bp-cond-failure.c | 14 +++++--- gdb/testsuite/gdb.base/bp-cond-failure.exp | 37 ++++++++++++---------- 2 files changed, 31 insertions(+), 20 deletions(-) diff --git a/gdb/testsuite/gdb.base/bp-cond-failure.c b/gdb/testsuite/gdb.base/bp-cond-failure.c index ffab09873bc..b7421399792 100644 --- a/gdb/testsuite/gdb.base/bp-cond-failure.c +++ b/gdb/testsuite/gdb.base/bp-cond-failure.c @@ -15,8 +15,14 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ -static inline int __attribute__((__always_inline__)) -foo () +static int +foo (int x) +{ + return 0; +} + +static int +foo (char c) { return 0; /* Multi-location breakpoint here. */ } @@ -24,7 +30,7 @@ foo () static int __attribute__((noinline)) bar () { - int res = foo (); /* Single-location breakpoint here. */ + int res = foo ('1'); /* Single-location breakpoint here. */ return res; } @@ -34,7 +40,7 @@ main () { int res = bar (); - res = foo (); + res = foo (1); return res; } diff --git a/gdb/testsuite/gdb.base/bp-cond-failure.exp b/gdb/testsuite/gdb.base/bp-cond-failure.exp index a82cedd3e36..403e7db9032 100644 --- a/gdb/testsuite/gdb.base/bp-cond-failure.exp +++ b/gdb/testsuite/gdb.base/bp-cond-failure.exp @@ -27,7 +27,7 @@ standard_testfile if { [prepare_for_testing "failed to prepare" ${binfile} "${srcfile}" \ - {debug}] == -1 } { + {debug c++}] == -1 } { return } @@ -44,7 +44,7 @@ if { [is_address_zero_readable] } { return } -proc run_test { cond_eval access_type lineno nloc } { +proc run_test { cond_eval access_type bpexpr nloc } { clean_restart ${::binfile} if { ![runto_main] } { @@ -56,23 +56,28 @@ proc run_test { cond_eval access_type lineno nloc } { } # Setup the conditional breakpoint and record its number. - gdb_breakpoint "${::srcfile}:${lineno} if (*(${access_type} *) 0) == 0" + gdb_breakpoint "${bpexpr} if (*(${access_type} *) 0) == 0" set bp_num [get_integer_valueof "\$bpnum" "*UNKNOWN*"] if { $nloc > 1 } { - set bp_num_pattern "${bp_num}.1" + gdb_test "continue" \ + [multi_line \ + "Continuing\\." \ + "Error in testing condition for breakpoint ${bp_num}.2:" \ + "Cannot access memory at address 0x0" \ + "" \ + "Breakpoint ${bp_num}.2, foo \\(c=49 ...\\) at \[^\r\n\]+:\[0-9\]+" \ + "${::decimal}\\s+\[^\r\n\]+ breakpoint here\\. \[^\r\n\]+"] } else { - set bp_num_pattern "${bp_num}" + gdb_test "continue" \ + [multi_line \ + "Continuing\\." \ + "Error in testing condition for breakpoint ${bp_num}:" \ + "Cannot access memory at address 0x0" \ + "" \ + "Breakpoint ${bp_num}, bar \\(\\) at \[^\r\n\]+:\[0-9\]+" \ + "${::decimal}\\s+\[^\r\n\]+ breakpoint here\\. \[^\r\n\]+"] } - - gdb_test "continue" \ - [multi_line \ - "Continuing\\." \ - "Error in testing condition for breakpoint ${bp_num_pattern}:" \ - "Cannot access memory at address 0x0" \ - "" \ - "Breakpoint ${bp_num_pattern}, \(foo\|bar\) \\(\\) at \[^\r\n\]+:${lineno}" \ - "${::decimal}\\s+\[^\r\n\]+ breakpoint here\\. \[^\r\n\]+"] } # If we're using a remote target then conditions could be evaulated @@ -101,7 +106,7 @@ gdb_test_multiple "show breakpoint condition-evaluation" "" { } # Where the breakpoint will be placed. -set bp_line_multi_loc [gdb_get_line_number "Multi-location breakpoint here"] +set bp_line_multi_loc "foo" set bp_line_single_loc [gdb_get_line_number "Single-location breakpoint here"] foreach_with_prefix access_type { "char" "short" "int" "long long" } { @@ -110,7 +115,7 @@ foreach_with_prefix access_type { "char" "short" "int" "long long" } { run_test $cond_eval $access_type $bp_line_multi_loc 2 } with_test_prefix "single-loc" { - run_test $cond_eval $access_type $bp_line_single_loc 1 + run_test $cond_eval $access_type "${srcfile}:${bp_line_single_loc}" 1 } } } -- 2.46.0