From patchwork Sat Mar 8 03:02:41 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Marchi X-Patchwork-Id: 107535 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D78393858D21 for ; Sat, 8 Mar 2025 03:04:43 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D78393858D21 Authentication-Results: sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=polymtl.ca header.i=@polymtl.ca header.a=rsa-sha256 header.s=default header.b=J/ke0uMz X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from smtp.polymtl.ca (smtp.polymtl.ca [132.207.4.11]) by sourceware.org (Postfix) with ESMTPS id 4F8A73858D37 for ; Sat, 8 Mar 2025 03:02:55 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 4F8A73858D37 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=polymtl.ca Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=polymtl.ca ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 4F8A73858D37 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=132.207.4.11 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1741402975; cv=none; b=br6fd3qmoKTb7BkeIQTZ1c3HW3AD4r6XdS9kIEBRNOCWuisOJbkAPMXQEpq4WLgmoMsAUG0ecFainePNCmf7i16Ofo3i2ANHhAmLLQ9NT6DqlTZzFBWuhZjWDDeZnr7y1lP0bsIg1sU03pGN6shH0FejB7x+ehACE8WnO70lT5o= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1741402975; c=relaxed/simple; bh=ZXm9WfB+qGUeyqHI7mtGhZIOTEB7GU2aY2TfHdS7+xA=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=RRiqAzrymZwZ/a6NRxyhsXjKIZtqx/5cTP20N1+IMNU/aExtNeiAOoyBs/FPV7LB78Dyv3GqtGZzbkfTx36g5GR1K/U92Y5nKJEyO6vfEgDwW8N562hVE3gGM/WOUuXKHOfmCzlSpqeq2R0/1KinCy6HgIJJjj/d0iedzpkKHKU= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4F8A73858D37 Received: from simark.ca (simark.ca [158.69.221.121]) (authenticated bits=0) by smtp.polymtl.ca (8.14.7/8.14.7) with ESMTP id 52832oPo245430 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 7 Mar 2025 22:02:54 -0500 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp.polymtl.ca 52832oPo245430 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=polymtl.ca; s=default; t=1741402974; bh=buBSvSvuEL/IlW+OUcXT8Z1uDYo3TiXOjFZDP/zqGmY=; h=From:To:Cc:Subject:Date:In-Reply-To:From; b=J/ke0uMzXeGEihrdT/qepZY4eQEoGMQY2+Ja83rRhNnMEMwIgskh4bUN9vVSRhrD1 0wzvs17UvsRr/JT1Eq6vmPma0MiRk1na0IMyFeCPHRY2QP6UiJhzt2MMTH8gpNWdbo p3TGixJEshyAAYc+NK+BeWhmXA8pqbLVrw+FXsHc= Received: by simark.ca (Postfix, from userid 112) id 2957D1E114; Fri, 7 Mar 2025 22:02:50 -0500 (EST) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-Spam-Level: X-Spam-Status: No, score=-3187.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_PASS, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.6 Received: from simark.localdomain (modemcable238.237-201-24.mc.videotron.ca [24.201.237.238]) (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 ESMTPSA id F29321E0FE; Fri, 7 Mar 2025 22:02:47 -0500 (EST) From: simon.marchi@polymtl.ca To: gdb-patches@sourceware.org Cc: Simon Marchi Subject: [PATCH 2/2] gdb/dwarf: rename comp_unit_die to top_level_die Date: Fri, 7 Mar 2025 22:02:41 -0500 Message-ID: <20250308030246.1036109-2-simon.marchi@polymtl.ca> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250308030246.1036109-1-simon.marchi@polymtl.ca> References: <20250308030246.1036109-1-simon.marchi@polymtl.ca> MIME-Version: 1.0 X-Poly-FromMTA: (simark.ca [158.69.221.121]) at Sat, 8 Mar 2025 03:02:50 +0000 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~patchwork=sourceware.org@sourceware.org From: Simon Marchi The name "comp_unit_die" is a bit misleading, because it can also represent a type unit (DW_TAG_type_unit). I think that "top_level_die" is clear. Change-Id: Ibaac99897f0ac7499f0f82caeed3385e1e6ee870 --- gdb/dwarf2/cooked-indexer.c | 16 +++++----- gdb/dwarf2/read.c | 64 ++++++++++++++++++------------------- gdb/dwarf2/read.h | 4 +-- 3 files changed, 42 insertions(+), 42 deletions(-) diff --git a/gdb/dwarf2/cooked-indexer.c b/gdb/dwarf2/cooked-indexer.c index 40f18d1e5e50..18c9c3b2459f 100644 --- a/gdb/dwarf2/cooked-indexer.c +++ b/gdb/dwarf2/cooked-indexer.c @@ -45,9 +45,9 @@ cooked_indexer::check_bounds (cutu_reader *reader) unrelocated_addr best_lowpc = {}, best_highpc = {}; /* Possibly set the default values of LOWPC and HIGHPC from `DW_AT_ranges'. */ - dwarf2_find_base_address (reader->comp_unit_die (), cu); + dwarf2_find_base_address (reader->top_level_die (), cu); enum pc_bounds_kind cu_bounds_kind - = dwarf2_get_pc_bounds (reader->comp_unit_die (), &best_lowpc, &best_highpc, + = dwarf2_get_pc_bounds (reader->top_level_die (), &best_lowpc, &best_highpc, cu, m_index_storage->get_addrmap (), cu->per_cu); if (cu_bounds_kind == PC_BOUNDS_HIGH_LOW && best_lowpc < best_highpc) { @@ -113,16 +113,16 @@ cooked_indexer::ensure_cu_exists (cutu_reader *reader, language_minimal, &m_index_storage->get_abbrev_table_cache ()); - if (new_reader.is_dummy () || new_reader.comp_unit_die () == nullptr - || !new_reader.comp_unit_die ()->has_children) + if (new_reader.is_dummy () || new_reader.top_level_die () == nullptr + || !new_reader.top_level_die ()->has_children) return nullptr; auto copy = std::make_unique (std::move (new_reader)); result = m_index_storage->preserve (std::move (copy)); } - if (result->is_dummy () || result->comp_unit_die () == nullptr - || !result->comp_unit_die ()->has_children) + if (result->is_dummy () || result->top_level_die () == nullptr + || !result->top_level_die ()->has_children) return nullptr; if (for_scanning) @@ -684,9 +684,9 @@ void cooked_indexer::make_index (cutu_reader *reader) { check_bounds (reader); - find_file_and_directory (reader->comp_unit_die (), reader->cu ()); + find_file_and_directory (reader->top_level_die (), reader->cu ()); - if (!reader->comp_unit_die ()->has_children) + if (!reader->top_level_die ()->has_children) return; index_dies (reader, reader->info_ptr (), nullptr, false); diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index c5375b685676..3b0f74cfec71 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -1863,7 +1863,7 @@ dw2_get_file_names (dwarf2_per_cu *this_cu, dwarf2_per_objfile *per_objfile) per_objfile->get_cu (this_cu), true, language_minimal, nullptr); if (!reader.is_dummy ()) - dw2_get_file_names_reader (reader.cu (), reader.comp_unit_die ()); + dw2_get_file_names_reader (reader.cu (), reader.top_level_die ()); return this_cu->file_names; } @@ -2774,7 +2774,7 @@ cutu_reader::init_cu_die_reader (dwarf2_cu *cu, dwarf2_section_info *section, attribute of the referencing CU. At most one of STUB_COMP_UNIT_DIE and STUB_COMP_DIR may be non-NULL. - *RESULT_READER,*RESULT_INFO_PTR,*RESULT_COMP_UNIT_DIE + *RESULT_READER,*RESULT_INFO_PTR,*RESULT_TOP_LEVEL_DIE are filled in with the info of the DIE from the DWO file. *RESULT_DWO_ABBREV_TABLE will be filled in with the abbrev table allocated @@ -2788,7 +2788,7 @@ cutu_reader::read_cutu_die_from_dwo (dwarf2_cu *cu, dwo_unit *dwo_unit, die_info *stub_comp_unit_die, const char *stub_comp_dir, const gdb_byte **result_info_ptr, - die_info **result_comp_unit_die, + die_info **result_top_level_die, abbrev_table_up *result_dwo_abbrev_table) { dwarf2_per_objfile *per_objfile = cu->per_objfile; @@ -2916,7 +2916,7 @@ cutu_reader::read_cutu_die_from_dwo (dwarf2_cu *cu, dwo_unit *dwo_unit, has the benefit of simplifying the rest of the code - all the work to maintain the illusion of a single DW_TAG_{compile,type}_unit DIE is done here. */ - info_ptr = this->read_toplevel_die (result_comp_unit_die, info_ptr, + info_ptr = this->read_toplevel_die (result_top_level_die, info_ptr, gdb::make_array_view (attributes, next_attr_idx)); @@ -3029,7 +3029,7 @@ cutu_reader::init_tu_and_read_dwo_dies (dwarf2_per_cu *this_cu, if (read_cutu_die_from_dwo (cu, sig_type->dwo_unit, NULL /* stub_comp_unit_die */, sig_type->dwo_unit->dwo_file->comp_dir, - &m_info_ptr, &m_comp_unit_die, + &m_info_ptr, &m_top_level_die, &m_dwo_abbrev_table) == 0) { @@ -3197,9 +3197,9 @@ cutu_reader::cutu_reader (dwarf2_per_cu *this_cu, /* Read the top level CU/TU die. */ this->init_cu_die_reader (cu, section, NULL, abbrev_table); - m_info_ptr = this->read_toplevel_die (&m_comp_unit_die, m_info_ptr); + m_info_ptr = this->read_toplevel_die (&m_top_level_die, m_info_ptr); - if (skip_partial && m_comp_unit_die->tag == DW_TAG_partial_unit) + if (skip_partial && m_top_level_die->tag == DW_TAG_partial_unit) m_dummy_p = true; else { @@ -3213,23 +3213,23 @@ cutu_reader::cutu_reader (dwarf2_per_cu *this_cu, Note that if USE_EXISTING_OK != 0, and THIS_CU->cu already contains a DWO CU, that this test will fail (the attribute will not be present). */ - const char *dwo_name = dwarf2_dwo_name (m_comp_unit_die, cu); + const char *dwo_name = dwarf2_dwo_name (m_top_level_die, cu); if (dwo_name != nullptr) { struct dwo_unit *dwo_unit; struct die_info *dwo_comp_unit_die; - if (m_comp_unit_die->has_children) + if (m_top_level_die->has_children) { complaint (_("compilation unit with DW_AT_GNU_dwo_name" " has children (offset %s) [in module %s]"), sect_offset_str (this_cu->sect_off), bfd_get_filename (abfd)); } - dwo_unit = lookup_dwo_unit (cu, m_comp_unit_die, dwo_name); + dwo_unit = lookup_dwo_unit (cu, m_top_level_die, dwo_name); if (dwo_unit != NULL) { - if (read_cutu_die_from_dwo (cu, dwo_unit, m_comp_unit_die, + if (read_cutu_die_from_dwo (cu, dwo_unit, m_top_level_die, nullptr, &m_info_ptr, &dwo_comp_unit_die, &m_dwo_abbrev_table) @@ -3239,7 +3239,7 @@ cutu_reader::cutu_reader (dwarf2_per_cu *this_cu, m_dummy_p = true; } else - m_comp_unit_die = dwo_comp_unit_die; + m_top_level_die = dwo_comp_unit_die; } else { @@ -3254,7 +3254,7 @@ cutu_reader::cutu_reader (dwarf2_per_cu *this_cu, } /* Only a dummy unit can be missing the compunit DIE. */ - gdb_assert (m_dummy_p || m_comp_unit_die != nullptr); + gdb_assert (m_dummy_p || m_top_level_die != nullptr); prepare_one_comp_unit (cu, pretend_language); } @@ -3342,7 +3342,7 @@ cutu_reader::cutu_reader (dwarf2_per_cu *this_cu, this->init_cu_die_reader (m_new_cu.get (), section, dwo_file, m_abbrev_table_holder.get ()); - info_ptr = this->read_toplevel_die (&m_comp_unit_die, info_ptr); + info_ptr = this->read_toplevel_die (&m_top_level_die, info_ptr); } prepare_one_comp_unit (m_new_cu.get (), pretend_language); @@ -3482,12 +3482,12 @@ process_psymtab_comp_unit (dwarf2_per_cu *this_cu, reader = storage->preserve (std::move (copy)); } - if (reader->comp_unit_die () == nullptr || reader->is_dummy ()) + if (reader->top_level_die () == nullptr || reader->is_dummy ()) return; if (this_cu->is_debug_types) build_type_psymtabs_reader (reader, storage); - else if (reader->comp_unit_die ()->tag != DW_TAG_partial_unit) + else if (reader->top_level_die ()->tag != DW_TAG_partial_unit) { bool nope = false; if (this_cu->scanned.compare_exchange_strong (nope, true)) @@ -3507,7 +3507,7 @@ build_type_psymtabs_reader (cutu_reader *reader, { struct dwarf2_cu *cu = reader->cu (); dwarf2_per_cu *per_cu = cu->per_cu; - die_info *type_unit_die = reader->comp_unit_die (); + die_info *type_unit_die = reader->top_level_die (); gdb_assert (per_cu->is_debug_types); @@ -4421,11 +4421,11 @@ load_full_comp_unit (dwarf2_per_cu *this_cu, gdb_assert (cu->die_hash.empty ()); cu->die_hash.reserve (cu->header.get_length_without_initial () / 12); - if (reader.comp_unit_die ()->has_children) - reader.comp_unit_die ()->child + if (reader.top_level_die ()->has_children) + reader.top_level_die ()->child = reader.read_die_and_siblings (reader.info_ptr (), &info_ptr, - reader.comp_unit_die ()); - cu->dies = reader.comp_unit_die (); + reader.top_level_die ()); + cu->dies = reader.top_level_die (); /* comp_unit_die is not stored in die_hash, no need. */ reader.keep (); @@ -6619,7 +6619,7 @@ create_cus_hash_table (dwarf2_cu *cu, dwo_file &dwo_file) if (!reader.is_dummy ()) create_dwo_cu_reader (reader.cu (), reader.info_ptr (), - reader.comp_unit_die (), &dwo_file, &read_unit); + reader.top_level_die (), &dwo_file, &read_unit); info_ptr += per_cu.length (); /* If the unit could not be parsed, skip it. */ @@ -19160,11 +19160,11 @@ read_signatured_type (signatured_type *sig_type, gdb_assert (cu->die_hash.empty ()); cu->die_hash.reserve (cu->header.get_length_without_initial () / 12); - if (reader.comp_unit_die ()->has_children) - reader.comp_unit_die ()->child + if (reader.top_level_die ()->has_children) + reader.top_level_die ()->child = reader.read_die_and_siblings (info_ptr, &info_ptr, - reader.comp_unit_die ()); - cu->dies = reader.comp_unit_die (); + reader.top_level_die ()); + cu->dies = reader.top_level_die (); /* comp_unit_die is not stored in die_hash, no need. */ reader.keep (); @@ -19804,7 +19804,7 @@ cutu_reader::prepare_one_comp_unit (struct dwarf2_cu *cu, { struct attribute *attr; - if (m_comp_unit_die == nullptr) + if (m_top_level_die == nullptr) { cu->set_producer (nullptr); cu->language_defn = language_def (pretend_language); @@ -19813,10 +19813,10 @@ cutu_reader::prepare_one_comp_unit (struct dwarf2_cu *cu, return; } - cu->set_producer (dwarf2_string_attr (m_comp_unit_die, DW_AT_producer, cu)); + cu->set_producer (dwarf2_string_attr (m_top_level_die, DW_AT_producer, cu)); /* Set the language we're debugging. */ - attr = dwarf2_attr (m_comp_unit_die, DW_AT_language, cu); + attr = dwarf2_attr (m_top_level_die, DW_AT_language, cu); enum language lang; dwarf_source_language dw_lang = (dwarf_source_language) 0; if (cu->producer_is_xlc_opencl ()) @@ -19845,14 +19845,14 @@ cutu_reader::prepare_one_comp_unit (struct dwarf2_cu *cu, cu->language_defn = language_def (lang); /* Initialize the lto_artificial field. */ - attr = dwarf2_attr (m_comp_unit_die, DW_AT_name, cu); + attr = dwarf2_attr (m_top_level_die, DW_AT_name, cu); if (attr != nullptr && cu->producer_is_gcc () && attr->as_string () != nullptr && strcmp (attr->as_string (), "") == 0) cu->per_cu->lto_artificial = true; - switch (m_comp_unit_die->tag) + switch (m_top_level_die->tag) { case DW_TAG_compile_unit: cu->per_cu->set_unit_type (DW_UT_compile); @@ -19865,7 +19865,7 @@ cutu_reader::prepare_one_comp_unit (struct dwarf2_cu *cu, break; default: error (_(DWARF_ERROR_PREFIX "unexpected tag '%s' at offset %s"), - dwarf_tag_name (m_comp_unit_die->tag), + dwarf_tag_name (m_top_level_die->tag), sect_offset_str (cu->per_cu->sect_off)); } diff --git a/gdb/dwarf2/read.h b/gdb/dwarf2/read.h index d6d119e038dc..4376ee9fbe95 100644 --- a/gdb/dwarf2/read.h +++ b/gdb/dwarf2/read.h @@ -954,7 +954,7 @@ class cutu_reader dwarf2_cu *cu () const { return m_cu; } - die_info *comp_unit_die () const { return m_comp_unit_die; } + die_info *top_level_die () const { return m_top_level_die; } const gdb_byte *info_ptr () const { return m_info_ptr; } @@ -1061,7 +1061,7 @@ class cutu_reader const struct abbrev_table *m_abbrev_table; const gdb_byte *m_info_ptr = nullptr; - struct die_info *m_comp_unit_die = nullptr; + struct die_info *m_top_level_die = nullptr; bool m_dummy_p = false; dwarf2_per_cu *m_this_cu;