gdb/dwarf: implement section_and_offset comparison using operator==

This was suggested during review.

Change-Id: Iabe893f5b7ee1c4dce9655cbc323e3640e061aa3
Approved-By: Tom Tromey <tom@tromey.com>
This commit is contained in:
Simon Marchi 2026-03-10 13:44:57 -04:00 committed by Simon Marchi
parent 34909f3a1d
commit 06a03c076c

View file

@ -122,6 +122,10 @@ using dwarf2_section_info_up = std::unique_ptr<dwarf2_section_info>;
struct section_and_offset
{
friend bool operator== (const section_and_offset &lhs,
const section_and_offset &rhs) noexcept
{ return lhs.section == rhs.section && lhs.offset == rhs.offset; }
const dwarf2_section_info *section;
sect_offset offset;
};
@ -141,18 +145,9 @@ struct section_and_offset_hash
}
};
/* Equality function for section_and_offset. */
struct section_and_offset_eq
{
bool operator() (const section_and_offset &a,
const section_and_offset &b) const noexcept
{ return a.section == b.section && a.offset == b.offset; }
};
template<typename Value>
using unordered_section_and_offset_map
= gdb::unordered_map<section_and_offset, Value,
section_and_offset_hash, section_and_offset_eq>;
section_and_offset_hash>;
#endif /* GDB_DWARF2_SECTION_H */