xref: /freebsd/contrib/llvm-project/llvm/include/llvm/DebugInfo/PDB/Native/PDBStringTable.h (revision 700637cbb5e582861067a11aaca4d053546871d2)
1 //===- PDBStringTable.h - PDB String Table -----------------------*- C++-*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #ifndef LLVM_DEBUGINFO_PDB_NATIVE_PDBSTRINGTABLE_H
10 #define LLVM_DEBUGINFO_PDB_NATIVE_PDBSTRINGTABLE_H
11 
12 #include "llvm/ADT/StringRef.h"
13 #include "llvm/DebugInfo/CodeView/DebugStringTableSubsection.h"
14 #include "llvm/Support/BinaryStreamArray.h"
15 #include "llvm/Support/Compiler.h"
16 #include "llvm/Support/Endian.h"
17 #include "llvm/Support/Error.h"
18 #include <cstdint>
19 
20 namespace llvm {
21 class BinaryStreamReader;
22 
23 namespace pdb {
24 
25 struct PDBStringTableHeader;
26 
27 class PDBStringTable {
28 public:
29   LLVM_ABI Error reload(BinaryStreamReader &Reader);
30 
31   LLVM_ABI uint32_t getByteSize() const;
32   LLVM_ABI uint32_t getNameCount() const;
33   LLVM_ABI uint32_t getHashVersion() const;
34   LLVM_ABI uint32_t getSignature() const;
35 
36   LLVM_ABI Expected<StringRef> getStringForID(uint32_t ID) const;
37   LLVM_ABI Expected<uint32_t> getIDForString(StringRef Str) const;
38 
39   LLVM_ABI FixedStreamArray<support::ulittle32_t> name_ids() const;
40 
41   LLVM_ABI const codeview::DebugStringTableSubsectionRef &
42   getStringTable() const;
43 
44 private:
45   Error readHeader(BinaryStreamReader &Reader);
46   Error readStrings(BinaryStreamReader &Reader);
47   Error readHashTable(BinaryStreamReader &Reader);
48   Error readEpilogue(BinaryStreamReader &Reader);
49 
50   const PDBStringTableHeader *Header = nullptr;
51   codeview::DebugStringTableSubsectionRef Strings;
52   FixedStreamArray<support::ulittle32_t> IDs;
53   uint32_t NameCount = 0;
54 };
55 
56 } // end namespace pdb
57 } // end namespace llvm
58 
59 #endif // LLVM_DEBUGINFO_PDB_NATIVE_PDBSTRINGTABLE_H
60