File indexing completed on 2026-05-10 08:43:39
0001
0002
0003
0004
0005
0006
0007
0008
0009 #ifndef LLVM_DEBUGINFO_CODEVIEW_DEBUGSTRINGTABLESUBSECTION_H
0010 #define LLVM_DEBUGINFO_CODEVIEW_DEBUGSTRINGTABLESUBSECTION_H
0011
0012 #include "llvm/ADT/DenseMap.h"
0013 #include "llvm/ADT/StringMap.h"
0014 #include "llvm/ADT/StringRef.h"
0015 #include "llvm/DebugInfo/CodeView/CodeView.h"
0016 #include "llvm/DebugInfo/CodeView/DebugSubsection.h"
0017 #include "llvm/Support/BinaryStreamRef.h"
0018 #include "llvm/Support/Error.h"
0019 #include <cstdint>
0020
0021 namespace llvm {
0022
0023 class BinaryStreamReader;
0024
0025 namespace codeview {
0026
0027
0028
0029
0030
0031 class DebugStringTableSubsectionRef : public DebugSubsectionRef {
0032 public:
0033 DebugStringTableSubsectionRef();
0034
0035 static bool classof(const DebugSubsectionRef *S) {
0036 return S->kind() == DebugSubsectionKind::StringTable;
0037 }
0038
0039 Error initialize(BinaryStreamRef Contents);
0040 Error initialize(BinaryStreamReader &Reader);
0041
0042 Expected<StringRef> getString(uint32_t Offset) const;
0043
0044 bool valid() const { return Stream.valid(); }
0045
0046 BinaryStreamRef getBuffer() const { return Stream; }
0047
0048 private:
0049 BinaryStreamRef Stream;
0050 };
0051
0052
0053
0054
0055
0056 class DebugStringTableSubsection : public DebugSubsection {
0057 public:
0058 DebugStringTableSubsection();
0059
0060 static bool classof(const DebugSubsection *S) {
0061 return S->kind() == DebugSubsectionKind::StringTable;
0062 }
0063
0064
0065
0066 uint32_t insert(StringRef S);
0067
0068
0069 uint32_t getIdForString(StringRef S) const;
0070
0071 StringRef getStringForId(uint32_t Id) const;
0072
0073 uint32_t calculateSerializedSize() const override;
0074 Error commit(BinaryStreamWriter &Writer) const override;
0075
0076 uint32_t size() const;
0077
0078 StringMap<uint32_t>::const_iterator begin() const {
0079 return StringToId.begin();
0080 }
0081
0082 StringMap<uint32_t>::const_iterator end() const { return StringToId.end(); }
0083
0084 std::vector<uint32_t> sortedIds() const;
0085
0086 private:
0087 DenseMap<uint32_t, StringRef> IdToString;
0088 StringMap<uint32_t> StringToId;
0089 uint32_t StringSize = 1;
0090 };
0091
0092 }
0093
0094 }
0095
0096 #endif