From: Simon Marchi Date: Mon, 4 Nov 2024 18:27:33 +0000 (-0500) Subject: gdb: constification around abbrev_table_cache and abbrev_table X-Git-Tag: gdb-16-branchpoint~323 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=c9e2e9992adfcd520caa920f8e90b8339d40270b;p=thirdparty%2Fbinutils-gdb.git gdb: constification around abbrev_table_cache and abbrev_table Make `abbrev_table_cache::find` const, make it return a pointer to `const abbrev_table`, adjust the fallouts. Make `cooked_index_storage::get_abbrev_table_cache` const, make itreturn a pointer to const `abbrev_table_cache`. Change-Id: If63b4b3a4c253f3bd640b13bce4a854eb2d75ece Approved-By: Tom Tromey --- diff --git a/gdb/dwarf2/abbrev-table-cache.h b/gdb/dwarf2/abbrev-table-cache.h index 4f9111c51f0..bcec005f2c9 100644 --- a/gdb/dwarf2/abbrev-table-cache.h +++ b/gdb/dwarf2/abbrev-table-cache.h @@ -32,7 +32,8 @@ public: /* Find an abbrev table coming from the abbrev section SECTION at offset OFFSET. Return the table, or nullptr if it has not yet been registered. */ - abbrev_table *find (struct dwarf2_section_info *section, sect_offset offset) + const abbrev_table *find (dwarf2_section_info *section, + sect_offset offset) const { search_key key = { section, offset }; diff --git a/gdb/dwarf2/cooked-index.h b/gdb/dwarf2/cooked-index.h index 4b781529c53..6f9311bd108 100644 --- a/gdb/dwarf2/cooked-index.h +++ b/gdb/dwarf2/cooked-index.h @@ -377,7 +377,7 @@ public: DISABLE_COPY_AND_ASSIGN (cooked_index_storage); /* Return the current abbrev table_cache. */ - abbrev_table_cache *get_abbrev_table_cache () + const abbrev_table_cache *get_abbrev_table_cache () const { return &m_abbrev_table_cache; } /* Return the DIE reader corresponding to PER_CU. If no such reader diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index 017a15f4035..b0b2b51fe5f 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -573,7 +573,7 @@ struct die_reader_specs const gdb_byte *buffer_end; /* The abbreviation table to use when reading the DIEs. */ - struct abbrev_table *abbrev_table; + const struct abbrev_table *abbrev_table; }; /* A subclass of die_reader_specs that holds storage and has complex @@ -585,10 +585,10 @@ public: cutu_reader (dwarf2_per_cu_data *this_cu, dwarf2_per_objfile *per_objfile, - struct abbrev_table *abbrev_table, + const struct abbrev_table *abbrev_table, dwarf2_cu *existing_cu, bool skip_partial, - abbrev_table_cache *cache = nullptr); + const abbrev_table_cache *cache = nullptr); explicit cutu_reader (struct dwarf2_per_cu_data *this_cu, dwarf2_per_objfile *per_objfile, @@ -3710,7 +3710,7 @@ init_cu_die_reader (struct die_reader_specs *reader, struct dwarf2_cu *cu, struct dwarf2_section_info *section, struct dwo_file *dwo_file, - struct abbrev_table *abbrev_table) + const abbrev_table *abbrev_table) { gdb_assert (section->readin && section->buffer != NULL); reader->abfd = section->get_bfd_owner (); @@ -4009,10 +4009,10 @@ cutu_reader::init_tu_and_read_dwo_dies (dwarf2_per_cu_data *this_cu, cutu_reader::cutu_reader (dwarf2_per_cu_data *this_cu, dwarf2_per_objfile *per_objfile, - struct abbrev_table *abbrev_table, + const struct abbrev_table *abbrev_table, dwarf2_cu *existing_cu, bool skip_partial, - abbrev_table_cache *cache) + const abbrev_table_cache *cache) : die_reader_specs {}, m_this_cu (this_cu) {