23Expected<std::string> readStreamData(BinaryStream &Stream,
uint64_t Limit) {
24 uint64_t Offset = 0, DataLength = std::min(Limit, Stream.getLength());
26 Result.reserve(DataLength);
27 while (
Offset < DataLength) {
28 ArrayRef<uint8_t>
Data;
29 if (
auto E = Stream.readLongestContiguousChunk(
Offset,
Data))
38class NativeInjectedSource final :
public IPDBInjectedSource {
39 const SrcHeaderBlockEntry &
Entry;
40 const PDBStringTable &Strings;
44 NativeInjectedSource(
const SrcHeaderBlockEntry &Entry,
45 PDBFile &File,
const PDBStringTable &Strings)
49 uint64_t getCodeByteSize()
const override {
return Entry.FileSize; }
53 "InjectedSourceStream should have rejected this");
54 return std::string(Ret);
57 std::string getObjectFileName()
const override {
59 "InjectedSourceStream should have rejected this");
60 return std::string(Ret);
63 std::string getVirtualFileName()
const override {
65 "InjectedSourceStream should have rejected this");
66 return std::string(Ret);
69 uint32_t getCompression()
const override {
return Entry.Compression; }
71 std::string getCode()
const override {
75 "InjectedSourceStream should have rejected this");
76 std::string StreamName = (
"/src/files/" + VName).str();
81 auto ExpectedFileStream =
File.safelyCreateNamedStream(StreamName);
82 if (!ExpectedFileStream) {
84 return "(failed to open data stream)";
87 auto Data = readStreamData(**ExpectedFileStream,
Entry.FileSize);
90 return "(failed to read data)";
101 : File(File), Stream(IJS), Strings(Strings), Cur(Stream.begin()) {}
104 return static_cast<uint32_t>(Stream.size());
107std::unique_ptr<IPDBInjectedSource>
111 return std::make_unique<NativeInjectedSource>(std::next(Stream.begin(),
N)->second,
116 if (Cur == Stream.end())
118 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.