From: Simon Marchi <simon.marchi@efficios.com>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tromey@adacore.com>
Subject: [PATCH v2] Make addrmap const-correct in cooked index
Date: Mon, 30 Jan 2023 10:29:36 -0500 [thread overview]
Message-ID: <20230130152936.41750-1-simon.marchi@efficios.com> (raw)
In-Reply-To: <fb373fbd-cca1-5c4a-dd10-079afc7fcda5@simark.ca>
From: Tom Tromey <tromey@adacore.com>
After the cooked index is created, the addrmaps should be const.
Change-Id: I8234520ab346ced40a8dd6e478ba21fc438c2ba2
---
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 1a568e6aae76..646bc76575cd 100644
--- a/gdb/dwarf2/cooked-index.c
+++ b/gdb/dwarf2/cooked-index.c
@@ -401,10 +401,10 @@ cooked_index_vector::lookup (CORE_ADDR addr)
/* See cooked-index.h. */
-std::vector<addrmap *>
-cooked_index_vector::get_addrmaps ()
+std::vector<const addrmap *>
+cooked_index_vector::get_addrmaps () const
{
- std::vector<addrmap *> result;
+ std::vector<const addrmap *> 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 7a8c18975e5a..7299a4f77b44 100644
--- a/gdb/dwarf2/cooked-index.h
+++ b/gdb/dwarf2/cooked-index.h
@@ -360,7 +360,7 @@ class cooked_index_vector : public dwarf_scanner_base
/* Return a new vector of all the addrmaps used by all the indexes
held by this object. */
- std::vector<addrmap *> get_addrmaps ();
+ std::vector<const addrmap *> get_addrmaps () const;
/* 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 7b1b2d6520cb..82cd3a8636d0 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 &output, data_buf &cpool)
}
}
-typedef std::unordered_map<dwarf2_per_cu_data *, unsigned int> cu_index_map;
+using cu_index_map
+ = std::unordered_map<const dwarf2_per_cu_data *, unsigned int>;
/* 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;
- int operator() (CORE_ADDR start_addr, void *obj);
+ int operator() (CORE_ADDR start_addr, const void *obj);
/* 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. */
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 = static_cast<dwarf2_per_cu_data *> (obj);
+ const dwarf2_per_cu_data *per_cu
+ = static_cast<const dwarf2_per_cu_data *> (obj);
if (previous_valid)
add_address_entry (addr_vec,
@@ -500,7 +502,7 @@ addrmap_index_data::operator() (CORE_ADDR start_addr, void *obj)
in the index file. */
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);
--
2.39.1
next prev parent reply other threads:[~2023-01-30 15:29 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-27 16:26 [PATCH] " Tom Tromey
2023-01-27 19:58 ` Simon Marchi
2023-01-27 21:15 ` Tom Tromey
2023-01-27 21:18 ` Tom Tromey
2023-01-27 21:20 ` Simon Marchi
2023-01-27 21:26 ` Simon Marchi
2023-01-30 14:15 ` Tom Tromey
2023-01-27 22:00 ` Simon Marchi
2023-01-30 14:26 ` Tom Tromey
2023-01-30 15:22 ` Simon Marchi
2023-01-30 15:29 ` Simon Marchi [this message]
2023-01-30 16:54 ` [PATCH v2] " Tom Tromey
2023-01-30 16:55 ` Simon Marchi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230130152936.41750-1-simon.marchi@efficios.com \
--to=simon.marchi@efficios.com \
--cc=gdb-patches@sourceware.org \
--cc=tromey@adacore.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).