From: Guinevere Larsen Date: Tue, 28 Jan 2025 18:45:10 +0000 (-0300) Subject: gdb: move some stabs functions to gdbsupport/common-utils.h X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=61540d058308ac8410607cd8b079e655c41d8423;p=thirdparty%2Fbinutils-gdb.git gdb: move some stabs functions to gdbsupport/common-utils.h The gdb/stabsread.h and .c files define 2 things that, while originally intended only for stabs reading, actually end up being used for coff, ecoff and maybe more debuginfo formats. That is the function "hashname", and the macro HASHSIZE. Both are used for small hashtables when reading some symbols with incomplete information. With the upcoming removal of stabs code, this code should be moved somewhere, and the only location that looked mildly reasonable was gdbsupport/common-utils. No change is expected after this commit. --- diff --git a/gdb/stabsread.c b/gdb/stabsread.c index e4798203fbb..485edd97609 100644 --- a/gdb/stabsread.c +++ b/gdb/stabsread.c @@ -7188,14 +7188,6 @@ find_name_end (const char *name) } } -/* See stabsread.h. */ - -int -hashname (const char *name) -{ - return fast_hash (name, strlen (name)) % HASHSIZE; -} - /* Initializer for this module. */ void _initialize_stabsread (); diff --git a/gdb/stabsread.h b/gdb/stabsread.h index a88b593b443..a54817da833 100644 --- a/gdb/stabsread.h +++ b/gdb/stabsread.h @@ -26,13 +26,6 @@ enum language; /* Definitions, prototypes, etc for stabs debugging format support functions. */ -#define HASHSIZE 127 /* Size of things hashed via - hashname(). */ - -/* Compute a small integer hash code for the given name. */ - -extern int hashname (const char *name); - /* Count symbols as they are processed, for error messages. */ extern unsigned int symnum; diff --git a/gdbsupport/common-utils.h b/gdbsupport/common-utils.h index 114342d845d..aaf08cbd576 100644 --- a/gdbsupport/common-utils.h +++ b/gdbsupport/common-utils.h @@ -240,6 +240,16 @@ fast_hash (const void *ptr, size_t len, unsigned int start_value = 0) #endif } +/* Legacy hash for symbol names used for several debuginfo formats. */ + +#define HASHSIZE 127 + +static inline int +hashname (const char *name) +{ + return fast_hash (name, strlen (name)) % HASHSIZE; +} + namespace gdb {