From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 7ED4C385B515 for ; Thu, 26 Oct 2023 09:54:14 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 7ED4C385B515 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 7ED4C385B515 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1698314055; cv=none; b=klVfpWDmdQRWIzKTNm9Hoya6zCqfgNIiTXuUNEbDQnxh1gIUM3dBVYhPkN7PGNxkqeq4Qk3lwYso4r5O9sJ5gUgtkneA7V9rV4MWpM41QBb+a4nD0U1oZHEeEwSYqEBhYMht3ivqf7hig52CheruP9XVLHw5VeUAabtPFU0eJ/0= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1698314055; c=relaxed/simple; bh=fX8kIvscbdFzUF9pn0Yf1uGXamF2AKJV/wBcRnyLDlA=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=cVVSBeaLFwa3N1swpmeerFqSCEMRqbOB3tepClaSI2MmD3r4vMg2+5QEv365R2SMT9AAYITArTm7sgr4NYQWzlHQ9IJP/d9Wxs4XFNvkyK4uivEyFDomFH48VWKLUYcmFCVIZod9mu7T94enWLrzmocfpPXVg3JO9vzIy0EzuWA= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1698314054; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=T7+VNJ56vGjgSSbBFcHf69GkFvFD/j6hB5/MIi4JVsM=; b=NXeX0+5rXmPi8PTOYMz1uX0TUFSdWfYIEN0/4kIvf2lGewq1dJ+R0Qi8R1c+gvIVKYXd/Q a9nY2W/KmjPKpeS+JOT+yBCwNHgxtR5ExbN+1votY8UYETfCZYrEOTBPckRAzAWDPFFCJB 09RUzZDFXXsd6fsjVQ1ftQB6K/ic5Xw= Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-314-tUVjJhUcPn6eot_PkSgmhw-1; Thu, 26 Oct 2023 05:54:10 -0400 X-MC-Unique: tUVjJhUcPn6eot_PkSgmhw-1 Received: by mail-ed1-f70.google.com with SMTP id 4fb4d7f45d1cf-54061ad6600so553195a12.3 for ; Thu, 26 Oct 2023 02:54:10 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698314049; x=1698918849; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=T7+VNJ56vGjgSSbBFcHf69GkFvFD/j6hB5/MIi4JVsM=; b=t6v8FSHEO1bxLFP734q/IwgiFSzTviSDBBAuNCx+gb5ZTZ5k1frejEHmMpEUtrymi1 hElHkUnAgcUoWpXiKKjyRsf35AuaYongfjiW4A1fJkh1LGcdO7yisTEYRKZyd+oO7lwf hd4y8enYrJ8rMSCtqOrFU8XLsWWiIrJZqoEvkNNosDbEOxGAqkLaVbu1FKx5PywMlxpf kbc4YxTmZgm9OkQtq42DNOys2IautSlOJOEV4ATxhpykbhs6wGrv1V71U0THaQQbfN2O w1uyduguO4QtXYH/ryM5fCiu2cl00L2FHUPiBLNt/LZSlB/0VBes9iGqYFHMVZzzBl+4 qdBA== X-Gm-Message-State: AOJu0YxydLYu4yzSc5gBRtWXEwXAslA3O9VHGMfJwVtACZayIwxUumb8 iQv+IHfbGyzSuumiWY6xAG9049pYcVUEUX1ON6pGy6s4ONONmkODdhrCwedU1xPVsxeeSuZvw/4 Uz4peHlx7S7UQWyKFinwXOWJuZ9gxdA== X-Received: by 2002:a50:9f2d:0:b0:53d:eca9:742e with SMTP id b42-20020a509f2d000000b0053deca9742emr13682189edf.9.1698314049258; Thu, 26 Oct 2023 02:54:09 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHEBEoHjfn1CCyU+tt8nuiok9fhWbzAijwyyNS5g1Xw4TAa/VgLPyvifw8OUOKbf9960Z2v7Q== X-Received: by 2002:a50:9f2d:0:b0:53d:eca9:742e with SMTP id b42-20020a509f2d000000b0053deca9742emr13682173edf.9.1698314048915; Thu, 26 Oct 2023 02:54:08 -0700 (PDT) Received: from [192.168.0.129] (ip-94-112-227-180.bb.vodafone.cz. [94.112.227.180]) by smtp.gmail.com with ESMTPSA id dk18-20020a0564021d9200b005402c456892sm7506405edb.33.2023.10.26.02.54.08 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 26 Oct 2023 02:54:08 -0700 (PDT) Message-ID: <0ffa7f32-114d-fa15-c739-53e88e6e5c28@redhat.com> Date: Thu, 26 Oct 2023 11:54:07 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.15.1 Subject: Re: [PATCH 1/2] Pre-read .debug_aranges section To: Tom Tromey , gdb-patches@sourceware.org References: <20231014205755.996771-1-tom@tromey.com> <20231014205755.996771-2-tom@tromey.com> From: Guinevere Larsen In-Reply-To: <20231014205755.996771-2-tom@tromey.com> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-11.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,NICE_REPLY_A,RCVD_IN_BARRACUDACENTRAL,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: 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 -- 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 §ion : 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 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;