const NamedStreamMap &getNamedStreams() const;
+ BinarySubstreamRef getNamedStreamsBuffer() const;
+
uint32_t getNamedStreamIndex(llvm::StringRef Name) const;
iterator_range<StringMapConstIterator<uint32_t>> named_streams() const;
// universally unique.
PDB_UniqueId Guid;
+ BinarySubstreamRef SubNamedStreams;
+
std::vector<PdbRaw_FeatureSig> FeatureSignatures;
PdbRaw_Features Features = PdbFeatureNone;
uint32_t NewOffset = Reader.getOffset();
NamedStreamMapByteSize = NewOffset - Offset;
+ Reader.setOffset(Offset);
+ if (auto EC = Reader.readSubstream(SubNamedStreams, NamedStreamMapByteSize))
+ return EC;
+
bool Stop = false;
while (!Stop && !Reader.empty()) {
PdbRaw_FeatureSig Sig;
const NamedStreamMap &InfoStream::getNamedStreams() const {
return NamedStreams;
}
+
+BinarySubstreamRef InfoStream::getNamedStreamsBuffer() const {
+ return SubNamedStreams;
+}
; RUN: not llvm-pdbutil bytes -byte-range=100-20 %p/Inputs/empty.pdb 2>&1 | FileCheck --check-prefix=INVALID %s\r
; RUN: not llvm-pdbutil bytes -byte-range=100000-200000 %p/Inputs/empty.pdb 2>&1 | FileCheck --check-prefix=INVALID-RANGE %s\r
\r
+; RUN: llvm-pdbutil bytes -name-map %p/Inputs/empty.pdb | FileCheck --check-prefix=NAME-MAP %s\r
+\r
\r
VALID: MSF Bytes\r
VALID-NEXT: ============================================================\r
INVALID: llvm-pdbutil: Invalid byte range specified. Max < Min\r
\r
INVALID-RANGE: llvm-pdbutil: Invalid byte range specified. Requested byte larger than file size\r
+\r
+NAME-MAP: Named Stream Map\r
+NAME-MAP-NEXT: ============================================================\r
+NAME-MAP-NEXT: Named Stream Map (\r
+NAME-MAP-NEXT: 1301C: 22000000 2F4C696E 6B496E66 6F002F6E 616D6573 002F7372 632F6865 61646572 |".../LinkInfo./names./src/header|\r
+NAME-MAP-NEXT: 1303C: 626C6F63 6B000300 00000600 00000100 00001A00 00000000 00001100 00000900 |block...........................|\r
+NAME-MAP-NEXT: 1305C: 00000A00 00000D00 00000000 00000500 0000 |..................|\r
+NAME-MAP-NEXT: )\r
#include "llvm-pdbutil.h"
#include "llvm/DebugInfo/MSF/MappedBlockStream.h"
+#include "llvm/DebugInfo/PDB/Native/InfoStream.h"
#include "llvm/DebugInfo/PDB/Native/PDBFile.h"
#include "llvm/DebugInfo/PDB/Native/RawError.h"
#include "llvm/Support/BinaryStreamReader.h"
dumpStreamBytes();
P.NewLine();
}
+
+ if (opts::bytes::NameMap) {
+ dumpNameMap();
+ P.NewLine();
+ }
return Error::success();
}
+void BytesOutputStyle::dumpNameMap() {
+ printHeader(P, "Named Stream Map");
+
+ AutoIndent Indent(P);
+
+ auto &InfoS = Err(File.getPDBInfoStream());
+ BinarySubstreamRef NS = InfoS.getNamedStreamsBuffer();
+ auto Layout = File.getStreamLayout(StreamPDB);
+ P.formatMsfStreamData("Named Stream Map", File, Layout, NS);
+}
+
void BytesOutputStyle::dumpBlockRanges(uint32_t Min, uint32_t Max) {
printHeader(P, "MSF Blocks");
Error dump() override;
private:
+ void dumpNameMap();
void dumpBlockRanges(uint32_t Min, uint32_t Max);
void dumpByteRanges(uint32_t Min, uint32_t Max);
void dumpStreamBytes();
PDBFile &File;
LinePrinter P;
+ ExitOnError Err;
SmallVector<std::string, 8> StreamPurposes;
};
} // namespace pdb
StreamPurpose, Size, S->getLength());
AutoIndent Indent(*this);
BinaryStreamRef Slice(*S);
- Slice = Slice.keep_front(Offset + Size);
- BinaryStreamReader Reader(Slice);
- consumeError(Reader.skip(Offset));
+ BinarySubstreamRef Substream;
+ Substream.Offset = Offset;
+ Substream.StreamData = Slice.drop_front(Offset).keep_front(Size);
+
auto Layout = File.getStreamLayout(StreamIdx);
- formatMsfStreamData(Label, File, Layout, Reader);
+ formatMsfStreamData(Label, File, Layout, Substream);
}
void LinePrinter::formatMsfStreamData(StringRef Label, PDBFile &File,
BinarySubstreamRef Substream) {
BinaryStreamReader Reader(Substream.StreamData);
- consumeError(Reader.skip(Substream.Offset));
- formatMsfStreamData(Label, File, Stream, Reader);
-}
-
-void LinePrinter::formatMsfStreamData(StringRef Label, PDBFile &File,
- const msf::MSFStreamLayout &Stream,
- BinaryStreamReader &Reader) {
auto Runs = computeBlockRuns(File.getBlockSize(), Stream);
NewLine();
Run FoundRun;
uint32_t RunOffset;
- std::tie(FoundRun, RunOffset) = findRun(Reader.getOffset(), Runs);
+ std::tie(FoundRun, RunOffset) = findRun(Substream.Offset, Runs);
assert(FoundRun.ByteLen >= RunOffset);
uint32_t Len = FoundRun.ByteLen - RunOffset;
Len = std::min(Len, Reader.bytesRemaining());
OS << formatv(" {0}",
fmt_align("<discontinuity>", AlignStyle::Center, 114, '-'));
}
+ Substream.Offset += Len;
}
NewLine();
OS << ")";
void formatMsfStreamData(StringRef Label, PDBFile &File,
const msf::MSFStreamLayout &Stream,
BinarySubstreamRef Substream);
- void formatMsfStreamData(StringRef Label, PDBFile &File,
- const msf::MSFStreamLayout &Stream,
- BinaryStreamReader &Reader);
bool hasColor() const { return UseColor; }
raw_ostream &getStream() { return OS; }
"is SN[:Start][@Size]"),
cl::sub(BytesSubcommand));
+cl::opt<bool> NameMap("name-map", cl::desc("Dump bytes of PDB Name Map"),
+ cl::sub(BytesSubcommand));
+
cl::list<std::string> InputFilenames(cl::Positional,
cl::desc("<input PDB files>"),
cl::OneOrMore, cl::sub(BytesSubcommand));
extern llvm::Optional<NumberRange> DumpBlockRange;
extern llvm::Optional<NumberRange> DumpByteRange;
extern llvm::cl::list<std::string> DumpStreamData;
+extern llvm::cl::opt<bool> NameMap;
} // namespace bytes
namespace dump {