Details | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 14 | pmbaty | 1 | //===- PDBStringTableBuilder.h - PDB String Table Builder -------*- 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 | // This file creates the "/names" stream. |
||
| 10 | // |
||
| 11 | //===----------------------------------------------------------------------===// |
||
| 12 | |||
| 13 | #ifndef LLVM_DEBUGINFO_PDB_NATIVE_PDBSTRINGTABLEBUILDER_H |
||
| 14 | #define LLVM_DEBUGINFO_PDB_NATIVE_PDBSTRINGTABLEBUILDER_H |
||
| 15 | |||
| 16 | #include "llvm/ADT/StringRef.h" |
||
| 17 | #include "llvm/DebugInfo/CodeView/DebugStringTableSubsection.h" |
||
| 18 | #include "llvm/Support/Error.h" |
||
| 19 | #include <cstdint> |
||
| 20 | |||
| 21 | namespace llvm { |
||
| 22 | class BinaryStreamWriter; |
||
| 23 | class WritableBinaryStreamRef; |
||
| 24 | |||
| 25 | namespace msf { |
||
| 26 | struct MSFLayout; |
||
| 27 | } |
||
| 28 | |||
| 29 | namespace pdb { |
||
| 30 | |||
| 31 | class PDBFileBuilder; |
||
| 32 | class PDBStringTableBuilder; |
||
| 33 | |||
| 34 | struct StringTableHashTraits { |
||
| 35 | PDBStringTableBuilder *Table; |
||
| 36 | |||
| 37 | explicit StringTableHashTraits(PDBStringTableBuilder &Table); |
||
| 38 | uint32_t hashLookupKey(StringRef S) const; |
||
| 39 | StringRef storageKeyToLookupKey(uint32_t Offset) const; |
||
| 40 | uint32_t lookupKeyToStorageKey(StringRef S); |
||
| 41 | }; |
||
| 42 | |||
| 43 | class PDBStringTableBuilder { |
||
| 44 | public: |
||
| 45 | // If string S does not exist in the string table, insert it. |
||
| 46 | // Returns the ID for S. |
||
| 47 | uint32_t insert(StringRef S); |
||
| 48 | |||
| 49 | uint32_t getIdForString(StringRef S) const; |
||
| 50 | StringRef getStringForId(uint32_t Id) const; |
||
| 51 | |||
| 52 | uint32_t calculateSerializedSize() const; |
||
| 53 | Error commit(BinaryStreamWriter &Writer) const; |
||
| 54 | |||
| 55 | void setStrings(const codeview::DebugStringTableSubsection &Strings); |
||
| 56 | |||
| 57 | private: |
||
| 58 | uint32_t calculateHashTableSize() const; |
||
| 59 | Error writeHeader(BinaryStreamWriter &Writer) const; |
||
| 60 | Error writeStrings(BinaryStreamWriter &Writer) const; |
||
| 61 | Error writeHashTable(BinaryStreamWriter &Writer) const; |
||
| 62 | Error writeEpilogue(BinaryStreamWriter &Writer) const; |
||
| 63 | |||
| 64 | codeview::DebugStringTableSubsection Strings; |
||
| 65 | }; |
||
| 66 | |||
| 67 | } // end namespace pdb |
||
| 68 | } // end namespace llvm |
||
| 69 | |||
| 70 | #endif // LLVM_DEBUGINFO_PDB_NATIVE_PDBSTRINGTABLEBUILDER_H |