[PATCH] Remove unusual use of core_addr_eq and core_addr_hash

Tom Tromey tom@tromey.com
Thu Dec 23 22:22:26 GMT 2021


gdbtypes.h uses core_addr_eq and core_addr_hash in a weird way: taking
the address of a member and then passing this (as a void*) to these
functions.

It seems better to simply inline the ordinary code here.  CORE_ADDR is
a scalar so it can be directly compared, and the identity hash
function seems safe to assume as well.

After this, core_addr_eq and core_addr_hash are unused.  I wasn't sure
whether it makes sense to remove them, so I've left them in.
---
 gdb/gdbtypes.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h
index 5284a4c3a03..35549a84620 100644
--- a/gdb/gdbtypes.h
+++ b/gdb/gdbtypes.h
@@ -1910,13 +1910,13 @@ struct call_site
     static int
     eq (const call_site *a, const call_site *b)
     {
-      return core_addr_eq (&a->m_unrelocated_pc, &b->m_unrelocated_pc);
+      return a->m_unrelocated_pc == b->m_unrelocated_pc;
     }
 
     static hashval_t
     hash (const call_site *a)
     {
-      return core_addr_hash (&a->m_unrelocated_pc);
+      return a->m_unrelocated_pc;
     }
 
     static int
-- 
2.31.1



More information about the Gdb-patches mailing list