From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id /8LQFnwGVWgqmxUAWB0awg (envelope-from ) for ; Fri, 20 Jun 2025 02:58:04 -0400 Authentication-Results: simark.ca; dkim=pass (2048-bit key; unprotected) header.d=gnu.org header.i=@gnu.org header.a=rsa-sha256 header.s=fencepost-gnu-org header.b=N1PZ5T++; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 4C3F41E11C; Fri, 20 Jun 2025 02:58:04 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-10.1 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_MED,RCVD_IN_VALIDITY_CERTIFIED, RCVD_IN_VALIDITY_RPBL,RCVD_IN_VALIDITY_SAFE autolearn=ham autolearn_force=no version=4.0.1 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 2798A1E0C2 for ; Fri, 20 Jun 2025 02:58:03 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 8A1263866204 for ; Fri, 20 Jun 2025 06:58:02 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8A1263866204 Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=gnu.org header.i=@gnu.org header.a=rsa-sha256 header.s=fencepost-gnu-org header.b=N1PZ5T++ Received: from eggs.gnu.org (eggs.gnu.org [IPv6:2001:470:142:3::10]) by sourceware.org (Postfix) with ESMTPS id D5404384CBAB for ; Fri, 20 Jun 2025 06:57:25 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D5404384CBAB Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gnu.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gnu.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org D5404384CBAB Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2001:470:142:3::10 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1750402645; cv=none; b=atJ5q1rna6o7/406D3AcbYgzjUcITV/lAVVlJkN4zPFTE5i7mhfYM3Yxzgr/aXfnEGRwO2qk0fftjAuH2SoTVtU8eKrZb5cZgPvhFD4KttylAqUCbo3kD8jxmrJIQwd77MnLuXGt62swhrzzzeRzAjgZzd+5ndglS3vNQCcLLEY= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1750402645; c=relaxed/simple; bh=+fnmwrqFZaMJNFjjoCJZTwez595UdNKSY7Lh09gyaV4=; h=DKIM-Signature:Date:Message-Id:From:To:Subject; b=wjvmtDZSNsIx2+y8K8bjwvc8gwec9PbK2kRc7ID5iyjtpNtURO6OObDtNMjtmx4AmK8/1e9ePNHpVefV2OdnWa8pn9Y2NG4eOrQ8ML6E4fVa7u0QfVbErriwU6s43KJiJHshoPnexcld1ELhw2dXZDilKUHyHTpVvSv2OdWxIqM= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D5404384CBAB Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uSVgj-0004yL-4L; Fri, 20 Jun 2025 02:57:25 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=cM7lb7J51etH24i5b/z2mDXreKxgJ2FgHue0S5EGcIA=; b=N1PZ5T++vViH WyhJJBNspm8XPlZG/sSQxl7yaIYyBs9zxo04PQf0uzP7/WS6wPN8qRSMha/ScSY2kEuZEsL8XFsj8 5E5pNhwudONkUnoBN+K7R6CMcjZ5OLNKSoynomROXyePntbgXO/DIQm0A1DNpVPKU3HN1znYqsgOo i9DW2hneTF2/dYvbfx+iP7PfOTQVt4pOJvbuG1KEQ1orlfdEzQkb9hiuD2U1lfzH180YhxtV1Na23 n9U4cJ3aVy3RLA2WMDN64nlLySJt7Hsxm3TQiyKS0zGRt6Q11bxdtAGYAHh/Fb+kNa84ptwnZg7bo BCf+NEn7h8eX+EFkiHKrOA==; Date: Fri, 20 Jun 2025 09:57:21 +0300 Message-Id: <865xgqlx2m.fsf@gnu.org> From: Eli Zaretskii To: Guinevere Larsen Cc: gdb-patches@sourceware.org In-Reply-To: <20250619180540.2315103-3-guinevere@redhat.com> (message from Guinevere Larsen on Thu, 19 Jun 2025 15:05:39 -0300) Subject: Re: [PATCH v3 2/3] gdb: Make the parser recognize the [[N]] syntax for variables References: <20250619180540.2315103-1-guinevere@redhat.com> <20250619180540.2315103-3-guinevere@redhat.com> 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 > From: Guinevere Larsen > Cc: Guinevere Larsen > Date: Thu, 19 Jun 2025 15:05:39 -0300 > > This commit adds a couple new rules to the YACC parser, that will allow > GDB to recognize expressions like [[N]]::var. > > This new syntax re-uses the existing rules for searching for "block"s, > because it allows, with minimal changes to the .y file as a whole, while > also allowing [[N]]::function::symbol work. Notably, [[N]]::'file.c'::var > does not work yet, as this code change is also involved and would pollute > the current commit, so will be done in a separate one in the same series. > > To restrict the search to a desired namespace, a new function is > introduced, lookup_symbol_in_linker_namespace. This function will only > perform the symbol lookup in the objfiles that belong to the requested > namespace. > > This commit also changes the error message when "print var" if "var" is > only present in namespaces other than the current one. Before this commit, > lookup_minimal_symbol would find them as "external" symbols with > incomplete information - outputting " has incomplete > information, cast it to it's defined type." - which could be confusing for > the users. This commit changes the parser rule "variable: name_not_typename" > so that, if multiple namespaces are active, we'll look for minimal symbols > only in the current namespace. > > Known limitations: > * When using [[N]]::foo::var, if that specific foo version is not on the > stack, the error will be unable to include the linker namespace > requested. So if a user sees "foo" in the stack this could be > confusing, but it should be mitigated when a future patch adds the > namespace ID to the backtrace where applicable. > * Completion is not supported. That's because the function used to > complete symbols expects only text in the form "file.c:symbol", so > can't handle the double colon. This isn't unique to linker > namespaces, though, since func::var will also not complete, it is just > a quirk of how :: completion work at this point. > * The expression that parses [[N]] only takes an integer. That's > because there aren't many expressions that would make sense in there, > and the work of accepting an arbitrary expression felt too much for > little gain. > --- > gdb/NEWS | 6 + > gdb/c-exp.y | 72 ++++++++--- > gdb/doc/gdb.texinfo | 6 + > gdb/minsyms.c | 124 ++++++++++++------- > gdb/minsyms.h | 8 ++ > gdb/parser-defs.h | 7 ++ > gdb/symtab.c | 37 ++++++ > gdb/symtab.h | 8 ++ > gdb/testsuite/gdb.base/dlmopen-ns-ids-lib.c | 14 +++ > gdb/testsuite/gdb.base/dlmopen-ns-ids-main.c | 3 + > gdb/testsuite/gdb.base/dlmopen-ns-ids.exp | 47 +++++++ > 11 files changed, 268 insertions(+), 64 deletions(-) Thanks. > --- a/gdb/NEWS > +++ b/gdb/NEWS > @@ -102,6 +102,12 @@ info threads [-gid] [-stopped] [-running] [ID]... > These new flags can be useful to get a reduced list when there is a > large number of threads. > > +print > + The print command now accepts the following syntax to print values > + from a specific linker namespace: `[[N]]::foo'. N is the namespace > + identifier as understood by GDB. This part is okay. > --- a/gdb/doc/gdb.texinfo > +++ b/gdb/doc/gdb.texinfo > @@ -10565,6 +10565,12 @@ you can choose a different format by specifying @samp{/@var{f}}, where > @var{f} is a letter specifying the format; see @ref{Output Formats,,Output > Formats}. > > +Additionally, if the inferior supports linker namespaces, @value{GDBN} > +has implemented the following syntax to allow users to resolve symbols > +to a specific namespace: @code{[[@var{n}]]::@var{symbol}}. Here @var{n} > +is @value{GDBN}'s namespace identifier, which may be different to the > +inferior's identifier. This part is also okay, but please say "different from" in the last sentence. Reviewed-By: Eli Zaretskii