dwarves.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dimitri John Ledkov <dimitri.ledkov@canonical.com>
To: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: dwarves@vger.kernel.org, elfutils-devel@sourceware.org, mark@klomp.org
Subject: Re: Porting pahole from dwarf_next_unit() to dwarf_get_units()
Date: Tue, 5 Dec 2023 16:11:06 +0000	[thread overview]
Message-ID: <CADWks+bxFgT0e8vA0MaX2aXsLDzawU2kyhiOXBm_bP3UOxw_dA@mail.gmail.com> (raw)
In-Reply-To: <ZW9GKNPpEU1M3vYp@kernel.org>

I

On Tue, 5 Dec 2023, 15:47 Arnaldo Carvalho de Melo, <acme@kernel.org> wrote:
>
> Em Tue, Dec 05, 2023 at 01:03:01PM +0000, Dimitri John Ledkov escreveu:
> > Currently pahole warns and does nothing upon hitting
> > DW_TAG_skeleton_unit as implemented at
> > https://git.kernel.org/pub/scm/devel/pahole/pahole.git/commit/?id=0135ccd632796ab3aff65b7c99b374c4682c2bcf
> >
> > In elfutils, a while back a new API got added that aids with discovery
> > and processing of such tags -
> > https://sourceware.org/git/?p=elfutils.git;a=commitdiff;h=79f0e623dcde4b042bb72f636a2211d67d5c0ade
> >
> > It seems to me if pahole is ported from using dwarf_next_unit() to
> > instead use dwarf_get_units() native support can be added for
> > split-dwarf (dwo) files.
>
> That would be awesome!
>
> > I am trying to write such a port, but it is proving to be very
> > difficult.
>
> I did some work on supporting split-dwarf months ago, but got
> sidetracked with other work, BTF related and then the code bitrotted, I
> have to go back looking at it to swap back the details into my brain:
>
> https://git.kernel.org/pub/scm/devel/pahole/pahole.git/log/?h=alt_dwarf
>
> The patches after:
>
> 45c044860c2abce7 dwarf_loader: Sync with LINUX_ELFNOTE_LTO_INFO macro from kernel
>
> Are the ones to suport alt dwarf.

I will read into those thanks.

>
> > I am entirely unfamiliar with neither pahole nor libdw nor
> > the dwarf file format. Thus it is very confusing when both pahole and
> > dwarf library use very similar type names and structs. For example
> > libdw has struct Dwarf_CU and pahole has unrelated dwarf_cu struct.
>
> > What are the differences between dwarf_nextcu(), dwarf_next_unit(),
> > dwarf_get_units() and when should one use each one of them? (or nest
> > them?)
>
> > Is a port of https://git.kernel.org/pub/scm/devel/pahole/pahole.git/tree/dwarf_loader.c?id=0135ccd632796ab3aff65b7c99b374c4682c2bcf
> > to use dwarf_get_units() a right approach and would be welcomed?
>
> Yes, we need to support DWARF5 fully.

ack

>
> > Is anyone else interested in providing any help, or guidance?
>
> I'm interested, and I think if Mark could help it would be great as
> well.

I have something that sort of works, but then like aboarts with
invalid free's on exit - which the purist in me cares, but not sure if
it is of practical value or not.
And eu-readelf code also mentions that it deliberary leaks memory,
because life is hard.
I will try to address or warn about memory leaks to see if stuff
works, and post and RFC.

Regards,

Dimitri.

  reply	other threads:[~2023-12-05 16:11 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-05 13:03 Porting pahole from dwarf_next_unit() to dwarf_get_units() Dimitri John Ledkov
2023-12-05 15:47 ` Arnaldo Carvalho de Melo
2023-12-05 16:11   ` Dimitri John Ledkov [this message]
2023-12-05 17:43     ` [PATCH] HACK: port dwarf_loader to dwarf_get_units Dimitri John Ledkov
2023-12-05 18:46     ` Porting pahole from dwarf_next_unit() to dwarf_get_units() Arnaldo Carvalho de Melo
2024-01-14 22:29 ` Mark Wielaard

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=CADWks+bxFgT0e8vA0MaX2aXsLDzawU2kyhiOXBm_bP3UOxw_dA@mail.gmail.com \
    --to=dimitri.ledkov@canonical.com \
    --cc=acme@kernel.org \
    --cc=dwarves@vger.kernel.org \
    --cc=elfutils-devel@sourceware.org \
    --cc=mark@klomp.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 NNTP newsgroup(s).