public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
From: Mark Wielaard <mark@klomp.org>
To: Simon Marchi <simon.marchi@polymtl.ca>
Cc: "gdb@sourceware.org" <gdb@sourceware.org>,
	gcc@gcc.gnu.org,
	 "gdb-patches@sourceware.org" <gdb-patches@sourceware.org>
Subject: Re: Split DWARF and rnglists, gcc vs clang
Date: Fri, 13 Nov 2020 16:18:19 +0100	[thread overview]
Message-ID: <55c0f2f69f1e6ad5d008665d004d629ad62ab65f.camel@klomp.org> (raw)
In-Reply-To: <3a747adc-af41-7492-de36-b357e5429fff@polymtl.ca>

Hi Simon,

On Fri, 2020-11-13 at 09:45 -0500, Simon Marchi wrote:
> I think I would have asked the question the other way around :) The
> > spec explicitly describes rnglists_base (and loclists_base) as a way
> > to reference ranges (loclists) through the index table, so that the
> > only relocation you need is in the (skeleton) DIE.
> 
> I presume you reference this non-normative text in section 2.17.3?
> 
>     This range list representation, the rnglist class, and the related
>     DW_AT_rnglists_base attribute are new in DWARF Version 5. Together
>     they eliminate most or all of the object language relocations
>     previously needed for range lists.

That too, but I was actually referring to the sections that define
Range List and Location List Tables (7.28 and 7.29) which define the
meaning of DW_AT_rnglists_base and DW_AT_loclists_base. But you could
also look at 3.1.3 Split Full Compilation Unit Entries which says that
those base attributes are inherited from the corresponding skeleton
compilation unit for a split unit.

> What I understand from this is that the rnglist class and
> DW_AT_rnglists_base attribute help reduce the number of relocations in
> the non-split case (it removes the need for relocations from
> DW_AT_ranges attribute values in .debug_info to .debug_rnglists).  I
> don't understand it as saying anything about where to put the rnglist
> data in the split-unit case.

I interpreted it as when there is a base attribute in the (skeleton)
unit, then the corresponding section (index table) can be found in the
main object file. At least that is how elfutils libdw interprets the
base attributes, not just for rnglists_base, but also str_offsets_base,
addr_base, etc. And that is also how/when GCC emits them.

> > So I believe both encodings are valid according to the spec. It just
> > depends on what you are optimizing for, small main object file size or
> > smallest encoding with least number of indirections.
> 
> So, if I understand correctly, gcc's way of doing things (putting all
> the rnglists in a common .debug_rnglists section) reduces the overall
> size of debug info since the rnglists can use the direct addressing
> rnglists entries (e.g. DW_RLE_start_end) rather than the indirect ones
> (e.g. DW_RLE_startx_endx).  But this come at the expense of a lot of
> relocations in the rnglists themselves, since they refer to addresses
> directly.

Yes, and it reduces the number of .debug_addr entries that need
relocations.

> I thought that the main point of split-units was to reduce the number of
> relocations processed by the linker and data moved around by the linker,
> to reduce link time and provide a better edit-build-debug cycle.  Is
> that the case?

I think it depends on who exactly you ask and what their specific
goals/setups are. Both things, reducing the number of relocations and
moving data out of the main object file, are independently useful in
different context. But I think it is mainly reducing the number of
relocations that is beneficial. For example clang (but not yet gcc)
supports having the .dwo sections themselves in the main object file
(using SHF_EXCLUDED for the .dwo sections, so the linker will still
skip them). Which is also a possibility that the spec describes and
which really makes split DWARF much more usable, because then you don't
need to change your build system to deal with multiple output files.

> > P.S. I am really interested in these interpretations of DWARF, but I
> > don't really follow the gdb implementation details very much. Could we
> > maybe move discussions like these from the -patches list to the main
> > gdb (or gcc) mailinglist?
> 
> Sure, I added gdb@ and gcc@.  I also left gdb-patches@ so that it's
> possible to follow the discussion there.

Thanks,

Mark

  reply	other threads:[~2020-11-13 15:18 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <d2bd55b6-67fb-a04c-95d3-bae4a0c65ff5@polymtl.ca>
     [not found] ` <20201113001143.GA2654@wildebeest.org>
2020-11-13 14:45   ` Simon Marchi
2020-11-13 15:18     ` Mark Wielaard [this message]
2020-11-13 15:41       ` Simon Marchi
2020-11-13 18:34         ` 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=55c0f2f69f1e6ad5d008665d004d629ad62ab65f.camel@klomp.org \
    --to=mark@klomp.org \
    --cc=gcc@gcc.gnu.org \
    --cc=gdb-patches@sourceware.org \
    --cc=gdb@sourceware.org \
    --cc=simon.marchi@polymtl.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).