Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Guinevere Larsen <guinevere@redhat.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH v3 2/3] gdb: Make the parser recognize the [[N]] syntax for variables
Date: Mon, 7 Jul 2025 16:18:52 -0300	[thread overview]
Message-ID: <48f0d017-70b3-4697-b747-67d31a544f7b@redhat.com> (raw)
In-Reply-To: <865xgqlx2m.fsf@gnu.org>

On 6/20/25 3:57 AM, Eli Zaretskii wrote:
>> From: Guinevere Larsen <guinevere@redhat.com>
>> Cc: Guinevere Larsen <guinevere@redhat.com>
>> 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 "<symbol> 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 <eliz@gnu.org>
>
Thanks for the review (and sorry for the delay). I fixed this locally

-- 
Cheers,
Guinevere Larsen
She/Her/Hers


  reply	other threads:[~2025-07-07 19:19 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-19 18:05 [PATCH v3 0/3] Introduce syntax for linker-namespace specific symbols Guinevere Larsen
2025-06-19 18:05 ` [PATCH v3 1/3] gdb: make lookup_minimal_symbol_linkage work with linker namespaces Guinevere Larsen
2025-06-19 18:05 ` [PATCH v3 2/3] gdb: Make the parser recognize the [[N]] syntax for variables Guinevere Larsen
2025-06-20  6:57   ` Eli Zaretskii
2025-07-07 19:18     ` Guinevere Larsen [this message]
2025-06-19 18:05 ` [PATCH v3 3/3] gdb: extend the [[N]]::foo syntax for files Guinevere Larsen
2025-07-10  2:02   ` Kevin Buettner
2025-07-10 14:47     ` Guinevere Larsen
2025-07-10  2:27   ` Kevin Buettner
2025-07-10 15:07     ` Guinevere Larsen
2025-07-10 21:56       ` Kevin Buettner
2025-07-07 19:01 ` [PING][PATCH v3 0/3] Introduce syntax for linker-namespace specific symbols Guinevere Larsen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=48f0d017-70b3-4697-b747-67d31a544f7b@redhat.com \
    --to=guinevere@redhat.com \
    --cc=eliz@gnu.org \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox