public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Bruno Larsen <blarsen@redhat.com>
To: Felix Willgerodt <felix.willgerodt@intel.com>,
	gdb-patches@sourceware.org
Subject: Re: [PATCH 1/1] gdb: Enable complete to show members of anonymous classes/structs.
Date: Tue, 6 Sep 2022 16:41:49 +0200	[thread overview]
Message-ID: <a23eb527-8d41-61c3-a3b0-ae3866ee8239@redhat.com> (raw)
In-Reply-To: <20220906072153.508130-1-felix.willgerodt@intel.com>

On 06/09/2022 09:21, Felix Willgerodt via Gdb-patches wrote:
> This problem shows with anonymous structs/classes:
>
> ~~~
>    struct {
>      private:
>        int unique_name_foo = 5;
>      public:
>        int get() { return unique_name_foo; } /* breakpoint.  */
>    } a;
> ~~~
>
> Before:
>
> ~~~
> (gdb) p unique_name_foo
> $1 = 5
> (gdb) complete p unique_name_fo
> (gdb)
>
> ~~~
>
> After:
>
> ~~~
> (gdb) p unique_name_foo
> $1 = 5
> (gdb) complete p unique_name_fo
> p unique_name_foo
> (gdb)
> ~~~
>
> As we are able to print the member we should be able to complete on it.
> GDB doesn't look at "this" and its members for complete, while it does
> when printing.  So I tried fixing that.
> I saw that "this" is always represented as a PTR type with the symbol
> class LOC_COMPUTED (with g++ 11.3.1, clang++ 10.0.1 and icpx 2022.1).
>
> Not knowing too much about LOC_COMPUTED, I am assuming that this is the right
> symbol class for this case and that we should adjust
> completion_list_add_fields() for it.
> But it could very well be that I missed something.  Any comments welcome!

Hi Felix,

Thanks for working on this, this is a good improvement, I'm just not 
sure if this is the best solution, from reading around the adress_class 
enum.

LOC_COMPUTED seems to have  to do with how GDB finds the address of the 
variable: a constant location expression. From what I understand, any 
global variable may end up with this aclass. If this understanding is 
correct, identifying anonymous structs from this information seems 
sketchy, and they should instead also have an address class of 
LOC_TYPEDEF because classes and structs are defining a struct... but I'm 
not sure, if someone who understands this system could pitch in, would 
be nice.

Even if my understanding is correct, the completion function still needs 
updating, as it doesn't handle TYPE_CODE_PTR. If I'm misunderstanding, 
the patch looks alright and fixes the problem, so I give it a +1, but I 
can't approve patches.

-- 
Cheers,
Bruno


  reply	other threads:[~2022-09-06 14:41 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-06  7:21 Felix Willgerodt
2022-09-06 14:41 ` Bruno Larsen [this message]
2022-09-20  9:48 ` [Ping] " Willgerodt, Felix
2022-10-17  8:33 ` [Ping v2] " Willgerodt, Felix
2022-10-26 12:06 ` [Ping v3] " Willgerodt, Felix
2022-11-08 11:00 ` [Ping v4] " Willgerodt, Felix
2022-11-18 20:33 ` Tom Tromey
2022-11-24 12:58   ` Willgerodt, Felix

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=a23eb527-8d41-61c3-a3b0-ae3866ee8239@redhat.com \
    --to=blarsen@redhat.com \
    --cc=felix.willgerodt@intel.com \
    --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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).