From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 5CBC63858D37 for ; Sun, 12 Feb 2023 06:22:50 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 5CBC63858D37 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1676182970; 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: in-reply-to:in-reply-to:references:references; bh=yLT+zLbKw9NwMZQ8tCI61fzOZeICmUBVK4HOA1XkuqA=; b=NSrA4HfcNTcDNrQS4Gb28SKDtQjqjDKBGLfUld9RNbv2sRGCARvO3kJOcvTo5ksHIyoZff qVSpNPrnStN9D6MTQR/HgLpfNEec0meqfcKGuAP1PbrebgOuoMioh/4utaFh2pJ6ntE54v gsFovsDHY7Nd5EKlevMoPCXKi5PAZuA= Received: from mail-qk1-f197.google.com (mail-qk1-f197.google.com [209.85.222.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-338-e-Y9CUoaMgWq7eTWt2TNSQ-1; Sun, 12 Feb 2023 01:22:48 -0500 X-MC-Unique: e-Y9CUoaMgWq7eTWt2TNSQ-1 Received: by mail-qk1-f197.google.com with SMTP id 130-20020a370588000000b0072fcbe20069so5797486qkf.22 for ; Sat, 11 Feb 2023 22:22:48 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=mime-version:message-id:date:references:in-reply-to:subject:cc:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=yLT+zLbKw9NwMZQ8tCI61fzOZeICmUBVK4HOA1XkuqA=; b=5gT1YNQpIejVQjAIcmNtAb35bcsdKnRMXzYhDTP2I5dyr9TGJzbZoN4+GvsXfR6OIm VLp5sEJucm+fPep7PQWcd+jQlrVkGsp/vQzG+Db6+pzk7dyNBsXwVrUhX5Us+F3dgPCt tua1wA5T5+vQWWluOyT30QVYzb+y/nJeeynrj4qkx5mkkjxYD9+LfQCahkKfySDa8YEX xGeYKxZTlCjDicDMH3SFudKXaub6/Wyk1vELlA6+QFtKHQ+o9KNPVVl6QTxdW0p6d4/0 Jzx0wSRSi4TZmlZjDbAdWSN04zIpXPRI30hcLu/4Vg8K2EFyyNBzzEFmMoy6lploTnqx fMrA== X-Gm-Message-State: AO0yUKUiGy3YFLM2POMko29It4lH6fna+EwWSztJtfszQ2cIe7D+SHpi MkqnSG0OA7uUzJS5BV4spZTHwv4nsYSe/WAJhpqlsxUAReN+TYmh6dgBXl3zNga8l/P/+AQ3EvC l7cprwzemK5uBcK3F4IgzDAWN0Ik= X-Received: by 2002:a05:622a:287:b0:3b8:68f4:31f0 with SMTP id z7-20020a05622a028700b003b868f431f0mr34318456qtw.41.1676182967912; Sat, 11 Feb 2023 22:22:47 -0800 (PST) X-Google-Smtp-Source: AK7set8KlJ5H6+N/Bc5pPLlh1IVUZJATaFUv9x0PJK8Ur+nTbVxSzxQDyosgZ3yPgzRM7xi//Gg5Rg== X-Received: by 2002:a05:622a:287:b0:3b8:68f4:31f0 with SMTP id z7-20020a05622a028700b003b868f431f0mr34318446qtw.41.1676182967670; Sat, 11 Feb 2023 22:22:47 -0800 (PST) Received: from localhost (95.72.115.87.dyn.plus.net. [87.115.72.95]) by smtp.gmail.com with ESMTPSA id l26-20020ac8459a000000b0039cc0fbdb61sm6810188qtn.53.2023.02.11.22.22.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 11 Feb 2023 22:22:47 -0800 (PST) From: Andrew Burgess To: Simon Marchi , gdb-patches@sourceware.org Cc: Bruno Larsen Subject: Re: [PATCHv3] gdb/c++: fix handling of breakpoints on @plt symbols In-Reply-To: References: <29e560fd9c94874f0839924fa25557a7e8418ad3.1674215225.git.aburgess@redhat.com> <1e9534288b91692c94af288b12659b107ac590c8.1676055649.git.aburgess@redhat.com> Date: Sun, 12 Feb 2023 06:22:45 +0000 Message-ID: <875yc7v1vu.fsf@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain X-Spam-Status: No, score=-11.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,KAM_SHORT,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,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 List-Id: Simon Marchi writes: >> diff --git a/gdb/testsuite/gdb.cp/breakpoint-shlib-func-lib.cc b/gdb/testsuite/gdb.cp/breakpoint-shlib-func-lib.cc >> new file mode 100644 >> index 00000000000..7219f7c5a23 >> --- /dev/null >> +++ b/gdb/testsuite/gdb.cp/breakpoint-shlib-func-lib.cc >> @@ -0,0 +1,21 @@ >> +/* Copyright 2022-2023 Free Software Foundation, Inc. >> + This program is free software; you can redistribute it and/or modify >> + it under the terms of the GNU General Public License as published by >> + the Free Software Foundation; either version 3 of the License, or >> + (at your option) any later version. >> + >> + This program is distributed in the hope that it will be useful, >> + but WITHOUT ANY WARRANTY; without even the implied warranty of >> + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >> + GNU General Public License for more details. >> + >> + You should have received a copy of the GNU General Public License >> + along with this program. If not, see . */ >> + >> +extern int foo (); > > I don't think this extern declaration is needed. > >> +# The breakpoint should now be showing in `foo` for real. >> +gdb_test "info breakpoints" \ >> + "\r\n$decimal\\s+\[^\r\n\]+ in foo\\(\\) at \[^\r\n\]+\r\n.*" \ >> + "check breakpoints after starting the inferior" >> + >> +# Now we can delete the breakpoints. >> +delete_breakpoints >> + >> +# And recreate the foo breakpoint, we should only get one location, >> +# the actual location. >> +gdb_test "break foo" "Breakpoint $decimal at \[^\r\n\]+" \ >> + "recreate foo breakpoint" >> + >> +# Check the breakpoint was recreated correctly. >> +gdb_test "info breakpoints" \ >> + "\r\n$decimal\\s+\[^\r\n\]+ in foo\\(\\) at \[^\r\n\]+" \ >> + "check breakpoints after recreation" > > For completeness, you could maybe resume and confirm you are stopped at > foo (and not foo@plt). > > Otherwise, it all LGTM: I removed the 'extern' and added an extra check that we hit the expected breakpoint, then pushed this patch. Thanks, Andrew > > Approved-By: Simon Marchi > >> diff --git a/gdb/utils.c b/gdb/utils.c >> index 95adbe58e4a..76c0df36a80 100644 >> --- a/gdb/utils.c >> +++ b/gdb/utils.c >> @@ -2402,7 +2402,31 @@ strncmp_iw_with_mode (const char *string1, const char *string2, >> return 0; >> } >> else >> - return (*string1 != '\0' && *string1 != '('); >> + { >> + if (*string1 == '(') >> + { >> + int p_count = 0; >> + >> + do >> + { >> + if (*string1 == '(') >> + ++p_count; >> + else if (*string1 == ')') >> + --p_count; >> + ++string1; >> + } >> + while (*string1 != '\0' && p_count > 0); >> + >> + /* There maybe things like 'const' after the parameters, >> + which we do want to ignore. However, if there's an '@' >> + then this likely indicates something like '@plt' which we >> + should not ignore. */ >> + return *string1 == '@'; >> + } >> + >> + return *string1 == '\0' ? 0 : 1; >> + } > > Not really relevant for your patch but... just chatting. I don't know > if it would be really inefficient, but reading this function, I dream of > some util function that would parse a demangled C++ function symbol into > some structured type (listing the namespaces, name, abi tags, > parameters, whether it is const or not, etc). It would then be much > easier to work on that, rather than doing everything string-based. > > Simon