From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id 6ii0K1uW7WbTeDEAWB0awg (envelope-from ) for ; Fri, 20 Sep 2024 11:35:55 -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=PgvxTlRb; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 9D47D1E353; Fri, 20 Sep 2024 11:35:55 -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 A16591E05C for ; Fri, 20 Sep 2024 11:35:54 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id CAC053858D39 for ; Fri, 20 Sep 2024 15:35:53 +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 631623858D29 for ; Fri, 20 Sep 2024 15:35:26 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 631623858D29 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 631623858D29 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=1726846528; cv=none; b=Uwgzc7lZ3khsTzw6nxkezXhff0VBXZtTgSSLd5FFRIUDmwsMLfETp9CghPcsbRxmpsTRwrw1hfJpp7aJuZzKarncIHre3EERJzSB8VitDCeY0l/CaxfNBPneeCJgxjtGyu4jHqbup+wV7UJjXU7yrvb9SnRanqNgH0wuLdykBNE= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1726846528; c=relaxed/simple; bh=nB48BpI9FBNwfJ7q4OqpsxSb4qmeORtr0hM2PbmIzZY=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=KdxCZ5LCGQk2cXQvlEG1NBOPAU0pX8i+/Cw0KpNNJ8bdV9cGCTNtRCuabIqVmYGn8nm59wGEezu1L3z3msGjbhVy9QiTXOOvyK+2G8kZGCVpw6OTLPjCNbvc6tXKqiQn02tfqx5o2vcyI0moDYGIcZj+fXdUDeXIvB58AFK5SSE= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1726846526; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=bcfbjYOkhK2dSXtXW3VDrqF5+/za2QPQWBzrpeGyHoE=; b=PgvxTlRbjG/lMxstGkmmM8SNWl4cch5pwXpmHVgfr2WwRe6FtgbrM1ejDcSYF8LiEGDZ4i hwqHbYQ9bvue4d3nKKeUg8M77z5rf6Ppsk3X11Z4sV1q8PvShw25Xf4ZUHsfP91NBm6Az1 I8SrHlcHCookDk/EU/zpZCfZb8z804w= Received: from mail-oa1-f72.google.com (mail-oa1-f72.google.com [209.85.160.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-591-2w3w4LpIMnKTFjqcuTTw5w-1; Fri, 20 Sep 2024 11:35:24 -0400 X-MC-Unique: 2w3w4LpIMnKTFjqcuTTw5w-1 Received: by mail-oa1-f72.google.com with SMTP id 586e51a60fabf-278222c9c13so1529031fac.2 for ; Fri, 20 Sep 2024 08:35:24 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726846524; x=1727451324; h=content-transfer-encoding:in-reply-to:from:content-language :references:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=bcfbjYOkhK2dSXtXW3VDrqF5+/za2QPQWBzrpeGyHoE=; b=U62adgokqeZK36jo/AC941Npx2y38w++JQCZl9/HDv63GTzQ1THKR3SaJb4Uzcltja 6xfyZbL/+eMag2ax2GEIBlMcB3PvLDpbYh5QuDQ1NtLfAz9SdnPPwTGAoN76M83XPDMW VaGEZouEg57pCNKB9s2+Eos5RpuF8vl/qtb/Tnpq4kw6XhC2HWo8nVp4JQ6nRhx6dKf5 q2fIQoaRmLq3YLRK9ezVuJT43ii4h/kWd9nzO2JGf3fzIRbpJ2oQIfnkg0IfjtqaCNSb mXS8DFFpcsTdmf46/KcsKk/5RQAp/fe8lFyzO4P/lokPFoh46XcI/RW+lEH5hRBsbRpt 1RfQ== X-Forwarded-Encrypted: i=1; AJvYcCWMyF74Sozfk9I3g61zHZn239mDZXpND5odwFbWmrUiQhkA6YngMVnOhP1//O4ht4o8XIISAajVBxyFMg==@sourceware.org X-Gm-Message-State: AOJu0YyTymgEHSJk3EvnXLFuFPjh2ZgPU8JioOCy85Oec3Cy9SqdQ882 o1AwWc3Cet0CSEx31Wzz/NCO6UUXh4X3FhQGciC5+9rdByiz+v5qKwcfA7074Oyz7PgZZTFjW4l nVgkjkrJE8yDRgNsYsNrGFy/UksZjbNJX9r6FqZqjhzej4mDuRzWhbIio0bg= X-Received: by 2002:a05:6870:b6a6:b0:270:130f:cee0 with SMTP id 586e51a60fabf-2803a8e10a9mr2150321fac.39.1726846524046; Fri, 20 Sep 2024 08:35:24 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGsVzbTp+uXkYIpryUvXmbYA2CqSwwpFN7bR8CHWJvHcYSdPR4ckgNtLgBzmCTwhjHP4aB07Q== X-Received: by 2002:a05:6870:b6a6:b0:270:130f:cee0 with SMTP id 586e51a60fabf-2803a8e10a9mr2150290fac.39.1726846523637; Fri, 20 Sep 2024 08:35:23 -0700 (PDT) Received: from [150.1.200.127] (174-21-139-113.tukw.qwest.net. [174.21.139.113]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-7db4998ff14sm10966362a12.66.2024.09.20.08.35.23 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 20 Sep 2024 08:35:23 -0700 (PDT) Message-ID: Date: Fri, 20 Sep 2024 08:35:22 -0700 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] gdb/testsuite: rework bp-cond-failure to not depend on inlining To: Guinevere Larsen , gdb-patches@sourceware.org References: <20240919124204.1465834-1-blarsen@redhat.com> From: Keith Seitz In-Reply-To: <20240919124204.1465834-1-blarsen@redhat.com> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit 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 Hi, Gwen, On 9/19/24 5:42 AM, Guinevere Larsen wrote: > 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. Ah, more inline function fun! Great idea moving to overloaded functions. > 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 Typo "currest". > 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. This LGTM with one other minor request (see below). Reviewed-by: Keith Seitz Keith > --- > 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\]+"] In your commit log, you mention why it is appropriate to hard-code location numbers. Would you mind adding some sort of explanation like that here? For the casual visitor to this file that has often been burned by hard-coded line numbers or locations, it would, at least, save me some grief. > } 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 > } > } > }