public inbox for elfutils@sourceware.org
 help / color / mirror / Atom feed
From: Mark Wielaard <mark@klomp.org>
To: elfutils-devel@sourceware.org
Cc: Dodji Seketeli <dodji@seketeli.org>
Subject: Re: [PATCH] libdw: Add dwarf_die_addr_die function.
Date: Tue, 13 Feb 2018 16:15:00 -0000	[thread overview]
Message-ID: <1518538527.3058.20.camel@klomp.org> (raw)
In-Reply-To: <1516892815-28359-1-git-send-email-mark@klomp.org>

On Thu, 2018-01-25 at 16:06 +0100, Mark Wielaard wrote:
> Currently storing a lot of Dwarf_Dies might be inefficient since it
> costs a lot of memory since the sizeof (Dwarf_Die) == 32 bytes on 64bit
> arches. You can try storing just the Dwarf_Off from dwarf_dieoffset.
> Which is just 8 bytes. But then you have to keep track of whether to
> call dwarf_dieoffset, if the Dwarf_Die came from the main .debug_info,
> or call dwarf_dieoffset_types, if it came from .debug_types. And you'll
> have to keep track of whether it came from the main Dwarf or the alt
> Dwarf (dwz multi file). With DWARF5 or GNU DebugFission split-dwarf
> you will also need to know which split Dwarf file the original DIE
> came from.
> 
> A Dwarf_Die consists of an addr pointer where the actual DIE data
> comes from, a CU pointer that provides context (and has a pointer
> to the Dwarf file the Die is associated with) and a (cached)
> Dwarf_Abbrev pointer that is initialized when the Dwarf_Die is
> first read and describes how to interpret the DIE data.
> 
> libdw already keeps track of the data pointers (sections) of a
> Dwarf file and given an offset it can already reconstruct the
> other Dwarf_Die fields. So this patch introduces dwarf_die_addr_die.
> Given a Dwarf_Die addr dwarf_die_addr_die returns a (reconstructed)
> Dwarf_Die, or NULL if the given addr didn't come from a valid
> Dwarf_Die. In particular it will make sure that the correct Dwarf_CU
> pointer is set for the Dwarf_Die, the Dwarf_Abbrev pointer will not
> be set up yet (it will only be once the Dwarf_Die is used to read
> attributes, children or siblings).
> 
> This functions can be used to keep a reference to a Dwarf_Die which
> you want to refer to later. The addr, and the result of this function,
> is only valid while the associated Dwarf is valid.
> 
> Since libdw already had to lookup the Dwarf_CU given an offset, this
> function is as efficient as dwarf_dieoffset (or dwarf_dieoffset_types)
> without having to know the original origin of the Dwarf_Die. It will
> search both the .debug_info and .debug_types data sections from both
> the main Dwarf or the alt Dwarf file. Once split dwarf support is added
> it will also look in any split dwarf .dwo (or the .dwp) file.
> 
> The only limitation, compared to using a Dwarf_Off and dwarf_dieoffset,
> is that it only works during runtime while the main Dwarf object is
> valid (till dwarf_end has been called on it).

I pushed this to master now.

      reply	other threads:[~2018-02-13 16:15 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-25 15:07 Mark Wielaard
2018-02-13 16:15 ` Mark Wielaard [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=1518538527.3058.20.camel@klomp.org \
    --to=mark@klomp.org \
    --cc=dodji@seketeli.org \
    --cc=elfutils-devel@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).