22Expected<std::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))
37class NativeInjectedSource final :
public IPDBInjectedSource {
38 const SrcHeaderBlockEntry &
Entry;
39 const PDBStringTable &Strings;
43 NativeInjectedSource(
const SrcHeaderBlockEntry &Entry,
44 PDBFile &File,
const PDBStringTable &Strings)
48 uint64_t getCodeByteSize()
const override {
return Entry.FileSize; }
52 "InjectedSourceStream should have rejected this");
53 return std::string(Ret);
56 std::string getObjectFileName()
const override {
58 "InjectedSourceStream should have rejected this");
59 return std::string(Ret);
62 std::string getVirtualFileName()
const override {
64 "InjectedSourceStream should have rejected this");
65 return std::string(Ret);
68 uint32_t getCompression()
const override {
return Entry.Compression; }
70 std::string getCode()
const override {
74 "InjectedSourceStream should have rejected this");
75 std::string StreamName = (
"/src/files/" + VName).str();
80 auto ExpectedFileStream =
File.safelyCreateNamedStream(StreamName);
81 if (!ExpectedFileStream) {
83 return "(failed to open data stream)";
86 auto Data = readStreamData(**ExpectedFileStream,
Entry.FileSize);
89 return "(failed to read data)";
100 : File(File), Stream(IJS), Strings(Strings), Cur(Stream.begin()) {}
103 return static_cast<uint32_t>(Stream.size());
106std::unique_ptr<IPDBInjectedSource>
110 return std::make_unique<NativeInjectedSource>(std::next(Stream.begin(),
N)->second,
115 if (Cur == Stream.end())
117 return std::make_unique<NativeInjectedSource>((Cur++)->second, File, Strings);
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
static Expected< StringRef > getFileName(const DebugStringTableSubsectionRef &Strings, const DebugChecksumsSubsectionRef &Checksums, uint32_t FileID)
std::unique_ptr< IPDBInjectedSource > getChildAtIndex(uint32_t Index) const override
NativeEnumInjectedSources(PDBFile &File, const InjectedSourceStream &IJS, const PDBStringTable &Strings)
std::unique_ptr< IPDBInjectedSource > getNext() override
uint32_t getChildCount() const override
StringRef toStringRef(const std::optional< DWARFFormValue > &V, StringRef Default={})
Take an optional DWARFFormValue and try to extract a string value from it.
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.