public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Guinevere Larsen <blarsen@redhat.com>
To: Tom Tromey <tom@tromey.com>, gdb-patches@sourceware.org
Subject: Re: [PATCH 1/2] Pre-read .debug_aranges section
Date: Thu, 26 Oct 2023 11:54:07 +0200	[thread overview]
Message-ID: <0ffa7f32-114d-fa15-c739-53e88e6e5c28@redhat.com> (raw)
In-Reply-To: <20231014205755.996771-2-tom@tromey.com>

On 14/10/2023 22:56, Tom Tromey wrote:
> While working on background DWARF reading, I found a race case that I
> tracked down to the handling of the .debug_aranges section.  Currently
> the section data is only read in after the CUs have all been created.
> However, there's no real reason to do this -- it seems fine to read it
> a little earlier, when all the other necessary sections are read in.
>
> This patch makes this change, and updates the
> read_addrmap_from_aranges API to assert that the section is read in.

I tested this as well and see no issues either. My one comment is about 
describing the section as "read in".

It made it very confusing to read (I thought there was a word missing 
somewhere at first), and the description of the "readin" flag says:

     /* True if we have tried to read this section.  */

So I think it would be better to describe that assert as "assert that 
the section has been read" or some other way to make it explicit that 
"read" is the past tense.

With some small rewording around this bit, everything looks good to me, 
Reviewed-By: Guinevere Larsen <blarsen@redhat.com>

-- 
Cheers,
Guinevere Larsen
She/Her/Hers

>
> This patch slightly changes the read_addrmap_from_aranges API as well,
> to reject an empty section.  This seems better to me than what the
> current code does, which is try to read an empty section but then do
> no work.
>
> Regression tested on x86-64 Fedora 38.
> ---
>   gdb/dwarf2/read-debug-names.c |  1 +
>   gdb/dwarf2/read.c             | 11 ++++++-----
>   2 files changed, 7 insertions(+), 5 deletions(-)
>
> diff --git a/gdb/dwarf2/read-debug-names.c b/gdb/dwarf2/read-debug-names.c
> index 2e5067efb3d..89f5df6df90 100644
> --- a/gdb/dwarf2/read-debug-names.c
> +++ b/gdb/dwarf2/read-debug-names.c
> @@ -166,6 +166,7 @@ create_addrmap_from_aranges (dwarf2_per_objfile *per_objfile,
>   
>     addrmap_mutable mutable_map;
>   
> +  section->read (per_objfile->objfile);
>     if (read_addrmap_from_aranges (per_objfile, section, &mutable_map))
>       per_bfd->index_addrmap
>         = new (&per_bfd->obstack) addrmap_fixed (&per_bfd->obstack,
> diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
> index d4aec19d31d..13ac83395eb 100644
> --- a/gdb/dwarf2/read.c
> +++ b/gdb/dwarf2/read.c
> @@ -1586,6 +1586,7 @@ dwarf2_per_bfd::map_info_sections (struct objfile *objfile)
>     ranges.read (objfile);
>     rnglists.read (objfile);
>     addr.read (objfile);
> +  debug_aranges.read (objfile);
>   
>     for (auto &section : types)
>       section.read (objfile);
> @@ -1843,6 +1844,11 @@ read_addrmap_from_aranges (dwarf2_per_objfile *per_objfile,
>   			   dwarf2_section_info *section,
>   			   addrmap *mutable_map)
>   {
> +  /* Caller must ensure this is read in.  */
> +  gdb_assert (section->readin);
> +  if (section->empty ())
> +    return false;
> +
>     struct objfile *objfile = per_objfile->objfile;
>     bfd *abfd = objfile->obfd.get ();
>     struct gdbarch *gdbarch = objfile->arch ();
> @@ -1870,13 +1876,8 @@ read_addrmap_from_aranges (dwarf2_per_objfile *per_objfile,
>       }
>   
>     std::set<sect_offset> debug_info_offset_seen;
> -
> -  section->read (objfile);
> -
>     const bfd_endian dwarf5_byte_order = gdbarch_byte_order (gdbarch);
> -
>     const gdb_byte *addr = section->buffer;
> -
>     while (addr < section->buffer + section->size)
>       {
>         const gdb_byte *const entry_addr = addr;



  reply	other threads:[~2023-10-26  9:54 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-14 20:56 [PATCH 0/2] Two .debug_aranges changes Tom Tromey
2023-10-14 20:56 ` [PATCH 1/2] Pre-read .debug_aranges section Tom Tromey
2023-10-26  9:54   ` Guinevere Larsen [this message]
2023-10-29 16:34     ` Tom Tromey
2023-10-14 20:56 ` [PATCH 2/2] Move read_addrmap_from_aranges to new file Tom Tromey
2023-10-26  9:56   ` Guinevere Larsen
2023-10-26 22:58     ` Tom Tromey
2023-10-27  7:27       ` Guinevere Larsen

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=0ffa7f32-114d-fa15-c739-53e88e6e5c28@redhat.com \
    --to=blarsen@redhat.com \
    --cc=gdb-patches@sourceware.org \
    --cc=tom@tromey.com \
    /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).