mirror of
https://github.com/RPCSX/llvm.git
synced 2025-02-25 15:41:05 +00:00
[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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@271309 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
3c5dd6e28a
commit
cb4d52f619
@ -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();
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user