From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca (simark.ca [158.69.221.121]) by sourceware.org (Postfix) with ESMTPS id 811793858C54 for ; Tue, 10 Oct 2023 20:46:19 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 811793858C54 Authentication-Results: sourceware.org; dmarc=fail (p=none dis=none) header.from=efficios.com Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=efficios.com Received: from smarchi-efficios.internal.efficios.com (192-222-143-198.qc.cable.ebox.net [192.222.143.198]) (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 297411E0C1; Tue, 10 Oct 2023 16:46:19 -0400 (EDT) From: Simon Marchi To: gdb-patches@sourceware.org Cc: Simon Marchi Subject: [PATCH 18/24] gdb: make so_list::sections not a pointer Date: Tue, 10 Oct 2023 16:40:13 -0400 Message-ID: <20231010204213.111285-19-simon.marchi@efficios.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231010204213.111285-1-simon.marchi@efficios.com> References: <20231010204213.111285-1-simon.marchi@efficios.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3496.9 required=5.0 tests=BAYES_00,GIT_PATCH_0,KAM_DMARC_NONE,KAM_DMARC_STATUS,SPF_HELO_PASS,SPF_SOFTFAIL,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: Make the field a vector directly, instead of a pointer to a vector. This was needed when so_list had to be a trivial type, which is not the case anymore. Change-Id: I79a8378ce0d0d1e2206ca08a273ebf332cb3ba14 --- gdb/solib.c | 18 ++++++------------ gdb/solist.h | 2 +- 2 files changed, 7 insertions(+), 13 deletions(-) diff --git a/gdb/solib.c b/gdb/solib.c index 3d6dfdc4e3c3..fabb6e1d938b 100644 --- a/gdb/solib.c +++ b/gdb/solib.c @@ -592,11 +592,9 @@ solib_map_sections (so_list &so) error (_("Shared library file name is too long.")); strcpy (so.so_name, bfd_get_filename (so.abfd)); - if (so.sections == nullptr) - so.sections = new std::vector; - *so.sections = build_section_table (so.abfd); + so.sections = build_section_table (so.abfd); - for (target_section &p : *so.sections) + for (target_section &p : so.sections) { /* Relocate the section binding addresses as recorded in the shared object's file by the base address to which the object was actually @@ -618,7 +616,7 @@ solib_map_sections (so_list &so) section tables. Do this immediately after mapping the object so that later nodes in the list can query this object, as is needed in solib-osf.c. */ - current_program_space->add_target_sections (&so, *so.sections); + current_program_space->add_target_sections (&so, so.sections); return 1; } @@ -630,8 +628,7 @@ so_list::clear () { const target_so_ops *ops = gdbarch_so_ops (current_inferior ()->arch ()); - delete this->sections; - this->sections = NULL; + this->sections.clear (); gdb_bfd_unref (this->abfd); this->abfd = NULL; @@ -708,7 +705,7 @@ solib_read_symbols (so_list &so, symfile_add_flags flags) if (so.objfile == NULL) { section_addr_info sap - = build_section_addr_info_from_section_table (*so.sections); + = build_section_addr_info_from_section_table (so.sections); gdb_bfd_ref_ptr tmp_bfd (gdb_bfd_ref_ptr::new_reference (so.abfd)); so.objfile = symbol_file_add_from_bfd (tmp_bfd, so.so_name, @@ -1168,10 +1165,7 @@ bool solib_contains_address_p (const so_list &solib, CORE_ADDR address) { - if (solib.sections == nullptr) - return false; - - for (target_section &p : *solib.sections) + for (const target_section &p : solib.sections) if (p.addr <= address && address < p.endaddr) return true; diff --git a/gdb/solist.h b/gdb/solist.h index ca12fd55ba0f..51b985d53247 100644 --- a/gdb/solist.h +++ b/gdb/solist.h @@ -84,7 +84,7 @@ struct so_list the file cannot be found or after the command "nosharedlibrary". */ struct objfile *objfile = nullptr; - std::vector *sections = nullptr; + std::vector sections; /* Record the range of addresses belonging to this shared library. There may not be just one (e.g. if two segments are relocated -- 2.42.0