From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1879) id 74957383FBAF; Mon, 30 Jan 2023 16:55:44 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 74957383FBAF DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1675097744; bh=5hVlZMtamUKPyByKIEd521foXDqWB62/Nz5/vdaAwu8=; h=From:To:Subject:Date:From; b=Y7+Gt00MEq4Mphl0QEfj0Tc5003TpkvwWhdwyZJS/AtTnc183lVJMeygfd6pZH5Af 1uL4QAQq2wldXFkjeQw3dDjpVu1PvgZSJF7wX1GUvCNPFwHGGLjvvAw05YoNz7/68T ISi0twaeFpAozbWCvVPn3GTXJMw7IXDZU4Dmt2uM= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Simon Marchi To: gdb-cvs@sourceware.org Subject: [binutils-gdb] Make addrmap const-correct in cooked index X-Act-Checkin: binutils-gdb X-Git-Author: Tom Tromey X-Git-Refname: refs/heads/master X-Git-Oldrev: 5867ab870b8aa36ae490ec6e4e8e4c55be11ccf1 X-Git-Newrev: 70ca3a6bc9538d98a602325f4e84d18d0be491d1 Message-Id: <20230130165544.74957383FBAF@sourceware.org> Date: Mon, 30 Jan 2023 16:55:44 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D70ca3a6bc953= 8d98a602325f4e84d18d0be491d1 commit 70ca3a6bc9538d98a602325f4e84d18d0be491d1 Author: Tom Tromey Date: Mon Jan 30 10:29:36 2023 -0500 Make addrmap const-correct in cooked index =20 After the cooked index is created, the addrmaps should be const. =20 Change-Id: I8234520ab346ced40a8dd6e478ba21fc438c2ba2 Diff: --- gdb/dwarf2/cooked-index.c | 6 +++--- gdb/dwarf2/cooked-index.h | 2 +- gdb/dwarf2/index-write.c | 12 +++++++----- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/gdb/dwarf2/cooked-index.c b/gdb/dwarf2/cooked-index.c index 1a568e6aae7..646bc76575c 100644 --- a/gdb/dwarf2/cooked-index.c +++ b/gdb/dwarf2/cooked-index.c @@ -401,10 +401,10 @@ cooked_index_vector::lookup (CORE_ADDR addr) =20 /* See cooked-index.h. */ =20 -std::vector -cooked_index_vector::get_addrmaps () +std::vector +cooked_index_vector::get_addrmaps () const { - std::vector result; + std::vector result; for (const auto &index : m_vector) result.push_back (index->m_addrmap); return result; diff --git a/gdb/dwarf2/cooked-index.h b/gdb/dwarf2/cooked-index.h index 7a8c18975e5..7299a4f77b4 100644 --- a/gdb/dwarf2/cooked-index.h +++ b/gdb/dwarf2/cooked-index.h @@ -360,7 +360,7 @@ public: =20 /* Return a new vector of all the addrmaps used by all the indexes held by this object. */ - std::vector get_addrmaps (); + std::vector get_addrmaps () const; =20 /* Return the entry that is believed to represent the program's "main". This will return NULL if no such entry is available. */ diff --git a/gdb/dwarf2/index-write.c b/gdb/dwarf2/index-write.c index 7b1b2d6520c..82cd3a8636d 100644 --- a/gdb/dwarf2/index-write.c +++ b/gdb/dwarf2/index-write.c @@ -433,7 +433,8 @@ write_hash_table (mapped_symtab *symtab, data_buf &outp= ut, data_buf &cpool) } } =20 -typedef std::unordered_map cu_index_ma= p; +using cu_index_map + =3D std::unordered_map; =20 /* Helper struct for building the address table. */ struct addrmap_index_data @@ -446,7 +447,7 @@ struct addrmap_index_data data_buf &addr_vec; cu_index_map &cu_index_htab; =20 - int operator() (CORE_ADDR start_addr, void *obj); + int operator() (CORE_ADDR start_addr, const void *obj); =20 /* True if the previous_* fields are valid. We can't write an entry until we see the next entry (since it is only= then @@ -472,9 +473,10 @@ add_address_entry (data_buf &addr_vec, /* Worker function for traversing an addrmap to build the address table. = */ =20 int -addrmap_index_data::operator() (CORE_ADDR start_addr, void *obj) +addrmap_index_data::operator() (CORE_ADDR start_addr, const void *obj) { - dwarf2_per_cu_data *per_cu =3D static_cast (obj); + const dwarf2_per_cu_data *per_cu + =3D static_cast (obj); =20 if (previous_valid) add_address_entry (addr_vec, @@ -500,7 +502,7 @@ addrmap_index_data::operator() (CORE_ADDR start_addr, v= oid *obj) in the index file. */ =20 static void -write_address_map (struct addrmap *addrmap, data_buf &addr_vec, +write_address_map (const addrmap *addrmap, data_buf &addr_vec, cu_index_map &cu_index_htab) { struct addrmap_index_data addrmap_index_data (addr_vec, cu_index_htab);