mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-02-15 17:58:50 +00:00
[llvm-pdbutil] Dump raw bytes of pdb name map.
This patch dumps the raw bytes of the pdb name map which contains the mapping of stream name to stream index for the string table and other reserved streams. llvm-svn: 306148
This commit is contained in:
parent
b0b7e2b937
commit
086ec4ddf5
@ -47,6 +47,8 @@ public:
|
||||
|
||||
const NamedStreamMap &getNamedStreams() const;
|
||||
|
||||
BinarySubstreamRef getNamedStreamsBuffer() const;
|
||||
|
||||
uint32_t getNamedStreamIndex(llvm::StringRef Name) const;
|
||||
iterator_range<StringMapConstIterator<uint32_t>> named_streams() const;
|
||||
|
||||
@ -71,6 +73,8 @@ private:
|
||||
// universally unique.
|
||||
PDB_UniqueId Guid;
|
||||
|
||||
BinarySubstreamRef SubNamedStreams;
|
||||
|
||||
std::vector<PdbRaw_FeatureSig> FeatureSignatures;
|
||||
PdbRaw_Features Features = PdbFeatureNone;
|
||||
|
||||
|
@ -57,6 +57,10 @@ Error InfoStream::reload() {
|
||||
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;
|
||||
@ -129,3 +133,7 @@ ArrayRef<PdbRaw_FeatureSig> InfoStream::getFeatureSignatures() const {
|
||||
const NamedStreamMap &InfoStream::getNamedStreams() const {
|
||||
return NamedStreams;
|
||||
}
|
||||
|
||||
BinarySubstreamRef InfoStream::getNamedStreamsBuffer() const {
|
||||
return SubNamedStreams;
|
||||
}
|
||||
|
@ -2,6 +2,8 @@
|
||||
; RUN: not llvm-pdbutil bytes -byte-range=100-20 %p/Inputs/empty.pdb 2>&1 | FileCheck --check-prefix=INVALID %s
|
||||
; RUN: not llvm-pdbutil bytes -byte-range=100000-200000 %p/Inputs/empty.pdb 2>&1 | FileCheck --check-prefix=INVALID-RANGE %s
|
||||
|
||||
; RUN: llvm-pdbutil bytes -name-map %p/Inputs/empty.pdb | FileCheck --check-prefix=NAME-MAP %s
|
||||
|
||||
|
||||
VALID: MSF Bytes
|
||||
VALID-NEXT: ============================================================
|
||||
@ -13,3 +15,11 @@ VALID-NEXT: )
|
||||
INVALID: llvm-pdbutil: Invalid byte range specified. Max < Min
|
||||
|
||||
INVALID-RANGE: llvm-pdbutil: Invalid byte range specified. Requested byte larger than file size
|
||||
|
||||
NAME-MAP: Named Stream Map
|
||||
NAME-MAP-NEXT: ============================================================
|
||||
NAME-MAP-NEXT: Named Stream Map (
|
||||
NAME-MAP-NEXT: 1301C: 22000000 2F4C696E 6B496E66 6F002F6E 616D6573 002F7372 632F6865 61646572 |".../LinkInfo./names./src/header|
|
||||
NAME-MAP-NEXT: 1303C: 626C6F63 6B000300 00000600 00000100 00001A00 00000000 00001100 00000900 |block...........................|
|
||||
NAME-MAP-NEXT: 1305C: 00000A00 00000D00 00000000 00000500 0000 |..................|
|
||||
NAME-MAP-NEXT: )
|
||||
|
@ -13,6 +13,7 @@
|
||||
#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"
|
||||
@ -116,9 +117,25 @@ Error BytesOutputStyle::dump() {
|
||||
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");
|
||||
|
||||
|
@ -28,12 +28,14 @@ public:
|
||||
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
|
||||
|
@ -203,11 +203,12 @@ void LinePrinter::formatMsfStreamData(StringRef Label, PDBFile &File,
|
||||
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,
|
||||
@ -215,13 +216,6 @@ 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();
|
||||
@ -231,7 +225,7 @@ void LinePrinter::formatMsfStreamData(StringRef Label, PDBFile &File,
|
||||
|
||||
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());
|
||||
@ -245,6 +239,7 @@ void LinePrinter::formatMsfStreamData(StringRef Label, PDBFile &File,
|
||||
OS << formatv(" {0}",
|
||||
fmt_align("<discontinuity>", AlignStyle::Center, 114, '-'));
|
||||
}
|
||||
Substream.Offset += Len;
|
||||
}
|
||||
NewLine();
|
||||
OS << ")";
|
||||
|
@ -60,9 +60,6 @@ public:
|
||||
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; }
|
||||
|
@ -286,6 +286,9 @@ cl::list<std::string>
|
||||
"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));
|
||||
|
@ -101,6 +101,7 @@ struct NumberRange {
|
||||
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 {
|
||||
|
Loading…
x
Reference in New Issue
Block a user