public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
* [binutils-gdb] Add new overload of dwarf5_djb_hash
@ 2022-04-12 15:39 Tom Tromey
0 siblings, 0 replies; only message in thread
From: Tom Tromey @ 2022-04-12 15:39 UTC (permalink / raw)
To: gdb-cvs
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=4e9e4fcda5e820d770369824669d86d3fadcad04
commit 4e9e4fcda5e820d770369824669d86d3fadcad04
Author: Tom Tromey <tom@tromey.com>
Date: Sun Mar 21 11:15:57 2021 -0600
Add new overload of dwarf5_djb_hash
This adds a new overload of dwarf5_djb_hash. This is used in
subsequent patches.
Diff:
---
gdb/dwarf2/index-common.c | 14 ++++++++++++++
gdb/dwarf2/index-common.h | 4 ++++
2 files changed, 18 insertions(+)
diff --git a/gdb/dwarf2/index-common.c b/gdb/dwarf2/index-common.c
index c2bb1c6f78e..d8f9973d6cc 100644
--- a/gdb/dwarf2/index-common.c
+++ b/gdb/dwarf2/index-common.c
@@ -54,3 +54,17 @@ dwarf5_djb_hash (const char *str_)
hash = hash * 33 + tolower (c);
return hash;
}
+
+/* See dwarf-index-common.h. */
+
+uint32_t
+dwarf5_djb_hash (gdb::string_view str)
+{
+ /* Note: tolower here ignores UTF-8, which isn't fully compliant.
+ See http://dwarfstd.org/ShowIssue.php?issue=161027.1. */
+
+ uint32_t hash = 5381;
+ for (char c : str)
+ hash = hash * 33 + tolower (c & 0xff);
+ return hash;
+}
diff --git a/gdb/dwarf2/index-common.h b/gdb/dwarf2/index-common.h
index 049e1d894f1..cbfb88a4e98 100644
--- a/gdb/dwarf2/index-common.h
+++ b/gdb/dwarf2/index-common.h
@@ -52,4 +52,8 @@ hashval_t mapped_index_string_hash (int index_version, const void *p);
uint32_t dwarf5_djb_hash (const char *str_);
+/* Symbol name hashing function as specified by DWARF-5. */
+
+uint32_t dwarf5_djb_hash (gdb::string_view str_);
+
#endif /* DWARF_INDEX_COMMON_H */
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-04-12 15:39 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-12 15:39 [binutils-gdb] Add new overload of dwarf5_djb_hash Tom Tromey
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).