[prev in list] [next in list] [prev in thread] [next in thread]
List: gdb-cvs
Subject: [binutils-gdb] Remove unusual use of core_addr_eq and core_addr_hash
From: Tom Tromey via Gdb-cvs <gdb-cvs () sourceware ! org>
Date: 2021-12-29 17:29:36
Message-ID: 20211229172936.A9BDD3858D35 () sourceware ! org
[Download RAW message or body]
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=ba0084966cfee307631aba6d0f052a39ad773909
commit ba0084966cfee307631aba6d0f052a39ad773909
Author: Tom Tromey <tom@tromey.com>
Date: Wed Dec 22 10:30:16 2021 -0700
Remove unusual use of core_addr_eq and core_addr_hash
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, so this patch
removes them.
Diff:
---
gdb/gdbtypes.h | 4 ++--
gdb/utils.c | 21 ---------------------
gdb/utils.h | 4 ----
3 files changed, 2 insertions(+), 27 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
diff --git a/gdb/utils.c b/gdb/utils.c
index 620ae9f3729..eba1acbc8f6 100644
--- a/gdb/utils.c
+++ b/gdb/utils.c
@@ -2837,27 +2837,6 @@ print_core_address (struct gdbarch *gdbarch, CORE_ADDR address)
return hex_string_custom (address, 16);
}
-/* Callback hash_f for htab_create_alloc or htab_create_alloc_ex. */
-
-hashval_t
-core_addr_hash (const void *ap)
-{
- const CORE_ADDR *addrp = (const CORE_ADDR *) ap;
-
- return *addrp;
-}
-
-/* Callback eq_f for htab_create_alloc or htab_create_alloc_ex. */
-
-int
-core_addr_eq (const void *ap, const void *bp)
-{
- const CORE_ADDR *addr_ap = (const CORE_ADDR *) ap;
- const CORE_ADDR *addr_bp = (const CORE_ADDR *) bp;
-
- return *addr_ap == *addr_bp;
-}
-
/* Convert a string back into a CORE_ADDR. */
CORE_ADDR
string_to_core_addr (const char *my_string)
diff --git a/gdb/utils.h b/gdb/utils.h
index d86b5645c7b..54cf090974a 100644
--- a/gdb/utils.h
+++ b/gdb/utils.h
@@ -541,10 +541,6 @@ extern const char *paddress (struct gdbarch *gdbarch, CORE_ADDR addr);
extern const char *print_core_address (struct gdbarch *gdbarch,
CORE_ADDR address);
-/* Callback hash_f and eq_f for htab_create_alloc or htab_create_alloc_ex. */
-extern hashval_t core_addr_hash (const void *ap);
-extern int core_addr_eq (const void *ap, const void *bp);
-
extern CORE_ADDR string_to_core_addr (const char *my_string);
extern void fprintf_symbol_filtered (struct ui_file *, const char *,
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic