public inbox for libabigail@sourceware.org
 help / color / mirror / Atom feed
From: "mark at klomp dot org" <sourceware-bugzilla@sourceware.org>
To: libabigail@sourceware.org
Subject: [Bug default/21023] The abidw tool does not appear to read dwarf from .dwp files associated with executables
Date: Tue, 07 Dec 2021 09:19:13 +0000	[thread overview]
Message-ID: <bug-21023-9487-BTnjWanXH3@http.sourceware.org/bugzilla/> (raw)
In-Reply-To: <bug-21023-9487@http.sourceware.org/bugzilla/>

https://sourceware.org/bugzilla/show_bug.cgi?id=21023

--- Comment #9 from Mark Wielaard <mark at klomp dot org> ---
Hi Thomas,

(In reply to Thomas Schwinge from comment #8)
> So I wanted to use libabigail on GCC '-gsplit-dwarf' object files
> ('*.o'/'*.dwo'), and found that it doesn't work.  Then found this existing
> PR; confirming that status is still as per Andrew's 2018-06-16 comment:
> 'eu-readelf'/elfutils (Ubuntu 0.176-1.1build1 in my case) appears to work,
> but 'abidw'/libabigail (current master branch) doesn't even open the '*.dwo'
> file, per 'strace'.
> 
> If I wanted to try help implement that (but no promises how far I'll
> get...), are Mark's 2018-06-05 comments here re "libabigail will need to use
> a few new interfaces" still applicable, to get started?

Yes, that is still applicable.

Where libabigail now uses dwarf_next_unit, it should use dwarf_get_units.
dwarf_get_units provides the type of the unit, if it is a type unit or split
unit, it will not only provide the CU DIE, but also the "Sub DIE", that is the
Type DIE (for type units) or Split DIE (for split units). It can then follow
the Split DIE to get the actual DIE tree for that unit (the CU DIE is just the
Skeleton DIE in that case).

These DIEs might come from different files (Dwarf objects) than the main Dwarf.
So where libabigail now uses Dwarf_Off as a (unique) identifier of a DIE (and
uses dwarf_offdie or dwarf_offdie_types to reconstruct a Dwarf_Die from a
Dwarf_Off), it should now use the Dwarf_Die void *addr field as unique
identifier (and use dwarf_die_addr_die to reconstruct the Dwarf_Die).

See libdw.h for more documentation. Specifically:

/* Gets the next Dwarf_CU (unit), version, unit type and if available
   the CU DIE and sub (type) DIE of the unit.  Returns 0 on success,
   -1 on error or 1 if there are no more units.  To start iterating
   provide NULL for CU.  If version < 5 the unit type is set from the
   CU DIE if available (DW_UT_compile for DW_TAG_compile_unit,
   DW_UT_type for DW_TAG_type_unit or DW_UT_partial for
   DW_TAG_partial_unit), otherwise it is set to zero.  If unavailable
   (the version or unit type is unknown) the CU DIE is cleared.
   Likewise if the sub DIE isn't isn't available (the unit type is not
   DW_UT_type or DW_UT_split_type) the sub DIE tag is cleared.  */
extern int dwarf_get_units (Dwarf *dwarf, Dwarf_CU *cu, Dwarf_CU **next_cu,
                            Dwarf_Half *version, uint8_t *unit_type,
                            Dwarf_Die *cudie, Dwarf_Die *subdie)
     __nonnull_attribute__ (3);

/* Given a Dwarf_Die addr 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.  */
extern Dwarf_Die *dwarf_die_addr_die (Dwarf *dbg, void *addr,
                                      Dwarf_Die *result)
     __nonnull_attribute__ (3);

One note to keep in mind. Each .dwo is also represented as a Dwarf handle, and
a Dwarf_Die from a split dwarf file will have that as Dwarf handle. But the
above functions work on the main Dwarf handle (which owns the sub Dwarf handles
and will clean them up when you drop the main Dwarf handle).

Cheers,

Mark

-- 
You are receiving this mail because:
You are on the CC list for the bug.

  parent reply	other threads:[~2021-12-07  9:19 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-01  0:00 [Bug default/21023] New: " andrew.c.morrow at gmail dot com
2017-01-01  0:00 ` [Bug default/21023] " andrew.c.morrow at gmail dot com
2017-01-01  0:00 ` mark at klomp dot org
2017-01-01  0:00 ` mark at klomp dot org
2017-01-01  0:00 ` andrew.c.morrow at gmail dot com
2017-01-01  0:00 ` andrew.c.morrow at gmail dot com
2018-01-01  0:00 ` andrew.c.morrow at gmail dot com
2018-01-01  0:00 ` mark at klomp dot org
2021-12-06 22:12 ` tschwinge at sourceware dot org
2021-12-07  9:19 ` mark at klomp dot org [this message]
2021-12-07  9:29 ` mark at klomp dot org

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=bug-21023-9487-BTnjWanXH3@http.sourceware.org/bugzilla/ \
    --to=sourceware-bugzilla@sourceware.org \
    --cc=libabigail@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).