From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id Jd40LUOb7WbvfTEAWB0awg (envelope-from ) for ; Fri, 20 Sep 2024 11:56:51 -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=f3E8ihMy; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id A30151E353; Fri, 20 Sep 2024 11:56:51 -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 00BEF1E05C for ; Fri, 20 Sep 2024 11:56:50 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 9FADD3858420 for ; Fri, 20 Sep 2024 15:56:50 +0000 (GMT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTP id 017AE3858D29 for ; Fri, 20 Sep 2024 15:56:26 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 017AE3858D29 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 017AE3858D29 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1726847790; cv=none; b=BY/pZ9rKJa4ZWxt8xK2uGV1yhg0UEQ/QtGMdDmuc/argTJuombNndwpeZr981SGwCjzulxS9rGx+jkVwKDIStQnRdIJGIaFKuULVaVyvt9m3k7rzsa0uC3gyQeXh8Hcy6OFI836iXYg+DZoJjVAEeC7R7MB5hZaeB6an4Oyt7Jk= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1726847790; c=relaxed/simple; bh=cyCJEEXyiGps6CGdiYmfKYPuilGTqO/xziddl4F/Y2w=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=mLt953uUCkRGA4Hwr+lLBd+CoCqs5+RIH2m1jCKirCzdJIw+xSgIg455jvyJ5EEy7KWIFmpYz0wzYmgSIMme8SqG7m5eOpcOUHgrGz+D1NvPfhhkr0kVhblRD4yq5UGL1SMrmm3MAewGJG8INcXET5lzUWoFgYDLPMtiUw3tCrk= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1726847786; 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=H67jGfDzJ2RH/j9zNFbLw0R9FKGMfzBEWiNW/i/yE0o=; b=f3E8ihMysZFZS1MT+Bo8ZpZ1fPJUEvHD6XgmnrjLmsUk8PMhvepdgZvuX8t2rnjTdP0Q37 uEmt7Uf+NrZ0pPuFusNAEDPDNzYjWo8unw0jEZsdCmPg98n+0t2T7A8jCyKY5x9qwNbBVh GCAVmmtV8cKnwSE2RhV2TI1Sz8OWuhA= Received: from mail-pf1-f197.google.com (mail-pf1-f197.google.com [209.85.210.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-90-WqW9IzwmOLS7w25l7slZOQ-1; Fri, 20 Sep 2024 11:56:25 -0400 X-MC-Unique: WqW9IzwmOLS7w25l7slZOQ-1 Received: by mail-pf1-f197.google.com with SMTP id d2e1a72fcca58-7190c5e73cdso2554142b3a.0 for ; Fri, 20 Sep 2024 08:56:25 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726847784; x=1727452584; 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=H67jGfDzJ2RH/j9zNFbLw0R9FKGMfzBEWiNW/i/yE0o=; b=u1flhF0WnCcRL+Mwua3UW9bp3s2kl4+LchmoOh5OluUnv45Hw+sF8rqHwgnqrrUT75 qvwq/+XPbIYURZ2z269/vbbUElPQeQe4yOIbBPRiH7Vf5J8gGcQ0BUsasyUqWxdkKo5p 4YQpZFGFx5aMi3SxdzTkMunmpKMSEn7zj+5RkbQIz8NUFPxB7SXwo30LlH5c4Y9zF3cQ f5X2fQId5knteIUuLyXKuYZ+M1aywTlqHKfbIl535DZtg9cIkR3/Cx4ETbTwmugPLIQa rmJVGhr2F4bS7no4oW42qj12+Sw/sC/oFB0kL6miIGCJ2c9BHXVxL6msqHVmaj9w3M4c +2QA== X-Forwarded-Encrypted: i=1; AJvYcCX5IWE3cHShAtWS/JozKIzGqmuirY7AewnNHqlmCTpiVEPlvjjjhNOMzezz6uuy2sW2SlpT1NC1j+l3vw==@sourceware.org X-Gm-Message-State: AOJu0YxoI/rwztoNSf3aKT2OoizJ245EmMd6UR+Q5EOelkSPaFdlIequ M/v9vu783uR5da5aqNX3JB+DbqRWApzeEJDnKe3nimRiAkRdbhEpYheY+Nfzr9SOTIKDKdMnDMV aUAZNdfr1yxgjuDHHDbJATp7eRb5g/vrax8IvcVmm59EssWCdPYATKTTQzec= X-Received: by 2002:a05:6a20:c702:b0:1cf:e5e5:263d with SMTP id adf61e73a8af0-1d30aa0e4f2mr5568374637.35.1726847784219; Fri, 20 Sep 2024 08:56:24 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEIeE5AAuT+HCPHUiXQB2kNPOWXBR2MH3y7rBZ21+yTzr9OfnG+bBZDZQL8kgC8pqU3VWk0ug== X-Received: by 2002:a05:6a20:c702:b0:1cf:e5e5:263d with SMTP id adf61e73a8af0-1d30aa0e4f2mr5568335637.35.1726847783777; Fri, 20 Sep 2024 08:56:23 -0700 (PDT) Received: from ?IPV6:2804:14d:8084:92c5::1000? ([2804:14d:8084:92c5::1000]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-71944ab55desm10033899b3a.62.2024.09.20.08.56.21 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 20 Sep 2024 08:56:23 -0700 (PDT) Message-ID: <1940030f-122d-4656-a293-44e5b5a98c92@redhat.com> Date: Fri, 20 Sep 2024 12:56:19 -0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] gdb/testsuite: rework bp-cond-failure to not depend on inlining To: Keith Seitz , Guinevere Larsen , gdb-patches@sourceware.org References: <20240919124204.1465834-1-blarsen@redhat.com> From: Guinevere Larsen In-Reply-To: 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: 8bit 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 On 9/20/24 12:35 PM, Keith Seitz wrote: > 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. At the top of the exp file, the comment that explains the purpose of the test ends with the following: # We check that the correct breakpoint number appears in the error # message, and that the error is reported at the correct source # location. Would you still like me to add the comment in context, or do you think that is enough? > >>       } 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 >>       } >>       } >>   } > -- Cheers, Guinevere Larsen She/Her/Hers