From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 72031 invoked by alias); 27 Dec 2019 03:02:13 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 72023 invoked by uid 89); 27 Dec 2019 03:02:12 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-5.5 required=5.0 tests=AWL,BAYES_00,SPF_HELO_PASS,SPF_PASS autolearn=ham version=3.3.1 spammy= X-HELO: simark.ca Received: from simark.ca (HELO simark.ca) (158.69.221.121) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 27 Dec 2019 03:02:11 +0000 Received: from [10.0.0.11] (unknown [192.222.164.54]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id 0C9231E10B; Thu, 26 Dec 2019 22:02:09 -0500 (EST) Subject: Re: [PATCH] Make symbol_set_names a member function To: Christian Biesinger Cc: gdb-patches References: <20191226075201.239053-1-cbiesinger@chromium.org> From: Simon Marchi Message-ID: <34ef9777-7067-8669-a9a5-40c8cfe8e8d6@simark.ca> Date: Fri, 27 Dec 2019 03:02:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.3.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-SW-Source: 2019-12/txt/msg01031.txt.bz2 On 2019-12-26 8:09 p.m., Christian Biesinger wrote: > On Thu, Dec 26, 2019 at 6:50 PM Simon Marchi wrote: >> >> On 2019-12-26 2:52 a.m., cbiesinger@chromium.org wrote: >>> From: Christian Biesinger >>> >>> This also renames it to make it clearer that this is not a cheap >>> functin (to compute_and_set_names). Also renames name to m_name >> >> "functin" > > Thanks, fixed locally. > >>> to make the implementation of the renamed function more readable. >>> >>> Most of the places that access sym->m_name directly were also changed >>> to call linkage_name () instead, to make it clearer which name they >>> are accessing. >> >> I think that all makes sense. >> >>> @@ -2110,7 +2109,8 @@ maintenance_check_psymtabs (const char *ignore, int from_tty) >>> if (!sym) >>> { >>> printf_filtered ("Static symbol `"); >>> - puts_filtered ((*psym)->ginfo.name); >>> + /* TODO: Should this be print_name ()? */ >>> + puts_filtered ((*psym)->ginfo.linkage_name ()); >>> printf_filtered ("' only found in "); >>> puts_filtered (ps->filename); >>> printf_filtered (" psymtab\n"); >>> @@ -2128,7 +2128,8 @@ maintenance_check_psymtabs (const char *ignore, int from_tty) >>> if (!sym) >>> { >>> printf_filtered ("Global symbol `"); >>> - puts_filtered ((*psym)->ginfo.name); >>> + /* TODO: Should this be print_name ()? */ >>> + puts_filtered ((*psym)->ginfo.linkage_name ()); >>> printf_filtered ("' only found in "); >>> puts_filtered (ps->filename); >>> printf_filtered (" psymtab\n"); >> >> For this patch, I wouldn't change the behavior (which means using linkage_name), but we could >> consider a separate patch to change it. > > I removed the TODO locally. OK to push with withose two changes? Yes. >> I hacked the code to always enter these ifs and print both the linkage_name >> and the natural_name. With a C++ test program containing this function: >> >> int hello(int); >> >> I get: >> >> linkage_name: hello >> natural_name: hello >> >> I would have expected linkage_name to be _Z5helloi and the natural_name to be >> hello(int). Do you know if it's expected for the partial symbol to contain >> just "hello" for both? > > Huh.. > > I added a printf in compute_and_set_names and found that there's a > symbol with the mangled name *and* a symbol with the plain name. I > guess that's why? But I don't know what that means... Ok, I see what happens. The first call to compute_and_set_names is while parsing minimal symbols, by minimal_symbol_reader::install. This one has a mangled linkage name (_Z5helloi). The second call is while creating partial symbols, by add_psymbol_to_bcache. This is the one with the linkage name "hello". I suppose that's expected, I had never really paid attention to this. There's also a third call, while creating the full blown symbol, with a linkage name of "hello(int)". So the term "linkage_name" in general_symbol_info is perhaps a bit misleading, it makes sense for minimal symbols, but not really for partial and full symbols. Simon