LLVM: lib/DebugInfo/PDB/Native/NativeEnumInjectedSources.cpp Source File (original) (raw)

1

2

3

4

5

6

7

8

10

16

17namespace llvm {

18namespace pdb {

19

20namespace {

21

22Expectedstd::string readStreamData(BinaryStream &Stream, uint64_t Limit) {

23 uint64_t Offset = 0, DataLength = std::min(Limit, Stream.getLength());

25 Result.reserve(DataLength);

26 while (Offset < DataLength) {

27 ArrayRef<uint8_t> Data;

28 if (auto E = Stream.readLongestContiguousChunk(Offset, Data))

29 return std::move(E);

33 }

35}

36

38 const SrcHeaderBlockEntry &Entry;

39 const PDBStringTable &Strings;

40 PDBFile &File;

41

42public:

43 NativeInjectedSource(const SrcHeaderBlockEntry &Entry,

44 PDBFile &File, const PDBStringTable &Strings)

45 : Entry(Entry), Strings(Strings), File(File) {}

46

47 uint32_t getCrc32() const override { return Entry.CRC; }

48 uint64_t getCodeByteSize() const override { return Entry.FileSize; }

49

50 std::string getFileName() const override {

51 StringRef Ret = cantFail(Strings.getStringForID(Entry.FileNI),

52 "InjectedSourceStream should have rejected this");

53 return std::string(Ret);

54 }

55

56 std::string getObjectFileName() const override {

57 StringRef Ret = cantFail(Strings.getStringForID(Entry.ObjNI),

58 "InjectedSourceStream should have rejected this");

59 return std::string(Ret);

60 }

61

62 std::string getVirtualFileName() const override {

63 StringRef Ret = cantFail(Strings.getStringForID(Entry.VFileNI),

64 "InjectedSourceStream should have rejected this");

65 return std::string(Ret);

66 }

67

68 uint32_t getCompression() const override { return Entry.Compression; }

69

70 std::string getCode() const override {

71

72 StringRef VName =

73 cantFail(Strings.getStringForID(Entry.VFileNI),

74 "InjectedSourceStream should have rejected this");

75 std::string StreamName = ("/src/files/" + VName).str();

76

77

78

79

80 auto ExpectedFileStream = File.safelyCreateNamedStream(StreamName);

81 if (!ExpectedFileStream) {

83 return "(failed to open data stream)";

84 }

85

86 auto Data = readStreamData(**ExpectedFileStream, Entry.FileSize);

89 return "(failed to read data)";

90 }

92 }

93};

94

95}

96

100 : File(File), Stream(IJS), Strings(Strings), Cur(Stream.begin()) {}

101

103 return static_cast<uint32_t>(Stream.size());

104}

105

106std::unique_ptr

109 return nullptr;

110 return std::make_unique(std::next(Stream.begin(), N)->second,

111 File, Strings);

112}

113

115 if (Cur == Stream.end())

116 return nullptr;

117 return std::make_unique((Cur++)->second, File, Strings);

118}

119

121

122}

123}

static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")

static Expected< StringRef > getFileName(const DebugStringTableSubsectionRef &Strings, const DebugChecksumsSubsectionRef &Checksums, uint32_t FileID)

IPDBInjectedSource defines an interface used to represent source files which were injected directly i...

void reset() override

Definition NativeEnumInjectedSources.cpp:120

std::unique_ptr< IPDBInjectedSource > getChildAtIndex(uint32_t Index) const override

Definition NativeEnumInjectedSources.cpp:107

NativeEnumInjectedSources(PDBFile &File, const InjectedSourceStream &IJS, const PDBStringTable &Strings)

Definition NativeEnumInjectedSources.cpp:97

std::unique_ptr< IPDBInjectedSource > getNext() override

Definition NativeEnumInjectedSources.cpp:114

uint32_t getChildCount() const override

Definition NativeEnumInjectedSources.cpp:102

This is an optimization pass for GlobalISel generic memory operations.

void cantFail(Error Err, const char *Msg=nullptr)

Report a fatal error if Err is a failure value.

void consumeError(Error Err)

Consume a Error without doing anything.

StringRef toStringRef(bool B)

Construct a string ref from a boolean.