[llvm] r271309 - [codeview] Add a CVTypeDumper::dump(ArrayRef<uint8_t>) overload
Reid Kleckner via llvm-commits
llvm-commits at lists.llvm.org
Tue May 31 11:15:23 PDT 2016
Author: rnk
Date: Tue May 31 13:15:23 2016
New Revision: 271309
URL: http://llvm.org/viewvc/llvm-project?rev=271309&view=rev
Log:
[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.
Modified:
llvm/trunk/include/llvm/DebugInfo/CodeView/TypeDumper.h
llvm/trunk/lib/DebugInfo/CodeView/TypeDumper.cpp
llvm/trunk/tools/llvm-readobj/COFFDumper.cpp
Modified: llvm/trunk/include/llvm/DebugInfo/CodeView/TypeDumper.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/CodeView/TypeDumper.h?rev=271309&r1=271308&r2=271309&view=diff
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/CodeView/TypeDumper.h (original)
+++ llvm/trunk/include/llvm/DebugInfo/CodeView/TypeDumper.h Tue May 31 13:15:23 2016
@@ -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();
Modified: llvm/trunk/lib/DebugInfo/CodeView/TypeDumper.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/CodeView/TypeDumper.cpp?rev=271309&r1=271308&r2=271309&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/CodeView/TypeDumper.cpp (original)
+++ llvm/trunk/lib/DebugInfo/CodeView/TypeDumper.cpp Tue May 31 13:15:23 2016
@@ -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 CVTypeArra
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;
Modified: llvm/trunk/tools/llvm-readobj/COFFDumper.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-readobj/COFFDumper.cpp?rev=271309&r1=271308&r2=271309&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-readobj/COFFDumper.cpp (original)
+++ llvm/trunk/tools/llvm-readobj/COFFDumper.cpp Tue May 31 13:15:23 2016
@@ -1052,18 +1052,7 @@ void COFFDumper::printCodeViewTypeSectio
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);
}
More information about the llvm-commits
mailing list