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 7A9373858CDA for ; Tue, 6 Sep 2022 14:41:53 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 7A9373858CDA Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-122-rMSRvaR0PsSacV18CUNAjw-1; Tue, 06 Sep 2022 10:41:51 -0400 X-MC-Unique: rMSRvaR0PsSacV18CUNAjw-1 Received: by mail-wr1-f70.google.com with SMTP id h2-20020adfa4c2000000b00228db7822cbso654167wrb.19 for ; Tue, 06 Sep 2022 07:41:51 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date; bh=wX0b1UOfxWttb6Of7/78/EQeXVT5DKUiXuvnL3Lere0=; b=qqAB/HgvGDOGc5OvvT53miVazjqWLgP2qK/1ncP8OJuDw8E1kkvHExqEhzTq7+lNU6 P850sCUzAhdm/h0plAD22P8dVy1pa1pBbD6tJGiVTVWiTyt4ukv8f2p1wqB3pazpBc2t skHCkhVyRogMzinnlkM3MT925VpZsmaECLf9aV/T4KLdLyZC1F5yHKafB/EFfUxn/94w 5Usso8u2wSL9SGmbEsR0A3Bv1tcCsMzm0QuB/2t4g8bRHcKTASrOcsib/OjC0dQ/OC6k gXozAeXqhbBVTurWFHDwCB+LSTFcxiihhFEdhsRJGzf6mxD9RUnWAS3QgJOujz85/30f xuEA== X-Gm-Message-State: ACgBeo0ayCjjUOBYJa2bsmmRMfeGwolxV1LwqoG2GP5EpBtS5gwZuzqz +DKn+dEd37/B1OOTimuIWgOl0JnWpnUjxlA2WvmST3lukeSOSvUaODM5+iVfDPWwgl5NJsgbAAX E9IAJxuO1RgUtkIq/AIoFBw== X-Received: by 2002:a5d:62cb:0:b0:228:6a13:24d9 with SMTP id o11-20020a5d62cb000000b002286a1324d9mr7161261wrv.497.1662475310190; Tue, 06 Sep 2022 07:41:50 -0700 (PDT) X-Google-Smtp-Source: AA6agR5rmGiMuZuFH5ZIOXPItk9PgvrmqwK1tBIIEYLIYltuzxret0StGTGRl5DEXUwNN1q6D+5/rQ== X-Received: by 2002:a5d:62cb:0:b0:228:6a13:24d9 with SMTP id o11-20020a5d62cb000000b002286a1324d9mr7161253wrv.497.1662475310012; Tue, 06 Sep 2022 07:41:50 -0700 (PDT) Received: from [10.43.2.105] (nat-pool-brq-t.redhat.com. [213.175.37.10]) by smtp.gmail.com with ESMTPSA id k1-20020adff281000000b00223b8168b15sm13043646wro.66.2022.09.06.07.41.49 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 06 Sep 2022 07:41:49 -0700 (PDT) Message-ID: Date: Tue, 6 Sep 2022 16:41:49 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.2.0 Subject: Re: [PATCH 1/1] gdb: Enable complete to show members of anonymous classes/structs. To: Felix Willgerodt , gdb-patches@sourceware.org References: <20220906072153.508130-1-felix.willgerodt@intel.com> From: Bruno Larsen In-Reply-To: <20220906072153.508130-1-felix.willgerodt@intel.com> 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-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, NICE_REPLY_A, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 06 Sep 2022 14:41:55 -0000 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