Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: "Christian Biesinger via gdb-patches" <gdb-patches@sourceware.org>
To: Simon Marchi <simark@simark.ca>
Cc: gdb-patches <gdb-patches@sourceware.org>
Subject: Re: [PATCH] Make symbol_set_names a member function
Date: Mon, 06 Jan 2020 19:26:00 -0000	[thread overview]
Message-ID: <CAPTJ0XGUCm9+6ChFZBDjZRkHW0eJFOyGYz5u2SZV8_CF6q6gkQ@mail.gmail.com> (raw)
In-Reply-To: <CAPTJ0XHszOAvcduFCq=PpqwNPwA+3D5yA6MaL3aBBL36pnjt2Q@mail.gmail.com>

On Thu, Dec 26, 2019 at 10:43 PM Christian Biesinger
<cbiesinger@google.com> wrote:
>
> On Fri, Dec 27, 2019 at 4:02 AM Simon Marchi <simark@simark.ca> wrote:
> >
> > On 2019-12-26 8:09 p.m., Christian Biesinger wrote:
> > > On Thu, Dec 26, 2019 at 6:50 PM Simon Marchi <simark@simark.ca> wrote:
> > >>
> > >> 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.
>
> Hm.. maybe I'll look into this some more to understand this better. It
> certainly seems surprising that minsyms behave differently from other
> symbols in this respect?

OK, I looked into this a little bit more...

For partial symbols, the actual DWARF data contains this:
    <2e>   DW_AT_name        : foo
    <35>   DW_AT_linkage_name: (indirect string, offset: 0x5): _Z3fool

And gdb just use the DIE's DW_AT_name as the linkage name for the
partial symbol. I have not checked what happens for full symbols. But
I'm not sure that this difference between minsyms and psymbols is a
good thing :(

Christian


      reply	other threads:[~2020-01-06 19:26 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-26  7:52 cbiesinger
2019-12-26 17:50 ` Simon Marchi
2019-12-27  1:09   ` Christian Biesinger via gdb-patches
2019-12-27  3:02     ` Simon Marchi
2019-12-27  4:43       ` Christian Biesinger via gdb-patches
2020-01-06 19:26         ` Christian Biesinger via gdb-patches [this message]

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=CAPTJ0XGUCm9+6ChFZBDjZRkHW0eJFOyGYz5u2SZV8_CF6q6gkQ@mail.gmail.com \
    --to=gdb-patches@sourceware.org \
    --cc=cbiesinger@google.com \
    --cc=simark@simark.ca \
    /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