Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Siva Chandra <sivachandra@google.com>
To: Doug Evans <dje@google.com>
Cc: gdb-patches <gdb-patches@sourceware.org>
Subject: Re: [RFC] While processing a struct die, store the method's address in its fn_field
Date: Tue, 25 Nov 2014 23:37:00 -0000	[thread overview]
Message-ID: <CAGyQ6gzOr86ORPhUjvBZ1YpQdsFDnUqz8gSJsy399+OKVufqzA@mail.gmail.com> (raw)
In-Reply-To: <CADPb22QmGovY394MbkwqZ34SVGEHkk7Z+6V5OqOGvbsxv_WgVg@mail.gmail.com>

On Tue, Nov 25, 2014 at 2:09 PM, Doug Evans <dje@google.com> wrote:
> For functions/methods gdb already uses lowpc as the start address.

May be I am reading wrong somewhere, but if I am correct, GDB
currently gets to a low pc (the address of the method) of a method via
its symbol. So, I agree that GDB uses low pc anyway.

> [IOW it doesn't use the linkage name, though even recently
> I'd forgotten this and thought otherwise.
> Also, GDB doesn't take a demangled name, mangle it,
> and then try to look that up in the ELF symbol table.]

May be I messed up some terminology somewhere, symbol handling side of
GDB is new to me. But, looking at value_fn_field, it appears to me
that GDB gets a method's address via its linkage name (first looking
up its symbol/minsym). Also, value_fn_field uses lookup_symbol which
uses lookup_symbol_in_language which demangles the linkage name. Based
on this, I concluded that GDB cannot get the address of a method if
the linkage name is missing. This is my understanding now, which could
be wrong ofcourse!

>>  [Clang
>> actually does not put out the low pc value for the subprogram die
>> under a structure die, but it puts out a separate (not under a
>> structure die) subprogram die for the operator() method with the low
>> pc value.]
>
> DWARF can be hard to read at times.
> Note that GCC can do this too.  E.g.,
> It will output a declaration in the proper context
> (e.g., inside a class definition for a method) without DW_AT_low_pc
> and then it will output another DIE at the top level with DW_AT_low_pc
> and with a DW_AT_specification referring back to previous DIE in its context.

Yes, Clang takes this exact route and things work fine with a Clang
generated binary. GCC does not generate the top level DIE at all, but
stuffs in DW_AT_low_pc into the DIE under the class definition and
does not specify the linkage name. So, there is no DIE specifying the
linkage name of operator(). IMO however, what GCC is emitting is
logical sufficient. In which case, GDB needs to store the low pc value
somewhere, and my patch puts it in the type struct.

Thanks,
Siva Chandra


  reply	other threads:[~2014-11-25 23:37 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-24 15:55 Siva Chandra
2014-11-24 20:22 ` Doug Evans
2014-11-24 20:28   ` Doug Evans
2014-11-26  4:36     ` Doug Evans
2014-11-26  4:46       ` Siva Chandra
2014-11-26  5:05         ` Doug Evans
2014-11-25 15:00   ` Siva Chandra
2014-11-25 22:10     ` Doug Evans
2014-11-25 23:37       ` Siva Chandra [this message]
2014-11-26  3:22         ` Doug Evans
2014-11-26  3:58           ` Siva Chandra
2014-11-26  5:19             ` Doug Evans
2014-11-26  7:31           ` Siva Chandra
2014-11-26 21:11             ` Doug Evans

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=CAGyQ6gzOr86ORPhUjvBZ1YpQdsFDnUqz8gSJsy399+OKVufqzA@mail.gmail.com \
    --to=sivachandra@google.com \
    --cc=dje@google.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