summaryrefslogtreecommitdiffstats
path: root/llvm/tools
diff options
context:
space:
mode:
authorZachary Turner <zturner@google.com>2017-02-25 00:44:30 +0000
committerZachary Turner <zturner@google.com>2017-02-25 00:44:30 +0000
commitaf299ea5d456aa2fc19d7fdb041a0452d209fd4c (patch)
tree2d863cba130306041941aeec5b44baa2e9c00ec1 /llvm/tools
parent42de38076517bc68a2b97c55dcbac7ea8d80b11b (diff)
downloadbcm5719-llvm-af299ea5d456aa2fc19d7fdb041a0452d209fd4c.tar.gz
bcm5719-llvm-af299ea5d456aa2fc19d7fdb041a0452d209fd4c.zip
[PDB] General improvements to Stream library.
This adds various new functionality and cleanup surrounding the use of the Stream library. Major changes include: * Renaming of all classes for more consistency / meaningfulness * Addition of some new methods for reading multiple values at once. * Full suite of unit tests for reader / writer functionality. * Full set of doxygen comments for all classes. * Streams now store their own endianness. * Fixed some bugs in a few of the classes that were discovered by the unit tests. llvm-svn: 296215
Diffstat (limited to 'llvm/tools')
-rw-r--r--llvm/tools/llvm-pdbdump/LLVMOutputStyle.cpp11
-rw-r--r--llvm/tools/llvm-pdbdump/YamlTypeDumper.cpp4
-rw-r--r--llvm/tools/llvm-readobj/COFFDumper.cpp35
3 files changed, 25 insertions, 25 deletions
diff --git a/llvm/tools/llvm-pdbdump/LLVMOutputStyle.cpp b/llvm/tools/llvm-pdbdump/LLVMOutputStyle.cpp
index 1843a3c9e0f..11c566facb3 100644
--- a/llvm/tools/llvm-pdbdump/LLVMOutputStyle.cpp
+++ b/llvm/tools/llvm-pdbdump/LLVMOutputStyle.cpp
@@ -22,6 +22,7 @@
#include "llvm/DebugInfo/CodeView/TypeDumpVisitor.h"
#include "llvm/DebugInfo/CodeView/TypeVisitorCallbackPipeline.h"
#include "llvm/DebugInfo/MSF/BinaryStreamReader.h"
+#include "llvm/DebugInfo/MSF/BinaryStreamReader.h"
#include "llvm/DebugInfo/MSF/MappedBlockStream.h"
#include "llvm/DebugInfo/PDB/Native/DbiStream.h"
#include "llvm/DebugInfo/PDB/Native/EnumTables.h"
@@ -450,7 +451,7 @@ Error LLVMOutputStyle::dumpStreamBytes() {
auto Blocks = File.getMsfLayout().StreamMap[SI];
P.printList("Blocks", Blocks);
- StreamReader R(*S);
+ BinaryStreamReader R(*S);
ArrayRef<uint8_t> StreamData;
if (auto EC = R.readBytes(StreamData, S->getLength()))
return EC;
@@ -745,10 +746,10 @@ Error LLVMOutputStyle::dumpDbiStream() {
public:
RecordVisitor(ScopedPrinter &P, PDBFile &F) : P(P), F(F) {}
Error visitUnknown(ModuleSubstreamKind Kind,
- ReadableStreamRef Stream) override {
+ BinaryStreamRef Stream) override {
DictScope DD(P, "Unknown");
ArrayRef<uint8_t> Data;
- StreamReader R(Stream);
+ BinaryStreamReader R(Stream);
if (auto EC = R.readBytes(Data, R.bytesRemaining())) {
return make_error<RawError>(
raw_error_code::corrupt_file,
@@ -758,7 +759,7 @@ Error LLVMOutputStyle::dumpDbiStream() {
return Error::success();
}
Error
- visitFileChecksums(ReadableStreamRef Data,
+ visitFileChecksums(BinaryStreamRef Data,
const FileChecksumArray &Checksums) override {
DictScope DD(P, "FileChecksums");
for (const auto &C : Checksums) {
@@ -774,7 +775,7 @@ Error LLVMOutputStyle::dumpDbiStream() {
return Error::success();
}
- Error visitLines(ReadableStreamRef Data,
+ Error visitLines(BinaryStreamRef Data,
const LineSubstreamHeader *Header,
const LineInfoArray &Lines) override {
DictScope DD(P, "Lines");
diff --git a/llvm/tools/llvm-pdbdump/YamlTypeDumper.cpp b/llvm/tools/llvm-pdbdump/YamlTypeDumper.cpp
index 80bf9349b0c..e2b901be868 100644
--- a/llvm/tools/llvm-pdbdump/YamlTypeDumper.cpp
+++ b/llvm/tools/llvm-pdbdump/YamlTypeDumper.cpp
@@ -573,8 +573,8 @@ struct MappingContextTraits<pdb::yaml::PdbTpiFieldListRecord,
assert(IO.outputting());
codeview::TypeVisitorCallbackPipeline Pipeline;
- msf::ByteStream Data(Obj.Record.Data);
- msf::StreamReader FieldReader(Data);
+ BinaryByteStream Data(Obj.Record.Data, llvm::support::little);
+ BinaryStreamReader FieldReader(Data);
codeview::FieldListDeserializer Deserializer(FieldReader);
// For PDB to Yaml, deserialize into a high level record type, then dump
diff --git a/llvm/tools/llvm-readobj/COFFDumper.cpp b/llvm/tools/llvm-readobj/COFFDumper.cpp
index 329768fcaa6..be90d18b121 100644
--- a/llvm/tools/llvm-readobj/COFFDumper.cpp
+++ b/llvm/tools/llvm-readobj/COFFDumper.cpp
@@ -56,7 +56,6 @@
using namespace llvm;
using namespace llvm::object;
using namespace llvm::codeview;
-using namespace llvm::msf;
using namespace llvm::support;
using namespace llvm::Win64EH;
@@ -155,7 +154,7 @@ public:
Sec = Obj->getCOFFSection(SR);
}
- uint32_t getRecordOffset(msf::StreamReader Reader) override {
+ uint32_t getRecordOffset(BinaryStreamReader Reader) override {
ArrayRef<uint8_t> Data;
if (auto EC = Reader.readLongestContiguousChunk(Data)) {
llvm::consumeError(std::move(EC));
@@ -841,13 +840,13 @@ void COFFDumper::printCodeViewSymbolSection(StringRef SectionName,
}
case ModuleSubstreamKind::FrameData: {
// First four bytes is a relocation against the function.
- msf::ByteStream S(Contents);
- msf::StreamReader SR(S);
- const uint32_t *CodePtr;
- error(SR.readObject(CodePtr));
+ BinaryByteStream S(Contents, llvm::support::little);
+ BinaryStreamReader SR(S);
+ StringRef CodePtr;
+ error(SR.readFixedString(CodePtr, 4));
StringRef LinkageName;
error(resolveSymbolName(Obj->getCOFFSection(Section), SectionContents,
- CodePtr, LinkageName));
+ CodePtr.data(), LinkageName));
W.printString("LinkageName", LinkageName);
// To find the active frame description, search this array for the
@@ -966,9 +965,9 @@ void COFFDumper::printCodeViewSymbolsSubsection(StringRef Subsection,
CVSymbolDumper CVSD(W, TypeDB, std::move(CODD),
opts::CodeViewSubsectionBytes);
- ByteStream Stream(BinaryData);
+ BinaryByteStream Stream(BinaryData, llvm::support::little);
CVSymbolArray Symbols;
- StreamReader Reader(Stream);
+ BinaryStreamReader Reader(Stream);
if (auto EC = Reader.readArray(Symbols, Reader.getLength())) {
consumeError(std::move(EC));
W.flush();
@@ -983,8 +982,8 @@ void COFFDumper::printCodeViewSymbolsSubsection(StringRef Subsection,
}
void COFFDumper::printCodeViewFileChecksums(StringRef Subsection) {
- msf::ByteStream S(Subsection);
- msf::StreamReader SR(S);
+ BinaryByteStream S(Subsection, llvm::support::little);
+ BinaryStreamReader SR(S);
while (!SR.empty()) {
DictScope S(W, "FileChecksum");
const FileChecksum *FC;
@@ -1012,10 +1011,10 @@ void COFFDumper::printCodeViewFileChecksums(StringRef Subsection) {
}
void COFFDumper::printCodeViewInlineeLines(StringRef Subsection) {
- msf::ByteStream S(Subsection);
- msf::StreamReader SR(S);
+ BinaryByteStream S(Subsection, llvm::support::little);
+ BinaryStreamReader SR(S);
uint32_t Signature;
- error(SR.readInteger(Signature, llvm::support::little));
+ error(SR.readInteger(Signature));
bool HasExtraFiles = Signature == unsigned(InlineeLinesSignature::ExtraFiles);
while (!SR.empty()) {
@@ -1028,12 +1027,12 @@ void COFFDumper::printCodeViewInlineeLines(StringRef Subsection) {
if (HasExtraFiles) {
uint32_t ExtraFileCount;
- error(SR.readInteger(ExtraFileCount, llvm::support::little));
+ error(SR.readInteger(ExtraFileCount));
W.printNumber("ExtraFileCount", ExtraFileCount);
ListScope ExtraFiles(W, "ExtraFiles");
for (unsigned I = 0; I < ExtraFileCount; ++I) {
uint32_t FileID;
- error(SR.readInteger(FileID, llvm::support::little));
+ error(SR.readInteger(FileID));
printFileNameForOffset("FileID", FileID);
}
}
@@ -1078,9 +1077,9 @@ void COFFDumper::mergeCodeViewTypes(TypeTableBuilder &CVTypes) {
error(object_error::parse_failed);
ArrayRef<uint8_t> Bytes(reinterpret_cast<const uint8_t *>(Data.data()),
Data.size());
- ByteStream Stream(Bytes);
+ BinaryByteStream Stream(Bytes, llvm::support::little);
CVTypeArray Types;
- StreamReader Reader(Stream);
+ BinaryStreamReader Reader(Stream);
if (auto EC = Reader.readArray(Types, Reader.getLength())) {
consumeError(std::move(EC));
W.flush();
OpenPOWER on IntegriCloud