xref: /netbsd-src/external/gpl3/gdb.old/dist/gdb/dwarf2/index-common.h (revision 6881a4007f077b54e5f51159c52b9b25f57deb0d)
17d62b00eSchristos /* Things needed for both reading and writing DWARF indices.
27d62b00eSchristos 
3*6881a400Schristos    Copyright (C) 1994-2023 Free Software Foundation, Inc.
47d62b00eSchristos 
57d62b00eSchristos    This file is part of GDB.
67d62b00eSchristos 
77d62b00eSchristos    This program is free software; you can redistribute it and/or modify
87d62b00eSchristos    it under the terms of the GNU General Public License as published by
97d62b00eSchristos    the Free Software Foundation; either version 3 of the License, or
107d62b00eSchristos    (at your option) any later version.
117d62b00eSchristos 
127d62b00eSchristos    This program is distributed in the hope that it will be useful,
137d62b00eSchristos    but WITHOUT ANY WARRANTY; without even the implied warranty of
147d62b00eSchristos    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
157d62b00eSchristos    GNU General Public License for more details.
167d62b00eSchristos 
177d62b00eSchristos    You should have received a copy of the GNU General Public License
187d62b00eSchristos    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
197d62b00eSchristos 
207d62b00eSchristos #ifndef DWARF_INDEX_COMMON_H
217d62b00eSchristos #define DWARF_INDEX_COMMON_H
227d62b00eSchristos 
237d62b00eSchristos /* The suffix for an index file.  */
247d62b00eSchristos #define INDEX4_SUFFIX ".gdb-index"
257d62b00eSchristos #define INDEX5_SUFFIX ".debug_names"
267d62b00eSchristos #define DEBUG_STR_SUFFIX ".debug_str"
277d62b00eSchristos 
287d62b00eSchristos /* All offsets in the index are of this type.  It must be
297d62b00eSchristos    architecture-independent.  */
307d62b00eSchristos typedef uint32_t offset_type;
317d62b00eSchristos 
32*6881a400Schristos /* Unpack a 32-bit little-endian value.  */
337d62b00eSchristos 
347d62b00eSchristos static inline offset_type
35*6881a400Schristos gdb_index_unpack (const gdb_byte *value)
367d62b00eSchristos {
37*6881a400Schristos   return (offset_type) extract_unsigned_integer (value, sizeof (offset_type),
38*6881a400Schristos 						 BFD_ENDIAN_LITTLE);
397d62b00eSchristos }
407d62b00eSchristos 
417d62b00eSchristos /* The hash function for strings in the mapped index.  This is the same as
427d62b00eSchristos    SYMBOL_HASH_NEXT, but we keep a separate copy to maintain control over the
437d62b00eSchristos    implementation.  This is necessary because the hash function is tied to the
447d62b00eSchristos    format of the mapped index file.  The hash values do not have to match with
457d62b00eSchristos    SYMBOL_HASH_NEXT.
467d62b00eSchristos 
477d62b00eSchristos    Use INT_MAX for INDEX_VERSION if you generate the current index format.  */
487d62b00eSchristos 
497d62b00eSchristos hashval_t mapped_index_string_hash (int index_version, const void *p);
507d62b00eSchristos 
517d62b00eSchristos /* Symbol name hashing function as specified by DWARF-5.  */
527d62b00eSchristos 
537d62b00eSchristos uint32_t dwarf5_djb_hash (const char *str_);
547d62b00eSchristos 
55*6881a400Schristos /* Symbol name hashing function as specified by DWARF-5.  */
56*6881a400Schristos 
57*6881a400Schristos uint32_t dwarf5_djb_hash (gdb::string_view str_);
58*6881a400Schristos 
597d62b00eSchristos #endif /* DWARF_INDEX_COMMON_H */
60