From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2126) id D38513858C27; Tue, 12 Apr 2022 15:39:50 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D38513858C27 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Tom Tromey To: gdb-cvs@sourceware.org Subject: [binutils-gdb] Add new overload of dwarf5_djb_hash X-Act-Checkin: binutils-gdb X-Git-Author: Tom Tromey X-Git-Refname: refs/heads/master X-Git-Oldrev: b2bc564fe817f857b4915903f16026472acfbdcc X-Git-Newrev: 4e9e4fcda5e820d770369824669d86d3fadcad04 Message-Id: <20220412153950.D38513858C27@sourceware.org> Date: Tue, 12 Apr 2022 15:39:50 +0000 (GMT) X-BeenThere: gdb-cvs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 12 Apr 2022 15:39:50 -0000 https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D4e9e4fcda5e8= 20d770369824669d86d3fadcad04 commit 4e9e4fcda5e820d770369824669d86d3fadcad04 Author: Tom Tromey Date: Sun Mar 21 11:15:57 2021 -0600 Add new overload of dwarf5_djb_hash =20 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 =3D 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=3D161027.1. */ + + uint32_t hash =3D 5381; + for (char c : str) + hash =3D 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, co= nst void *p); =20 uint32_t dwarf5_djb_hash (const char *str_); =20 +/* Symbol name hashing function as specified by DWARF-5. */ + +uint32_t dwarf5_djb_hash (gdb::string_view str_); + #endif /* DWARF_INDEX_COMMON_H */