summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorReid Kleckner <rnk@google.com>2016-05-31 18:15:23 +0000
committerReid Kleckner <rnk@google.com>2016-05-31 18:15:23 +0000
commit3b3f490f9c5706bb4d216068283f78694826100b (patch)
tree8650d5915d5e56361abd1bbe86ce90c3e4ba84c4
parent3836482abcd2e26630026d71100852f45b25aa20 (diff)
downloadbcm5719-llvm-3b3f490f9c5706bb4d216068283f78694826100b.tar.gz
bcm5719-llvm-3b3f490f9c5706bb4d216068283f78694826100b.zip
[codeview] Add a CVTypeDumper::dump(ArrayRef<uint8_t>) overload
This is a convenient wrapper when the type record is already laid out as bytes in memory. llvm-svn: 271309
-rw-r--r--llvm/include/llvm/DebugInfo/CodeView/TypeDumper.h8
-rw-r--r--llvm/lib/DebugInfo/CodeView/TypeDumper.cpp13
-rw-r--r--llvm/tools/llvm-readobj/COFFDumper.cpp26
3 files changed, 22 insertions, 25 deletions
diff --git a/llvm/include/llvm/DebugInfo/CodeView/TypeDumper.h b/llvm/include/llvm/DebugInfo/CodeView/TypeDumper.h
index 670dcd70c13..77dab8e8d3d 100644
--- a/llvm/include/llvm/DebugInfo/CodeView/TypeDumper.h
+++ b/llvm/include/llvm/DebugInfo/CodeView/TypeDumper.h
@@ -35,10 +35,16 @@ public:
/// type references.
bool dump(const CVRecord<TypeLeafKind> &Record);
- /// Dumps the type records in Data. Returns false if there was a type stream
+ /// Dumps the type records in Types. Returns false if there was a type stream
/// parse error, and true otherwise.
bool dump(const CVTypeArray &Types);
+ /// Dumps the type records in Data. Returns false if there was a type stream
+ /// parse error, and true otherwise. Use this method instead of the
+ /// CVTypeArray overload when type records are laid out contiguously in
+ /// memory.
+ bool dump(ArrayRef<uint8_t> Data);
+
/// Gets the type index for the next type record.
unsigned getNextTypeIndex() const {
return 0x1000 + CVUDTNames.size();
diff --git a/llvm/lib/DebugInfo/CodeView/TypeDumper.cpp b/llvm/lib/DebugInfo/CodeView/TypeDumper.cpp
index edfaea1315a..d27ef494202 100644
--- a/llvm/lib/DebugInfo/CodeView/TypeDumper.cpp
+++ b/llvm/lib/DebugInfo/CodeView/TypeDumper.cpp
@@ -12,6 +12,7 @@
#include "llvm/DebugInfo/CodeView/CVTypeVisitor.h"
#include "llvm/DebugInfo/CodeView/TypeIndex.h"
#include "llvm/DebugInfo/CodeView/TypeRecord.h"
+#include "llvm/DebugInfo/CodeView/ByteStream.h"
#include "llvm/Support/ScopedPrinter.h"
using namespace llvm;
@@ -690,6 +691,18 @@ bool CVTypeDumper::dump(const CVTypeArray &Types) {
return !Dumper.hadError();
}
+bool CVTypeDumper::dump(ArrayRef<uint8_t> Data) {
+ ByteStream Stream(Data);
+ CVTypeArray Types;
+ StreamReader Reader(Stream);
+ if (auto EC = Reader.readArray(Types, Reader.getLength())) {
+ consumeError(std::move(EC));
+ return false;
+ }
+
+ return dump(Types);
+}
+
void CVTypeDumper::setPrinter(ScopedPrinter *P) {
static ScopedPrinter NullP(llvm::nulls());
W = P ? P : &NullP;
diff --git a/llvm/tools/llvm-readobj/COFFDumper.cpp b/llvm/tools/llvm-readobj/COFFDumper.cpp
index bf6a7b4a2b0..0949436a8f3 100644
--- a/llvm/tools/llvm-readobj/COFFDumper.cpp
+++ b/llvm/tools/llvm-readobj/COFFDumper.cpp
@@ -1052,18 +1052,7 @@ void COFFDumper::printCodeViewTypeSection(StringRef SectionName,
if (Magic != COFF::DEBUG_SECTION_MAGIC)
return error(object_error::parse_failed);
- ArrayRef<uint8_t> BinaryData(reinterpret_cast<const uint8_t *>(Data.data()),
- Data.size());
- ByteStream Stream(BinaryData);
- CVTypeArray Types;
- StreamReader Reader(Stream);
- if (auto EC = Reader.readArray(Types, Reader.getLength())) {
- consumeError(std::move(EC));
- W.flush();
- error(object_error::parse_failed);
- }
-
- if (!CVTD.dump(Types)) {
+ if (!CVTD.dump({Data.bytes_begin(), Data.bytes_end()})) {
W.flush();
error(object_error::parse_failed);
}
@@ -1513,18 +1502,7 @@ void llvm::dumpCodeViewMergedTypes(
Buf.append(R->data(), R->data() + R->size());
});
CVTypeDumper CVTD(Writer, opts::CodeViewSubsectionBytes);
- ArrayRef<uint8_t> BinaryData(reinterpret_cast<const uint8_t *>(Buf.data()),
- Buf.size());
- ByteStream Stream(BinaryData);
- CVTypeArray Types;
- StreamReader Reader(Stream);
- if (auto EC = Reader.readArray(Types, Reader.getLength())) {
- consumeError(std::move(EC));
- Writer.flush();
- error(object_error::parse_failed);
- }
-
- if (!CVTD.dump(Types)) {
+ if (!CVTD.dump({Buf.str().bytes_begin(), Buf.str().bytes_end()})) {
Writer.flush();
error(object_error::parse_failed);
}
OpenPOWER on IntegriCloud