From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id 5mrjEiRkwGcfoz8AWB0awg (envelope-from ) for ; Thu, 27 Feb 2025 08:09:56 -0500 Authentication-Results: simark.ca; dkim=pass (1024-bit key; unprotected) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=gSj+hUhO; dkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=k3wK9gMF; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=lmfaPOyz; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=DE4VZzuf; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 3DAF61E105; Thu, 27 Feb 2025 08:09:56 -0500 (EST) X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-5.3 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,TRACKER_ID autolearn=ham autolearn_force=no version=4.0.0 Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 35E3B1E08E for ; Thu, 27 Feb 2025 08:09:55 -0500 (EST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id E1D283858C50 for ; Thu, 27 Feb 2025 13:09:53 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E1D283858C50 Authentication-Results: sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=gSj+hUhO; dkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=k3wK9gMF; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=lmfaPOyz; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=DE4VZzuf Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2a07:de40:b251:101:10:150:64:1]) by sourceware.org (Postfix) with ESMTPS id CE8373858C52 for ; Thu, 27 Feb 2025 13:09:16 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org CE8373858C52 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de ARC-Filter: OpenARC Filter v1.0.0 sourceware.org CE8373858C52 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a07:de40:b251:101:10:150:64:1 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1740661757; cv=none; b=GwILWZRW8POMM8TYWBaUAUjBLS9Wno1/j7doXn+25yD5vv74njWg1+2NYfk4ajDDxExYW+p9JtbUEhTryXzOGkc1ysIDAQ6lkluwJpyZf3fxsOwQBrIMCjGiEIeflrv6yFSlocN39P9MAbk3vFJE9cC9BZujEtVHrmnKFe3XUaE= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1740661757; c=relaxed/simple; bh=VKVYbc/keSZ/D6fz1iNhaHrKHPXArgosXbm9wd1ZRLU=; h=DKIM-Signature:DKIM-Signature:DKIM-Signature:DKIM-Signature: Message-ID:Date:MIME-Version:Subject:To:From; b=DCpzhPtRX9lunEZhiwcTPAIhRzCnmLEumCJ3dswDxNbiK+o4uI3d9qzMMAQ2plC5uuh1TEm3vk05xAodkme5Fiy3SpUvvut2w6ZussYDI0tUrjDY37ZjGBXoY5J6K1zV4oAr0m+Fi4m5XuRO5WLwU8FvEpLF0slGsezT2siiZpM= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CE8373858C52 Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id E89492118E; Thu, 27 Feb 2025 13:09:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1740661755; h=from:from:reply-to: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=rGJZBEo+8yj7EUnm43IPBWgZOHbQzPgs45Ix5efBaEI=; b=gSj+hUhOOjyhqVO8cZ0kDukoMt/G/oJSWJF39o+KLaW9frwI/ANXo/GeQEi+zJESpiArOq PVY2XiUeNxg8p+SuK3vNhC/tadC4/CTiNHx5EHNKx/WeXdD07tFe3RQUbRjPwxQLai450k 0jD93rL0saF+ZWmWzjPf4VRcHxE/smw= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1740661755; h=from:from:reply-to: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=rGJZBEo+8yj7EUnm43IPBWgZOHbQzPgs45Ix5efBaEI=; b=k3wK9gMFigkV1FmTYH5jfPfhQx7nR9eyKEqjXHBin6EO5HlZ6kFHp9GIrtk7Wx+KkZ4Uhm JDuOJsmfwFajbYCA== Authentication-Results: smtp-out1.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1740661754; h=from:from:reply-to: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=rGJZBEo+8yj7EUnm43IPBWgZOHbQzPgs45Ix5efBaEI=; b=lmfaPOyzwWAInX+I+aQDG/E5dxWxJWoQ8fwepr0gE1u7XbXytqTt11ZJi10VFs6Vi/aIMy W/SGFd2wQB3g9mmBgW21YYFXWJJ8n6mkhi/lm1YfVmZixGhBUrAj40majEKrV5EVd59TMt olORG18nHuLtDMoo3tg3+MOrHsrKsm8= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1740661754; h=from:from:reply-to: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=rGJZBEo+8yj7EUnm43IPBWgZOHbQzPgs45Ix5efBaEI=; b=DE4VZzufBWRjMOcEX28tAOfWb3U2IJGnEE30K5+Q7hgjjsXGYQrnx93tw8EwS0OW7oLwTP i74Czzgr3oz+1aDw== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id CE48D13888; Thu, 27 Feb 2025 13:09:14 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id ElXnMPpjwGdQWwAAD6G6ig (envelope-from ); Thu, 27 Feb 2025 13:09:14 +0000 Message-ID: Date: Thu, 27 Feb 2025 14:09:15 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 1/2] gdb/dwarf: pass unit length to dwarf2_per_cu_data constructor To: Simon Marchi , gdb-patches@sourceware.org References: <20250226165255.25737-1-simon.marchi@efficios.com> Content-Language: en-US From: Tom de Vries In-Reply-To: <20250226165255.25737-1-simon.marchi@efficios.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spamd-Result: default: False [-4.30 / 50.00]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; FROM_HAS_DN(0.00)[]; FUZZY_BLOCKED(0.00)[rspamd.com]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; RCPT_COUNT_TWO(0.00)[2]; MIME_TRACE(0.00)[0:+]; ARC_NA(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; RCVD_TLS_ALL(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; TO_DN_SOME(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; MID_RHS_MATCH_FROM(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:mid,suse.de:email] X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~public-inbox=simark.ca@sourceware.org On 2/26/25 17:52, Simon Marchi wrote: > Most of the time, the length of a unit is known when constructing a > dwarf2_per_cu_data or signatured_type. Add a construtor parameter for Hi Simon, construtor -> constructor. LGTM. Reviewed-By: Tom de Vries Thanks, - Tom > it. In the few cases where it isn't, pass 0, which leaves it unset. > > Change-Id: I0c8b9683164d3e3f3823ed995f71689a4d17fd96 > --- > gdb/dwarf2/read-gdb-index.c | 5 ++- > gdb/dwarf2/read.c | 66 ++++++++++++++++++------------------- > gdb/dwarf2/read.h | 13 +++++--- > 3 files changed, 46 insertions(+), 38 deletions(-) > > diff --git a/gdb/dwarf2/read-gdb-index.c b/gdb/dwarf2/read-gdb-index.c > index ff60e9b862c6..80b2931cd606 100644 > --- a/gdb/dwarf2/read-gdb-index.c > +++ b/gdb/dwarf2/read-gdb-index.c > @@ -1374,8 +1374,11 @@ create_signatured_type_table_from_gdb_index > = extract_unsigned_integer (bytes + 16, 8, BFD_ENDIAN_LITTLE); > bytes += 3 * 8; > > + /* The length of the type unit is unknown at this time. It gets > + (presumably) set by a cutu_reader when it gets expanded later. */ > signatured_type_up sig_type > - = per_bfd->allocate_signatured_type (section, sect_off, signature); > + = per_bfd->allocate_signatured_type (section, sect_off, 0 /* length */, > + signature); > sig_type->type_offset_in_tu = type_offset_in_tu; > > sig_types_hash.emplace (sig_type.get ()); > diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c > index b4fd7e30cb7c..2b060959c36f 100644 > --- a/gdb/dwarf2/read.c > +++ b/gdb/dwarf2/read.c > @@ -1819,10 +1819,10 @@ dw2_instantiate_symtab (dwarf2_per_cu_data *per_cu, > > dwarf2_per_cu_data_up > dwarf2_per_bfd::allocate_per_cu (dwarf2_section_info *section, > - sect_offset sect_off) > + sect_offset sect_off, unsigned int length) > { > dwarf2_per_cu_data_up result (new dwarf2_per_cu_data (this, section, > - sect_off)); > + sect_off, length)); > result->index = all_units.size (); > return result; > } > @@ -1832,10 +1832,11 @@ dwarf2_per_bfd::allocate_per_cu (dwarf2_section_info *section, > signatured_type_up > dwarf2_per_bfd::allocate_signatured_type (dwarf2_section_info *section, > sect_offset sect_off, > + unsigned int length, > ULONGEST signature) > { > - auto result > - = std::make_unique (this, section, sect_off, signature); > + auto result = std::make_unique (this, section, sect_off, > + length, signature); > result->index = all_units.size (); > tu_stats.nr_tus++; > return result; > @@ -1849,8 +1850,7 @@ create_cu_from_index_list (dwarf2_per_bfd *per_bfd, > int is_dwz, > sect_offset sect_off, ULONGEST length) > { > - dwarf2_per_cu_data_up the_cu = per_bfd->allocate_per_cu (section, sect_off); > - the_cu->set_length (length); > + dwarf2_per_cu_data_up the_cu = per_bfd->allocate_per_cu (section, sect_off, length); > the_cu->is_dwz = is_dwz; > return the_cu; > } > @@ -2690,13 +2690,13 @@ create_debug_types_hash_table (dwarf2_per_objfile *per_objfile, > > static signatured_type_set::iterator > add_type_unit (dwarf2_per_bfd *per_bfd, dwarf2_section_info *section, > - sect_offset sect_off, ULONGEST sig) > + sect_offset sect_off, unsigned int length, ULONGEST sig) > { > if (per_bfd->all_units.size () == per_bfd->all_units.capacity ()) > ++per_bfd->tu_stats.nr_all_type_units_reallocs; > > signatured_type_up sig_type_holder > - = per_bfd->allocate_signatured_type (section, sect_off, sig); > + = per_bfd->allocate_signatured_type (section, sect_off, length, sig); > signatured_type *sig_type = sig_type_holder.get (); > > per_bfd->all_units.emplace_back (sig_type_holder.release ()); > @@ -2730,7 +2730,6 @@ fill_in_sig_entry_from_dwo_entry (dwarf2_per_objfile *per_objfile, > gdb_assert (sig_entry->dwo_unit == NULL > || sig_entry->dwo_unit == dwo_entry); > > - sig_entry->set_length (dwo_entry->length, false); > sig_entry->reading_dwo_directly = 1; > sig_entry->type_offset_in_tu = dwo_entry->type_offset_in_tu; > sig_entry->dwo_unit = dwo_entry; > @@ -2795,8 +2794,8 @@ lookup_dwo_signatured_type (struct dwarf2_cu *cu, ULONGEST sig) > > /* If the global table doesn't have an entry for this TU, add one. */ > if (sig_type_it == per_bfd->signatured_types.end ()) > - sig_type_it > - = add_type_unit (per_bfd, dwo_entry->section, dwo_entry->sect_off, sig); > + sig_type_it = add_type_unit (per_bfd, dwo_entry->section, > + dwo_entry->sect_off, dwo_entry->length, sig); > > if ((*sig_type_it)->dwo_unit == nullptr) > fill_in_sig_entry_from_dwo_entry (per_objfile, *sig_type_it, dwo_entry); > @@ -2836,8 +2835,8 @@ lookup_dwp_signatured_type (struct dwarf2_cu *cu, ULONGEST sig) > if (dwo_entry == NULL) > return NULL; > > - sig_type_it > - = add_type_unit (per_bfd, dwo_entry->section, dwo_entry->sect_off, sig); > + sig_type_it = add_type_unit (per_bfd, dwo_entry->section, > + dwo_entry->sect_off, dwo_entry->length, sig); > fill_in_sig_entry_from_dwo_entry (per_objfile, *sig_type_it, dwo_entry); > > return *sig_type_it; > @@ -4022,7 +4021,7 @@ process_skeletonless_type_unit (void **slot, void *info) > /* This does the job that create_all_units would have done for > this TU. */ > sig_type_it = add_type_unit (per_bfd, dwo_unit->section, dwo_unit->sect_off, > - dwo_unit->signature); > + dwo_unit->length, dwo_unit->signature); > fill_in_sig_entry_from_dwo_entry (per_objfile, *sig_type_it, dwo_unit); > > /* This does the job that build_type_psymtabs would have done. */ > @@ -4283,13 +4282,16 @@ read_comp_units_from_section (dwarf2_per_objfile *per_objfile, > abbrev_section, info_ptr, > section_kind); > > + unsigned int length = cu_header.get_length_with_initial (); > + > /* Save the compilation unit for later lookup. */ > if (cu_header.unit_type != DW_UT_type) > - this_cu = per_objfile->per_bfd->allocate_per_cu (section, sect_off); > + this_cu > + = per_objfile->per_bfd->allocate_per_cu (section, sect_off, length); > else > { > auto sig_type = per_objfile->per_bfd->allocate_signatured_type > - (section, sect_off, cu_header.signature); > + (section, sect_off, length, cu_header.signature); > signatured_type *sig_ptr = sig_type.get (); > sig_type->type_offset_in_tu = cu_header.type_cu_offset_in_tu; > this_cu.reset (sig_type.release ()); > @@ -4304,7 +4306,6 @@ read_comp_units_from_section (dwarf2_per_objfile *per_objfile, > hex_string (sig_ptr->signature)); > } > > - this_cu->set_length (cu_header.get_length_with_initial ()); > this_cu->is_dwz = is_dwz; > /* Init this asap, to avoid a data race in the set_version in > cutu_reader::cutu_reader (which may be run in parallel for the cooked > @@ -7065,10 +7066,11 @@ create_cus_hash_table (dwarf2_per_objfile *per_objfile, > void **slot; > sect_offset sect_off = (sect_offset) (info_ptr - section.buffer); > > - dwarf2_per_cu_data per_cu (per_bfd, §ion, sect_off); > - > + /* The length of the CU gets set by the cutu_reader just below. */ > + dwarf2_per_cu_data per_cu (per_bfd, §ion, sect_off, 0); > cutu_reader reader (&per_cu, per_objfile, language_minimal, > cu, &dwo_file); > + > if (!reader.dummy_p) > create_dwo_cu_reader (&reader, reader.info_ptr, reader.comp_unit_die, > &dwo_file, &read_unit); > @@ -20944,29 +20946,27 @@ namespace find_containing_comp_unit { > static void > run_test () > { > - const auto create_dummy_per_cu = [] () > + const auto create_dummy_per_cu = [] (sect_offset sect_off, unsigned int length) > { > - return (dwarf2_per_cu_data_up > - (new dwarf2_per_cu_data (nullptr, nullptr, sect_offset {}))); > + return dwarf2_per_cu_data_up (new dwarf2_per_cu_data (nullptr, nullptr, > + sect_off, length)); > }; > > - dwarf2_per_cu_data_up one = create_dummy_per_cu (); > + /* Units in the main file. */ > + dwarf2_per_cu_data_up one = create_dummy_per_cu (sect_offset (0), 5); > dwarf2_per_cu_data *one_ptr = one.get (); > - dwarf2_per_cu_data_up two = create_dummy_per_cu (); > + dwarf2_per_cu_data_up two > + = create_dummy_per_cu (sect_offset (one->length ()), 7); > dwarf2_per_cu_data *two_ptr = two.get (); > - dwarf2_per_cu_data_up three = create_dummy_per_cu (); > + > + /* Units in the supplementary (dwz) file. */ > + dwarf2_per_cu_data_up three = create_dummy_per_cu (sect_offset (0), 5); > dwarf2_per_cu_data *three_ptr = three.get (); > - dwarf2_per_cu_data_up four = create_dummy_per_cu (); > + dwarf2_per_cu_data_up four > + = create_dummy_per_cu (sect_offset (three->length ()), 7); > dwarf2_per_cu_data *four_ptr = four.get (); > > - one->set_length (5); > - two->sect_off = sect_offset (one->length ()); > - two->set_length (7); > - > - three->set_length (5); > three->is_dwz = 1; > - four->sect_off = sect_offset (three->length ()); > - four->set_length (7); > four->is_dwz = 1; > > std::vector units; > diff --git a/gdb/dwarf2/read.h b/gdb/dwarf2/read.h > index e0c0e1fe3f0a..4463015d98d2 100644 > --- a/gdb/dwarf2/read.h > +++ b/gdb/dwarf2/read.h > @@ -96,9 +96,12 @@ using dwarf2_per_cu_data_up > > struct dwarf2_per_cu_data > { > + /* LENGTH is the length of the unit. If the value is 0, it means it is not > + known, and may be set later using the set_length method. */ > dwarf2_per_cu_data (dwarf2_per_bfd *per_bfd, dwarf2_section_info *section, > - sect_offset sect_off) > + sect_offset sect_off, unsigned int length) > : sect_off (sect_off), > + m_length (length), > is_debug_types (false), > is_dwz (false), > reading_dwo_directly (false), > @@ -374,8 +377,8 @@ struct dwarf2_per_cu_data > struct signatured_type : public dwarf2_per_cu_data > { > signatured_type (dwarf2_per_bfd *per_bfd, dwarf2_section_info *section, > - sect_offset sect_off, ULONGEST signature) > - : dwarf2_per_cu_data (per_bfd, section, sect_off), > + sect_offset sect_off, unsigned int length, ULONGEST signature) > + : dwarf2_per_cu_data (per_bfd, section, sect_off, length), > signature (signature) > { > this->is_debug_types = true; > @@ -489,13 +492,15 @@ struct dwarf2_per_bfd > returned object has its "index" field set properly. The object > is allocated on the dwarf2_per_bfd obstack. */ > dwarf2_per_cu_data_up allocate_per_cu (dwarf2_section_info *section, > - sect_offset sect_off); > + sect_offset sect_off, > + unsigned int length); > > /* A convenience function to allocate a signatured_type. The > returned object has its "index" field set properly. The object > is allocated on the dwarf2_per_bfd obstack. */ > signatured_type_up allocate_signatured_type (dwarf2_section_info *section, > sect_offset sect_off, > + unsigned int length, > ULONGEST signature); > > /* Map all the DWARF section data needed when scanning > > base-commit: 227a52fbbd60325440af342e14076f75397187ed