mirror of
https://github.com/RPCSX/llvm.git
synced 2026-01-31 01:05:23 +01:00
This was all using ArrayRef<>s before which presents a problem when you want to serialize to or deserialize from an actual PDB stream. An ArrayRef<> is really just a special case of what can be handled with StreamInterface though (e.g. by using a ByteStream), so changing this to use StreamInterface allows us to plug in a PDB stream and get all the record serialization and deserialization for free on a MappedBlockStream. Subsequent patches will try to remove TypeTableBuilder and TypeRecordBuilder in favor of class that operate on Streams as well, which should allow us to completely merge the reading and writing codepaths for both types and symbols. Differential Revision: https://reviews.llvm.org/D25831 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@284762 91177308-0d34-0410-b5e6-96231b3b80d8
65 lines
2.1 KiB
C++
65 lines
2.1 KiB
C++
//===- SymbolDeserializer.h -------------------------------------*- C++ -*-===//
|
|
//
|
|
// The LLVM Compiler Infrastructure
|
|
//
|
|
// This file is distributed under the University of Illinois Open Source
|
|
// License. See LICENSE.TXT for details.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#ifndef LLVM_DEBUGINFO_CODEVIEW_SYMBOLDESERIALIZER_H
|
|
#define LLVM_DEBUGINFO_CODEVIEW_SYMBOLDESERIALIZER_H
|
|
|
|
#include "llvm/ADT/ArrayRef.h"
|
|
#include "llvm/DebugInfo/CodeView/SymbolRecord.h"
|
|
#include "llvm/DebugInfo/CodeView/SymbolVisitorCallbacks.h"
|
|
#include "llvm/DebugInfo/CodeView/SymbolVisitorDelegate.h"
|
|
#include "llvm/DebugInfo/MSF/ByteStream.h"
|
|
#include "llvm/DebugInfo/MSF/StreamReader.h"
|
|
#include "llvm/Support/Error.h"
|
|
|
|
namespace llvm {
|
|
namespace codeview {
|
|
class SymbolVisitorDelegate;
|
|
class SymbolDeserializer : public SymbolVisitorCallbacks {
|
|
public:
|
|
explicit SymbolDeserializer(SymbolVisitorDelegate *Delegate)
|
|
: Delegate(Delegate) {}
|
|
|
|
#define SYMBOL_RECORD(EnumName, EnumVal, Name) \
|
|
Error visitKnownRecord(CVSymbol &CVR, Name &Record) override { \
|
|
return defaultVisitKnownRecord(CVR, Record); \
|
|
}
|
|
#define SYMBOL_RECORD_ALIAS(EnumName, EnumVal, Name, AliasName)
|
|
#include "CVSymbolTypes.def"
|
|
|
|
protected:
|
|
template <typename T>
|
|
Error deserializeRecord(msf::StreamReader &Reader, SymbolKind Kind,
|
|
T &Record) const {
|
|
uint32_t RecordOffset = Delegate ? Delegate->getRecordOffset(Reader) : 0;
|
|
SymbolRecordKind RK = static_cast<SymbolRecordKind>(Kind);
|
|
auto ExpectedRecord = T::deserialize(RK, RecordOffset, Reader);
|
|
if (!ExpectedRecord)
|
|
return ExpectedRecord.takeError();
|
|
Record = std::move(*ExpectedRecord);
|
|
return Error::success();
|
|
}
|
|
|
|
private:
|
|
template <typename T>
|
|
Error defaultVisitKnownRecord(CVSymbol &CVR, T &Record) {
|
|
msf::ByteStream S(CVR.content());
|
|
msf::StreamReader SR(S);
|
|
if (auto EC = deserializeRecord(SR, CVR.Type, Record))
|
|
return EC;
|
|
return Error::success();
|
|
}
|
|
|
|
SymbolVisitorDelegate *Delegate;
|
|
};
|
|
}
|
|
}
|
|
|
|
#endif
|