From: Tom Tromey Date: Thu, 14 Dec 2023 20:13:59 +0000 (-0700) Subject: Use unrelocated_addr in dwarf2_base_index_functions::find_per_cu X-Git-Tag: binutils-2_42~155 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bdb4b8036fd60438ac614d8a8326a17fa5f4ebe7;p=thirdparty%2Fbinutils-gdb.git Use unrelocated_addr in dwarf2_base_index_functions::find_per_cu dwarf2_base_index_functions::find_per_cu is documented as using an unrelocated address. This patch changes the interface to use the unrelocated_addr type, just to be a bit more type-safe. Regression tested on x86-64 Fedora 38. --- diff --git a/gdb/dwarf2/cooked-index.c b/gdb/dwarf2/cooked-index.c index fabffc75d92..661edf5f06e 100644 --- a/gdb/dwarf2/cooked-index.c +++ b/gdb/dwarf2/cooked-index.c @@ -522,7 +522,7 @@ cooked_index::~cooked_index () /* See cooked-index.h. */ dwarf2_per_cu_data * -cooked_index::lookup (CORE_ADDR addr) +cooked_index::lookup (unrelocated_addr addr) { /* Ensure that the address maps are ready. */ wait (cooked_state::MAIN_AVAILABLE, true); diff --git a/gdb/dwarf2/cooked-index.h b/gdb/dwarf2/cooked-index.h index 909e4c08e3a..b14930d558f 100644 --- a/gdb/dwarf2/cooked-index.h +++ b/gdb/dwarf2/cooked-index.h @@ -309,9 +309,10 @@ private: /* Look up ADDR in the address map, and return either the corresponding CU, or nullptr if the address could not be found. */ - dwarf2_per_cu_data *lookup (CORE_ADDR addr) + dwarf2_per_cu_data *lookup (unrelocated_addr addr) { - return static_cast (m_addrmap->find (addr)); + return (static_cast + (m_addrmap->find ((CORE_ADDR) addr))); } /* Create a new cooked_index_entry and register it with this object. @@ -625,7 +626,7 @@ public: /* Look up ADDR in the address map, and return either the corresponding CU, or nullptr if the address could not be found. */ - dwarf2_per_cu_data *lookup (CORE_ADDR addr); + dwarf2_per_cu_data *lookup (unrelocated_addr addr); /* Return a new vector of all the addrmaps used by all the indexes held by this object. */ diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index 5c4bbbd0914..e055371dc6a 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -2993,12 +2993,12 @@ recursively_find_pc_sect_compunit_symtab (struct compunit_symtab *cust, dwarf2_per_cu_data * dwarf2_base_index_functions::find_per_cu (dwarf2_per_bfd *per_bfd, - CORE_ADDR adjusted_pc) + unrelocated_addr adjusted_pc) { if (per_bfd->index_addrmap == nullptr) return nullptr; - void *obj = per_bfd->index_addrmap->find (adjusted_pc); + void *obj = per_bfd->index_addrmap->find ((CORE_ADDR) adjusted_pc); return static_cast (obj); } @@ -3015,8 +3015,8 @@ dwarf2_base_index_functions::find_pc_sect_compunit_symtab dwarf2_per_objfile *per_objfile = get_dwarf2_per_objfile (objfile); CORE_ADDR baseaddr = objfile->text_section_offset (); - struct dwarf2_per_cu_data *data = find_per_cu (per_objfile->per_bfd, - pc - baseaddr); + struct dwarf2_per_cu_data *data + = find_per_cu (per_objfile->per_bfd, (unrelocated_addr) (pc - baseaddr)); if (data == nullptr) return nullptr; @@ -16659,7 +16659,7 @@ struct cooked_index_functions : public dwarf2_base_index_functions } dwarf2_per_cu_data *find_per_cu (dwarf2_per_bfd *per_bfd, - CORE_ADDR adjusted_pc) override; + unrelocated_addr adjusted_pc) override; struct compunit_symtab *find_compunit_symtab_by_address (struct objfile *objfile, CORE_ADDR address) override; @@ -16739,7 +16739,7 @@ struct cooked_index_functions : public dwarf2_base_index_functions dwarf2_per_cu_data * cooked_index_functions::find_per_cu (dwarf2_per_bfd *per_bfd, - CORE_ADDR adjusted_pc) + unrelocated_addr adjusted_pc) { cooked_index *table = (gdb::checked_static_cast @@ -16758,7 +16758,8 @@ cooked_index_functions::find_compunit_symtab_by_address cooked_index *table = wait (objfile, true); CORE_ADDR baseaddr = objfile->data_section_offset (); - dwarf2_per_cu_data *per_cu = table->lookup (address - baseaddr); + dwarf2_per_cu_data *per_cu + = table->lookup ((unrelocated_addr) (address - baseaddr)); if (per_cu == nullptr) return nullptr; diff --git a/gdb/dwarf2/read.h b/gdb/dwarf2/read.h index 493d64acf68..d6631d45a54 100644 --- a/gdb/dwarf2/read.h +++ b/gdb/dwarf2/read.h @@ -893,7 +893,7 @@ struct dwarf2_base_index_functions : public quick_symbol_functions /* A helper function that finds the per-cu object from an "adjusted" PC -- a PC with the base text offset removed. */ virtual dwarf2_per_cu_data *find_per_cu (dwarf2_per_bfd *per_bfd, - CORE_ADDR adjusted_pc); + unrelocated_addr adjusted_pc); struct compunit_symtab *find_pc_sect_compunit_symtab (struct objfile *objfile, struct bound_minimal_symbol msymbol,