From: Guinevere Larsen Date: Tue, 28 Jan 2025 18:45:10 +0000 (-0300) Subject: gdb: move some stabs functions to gdb/buildsym-legacy.h X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=31da5c3604ff991868cc1da7593502993c41af27;p=thirdparty%2Fbinutils-gdb.git gdb: move some stabs functions to gdb/buildsym-legacy.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 location that looked most reasonable was gdb/buildsym-legacy. No change in behavior is expected after this commit. Approved-By: Tom Tromey --- diff --git a/gdb/buildsym-legacy.h b/gdb/buildsym-legacy.h index 4ae8e1a7b66..06d39e8529f 100644 --- a/gdb/buildsym-legacy.h +++ b/gdb/buildsym-legacy.h @@ -21,6 +21,16 @@ #include "buildsym.h" +/* 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; +} + /* This module provides definitions used for creating and adding to the symbol table. These routines are called from various symbol- file-reading routines. This file holds the legacy API, which diff --git a/gdb/stabsread.c b/gdb/stabsread.c index c7fc626e31c..05a7c27c5df 100644 --- a/gdb/stabsread.c +++ b/gdb/stabsread.c @@ -7190,14 +7190,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. */ INIT_GDB_FILE (stabsread) diff --git a/gdb/stabsread.h b/gdb/stabsread.h index 15f73266e1c..1c9ce854dff 100644 --- a/gdb/stabsread.h +++ b/gdb/stabsread.h @@ -19,6 +19,8 @@ #ifndef GDB_STABSREAD_H #define GDB_STABSREAD_H +#include "buildsym-legacy.h" + struct objfile; struct legacy_psymtab; enum language; @@ -26,13 +28,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;