diff options
author | Zachary Turner <zturner@google.com> | 2017-03-13 14:57:45 +0000 |
---|---|---|
committer | Zachary Turner <zturner@google.com> | 2017-03-13 14:57:45 +0000 |
commit | 407dec59a4b66819081757b6895f4ec6417dd57f (patch) | |
tree | 7f10821ba58708edac9db95e0784a94d7f436d86 /llvm/lib/DebugInfo/CodeView | |
parent | 82d55239eae14af084fb35f7692d463b5834fb6d (diff) | |
download | bcm5719-llvm-407dec59a4b66819081757b6895f4ec6417dd57f.tar.gz bcm5719-llvm-407dec59a4b66819081757b6895f4ec6417dd57f.zip |
[llvm-pdbdump] Add support for dumping symbols from Yaml -> PDB.
Previously we could round-trip type records from PDB -> Yaml ->
PDB, but for symbols we could only go from PDB -> Yaml. This
completes the round-tripping for symbols as well.
llvm-svn: 297625
Diffstat (limited to 'llvm/lib/DebugInfo/CodeView')
-rw-r--r-- | llvm/lib/DebugInfo/CodeView/CMakeLists.txt | 1 | ||||
-rw-r--r-- | llvm/lib/DebugInfo/CodeView/SymbolSerializer.cpp | 52 |
2 files changed, 53 insertions, 0 deletions
diff --git a/llvm/lib/DebugInfo/CodeView/CMakeLists.txt b/llvm/lib/DebugInfo/CodeView/CMakeLists.txt index 63c1832b3f2..a120484cdbe 100644 --- a/llvm/lib/DebugInfo/CodeView/CMakeLists.txt +++ b/llvm/lib/DebugInfo/CodeView/CMakeLists.txt @@ -12,6 +12,7 @@ add_llvm_library(LLVMDebugInfoCodeView RecordSerialization.cpp SymbolRecordMapping.cpp SymbolDumper.cpp + SymbolSerializer.cpp TypeDatabase.cpp TypeDatabaseVisitor.cpp TypeDumpVisitor.cpp diff --git a/llvm/lib/DebugInfo/CodeView/SymbolSerializer.cpp b/llvm/lib/DebugInfo/CodeView/SymbolSerializer.cpp new file mode 100644 index 00000000000..251cc431f52 --- /dev/null +++ b/llvm/lib/DebugInfo/CodeView/SymbolSerializer.cpp @@ -0,0 +1,52 @@ +//===- SymbolSerializer.cpp -------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include "llvm/DebugInfo/CodeView/SymbolSerializer.h" + +using namespace llvm; +using namespace llvm::codeview; + +SymbolSerializer::SymbolSerializer(BumpPtrAllocator &Allocator) + : Storage(Allocator), RecordBuffer(MaxRecordLength), Stream(RecordBuffer, llvm::support::little), + Writer(Stream), Mapping(Writer) { } + +Error SymbolSerializer::visitSymbolBegin(CVSymbol &Record) { + assert(!CurrentSymbol.hasValue() && "Already in a symbol mapping!"); + + Writer.setOffset(0); + + if (auto EC = writeRecordPrefix(Record.kind())) + return EC; + + CurrentSymbol = Record.kind(); + if (auto EC = Mapping.visitSymbolBegin(Record)) + return EC; + + return Error::success(); +} + +Error SymbolSerializer::visitSymbolEnd(CVSymbol &Record) { + assert(CurrentSymbol.hasValue() && "Not in a symbol mapping!"); + + if (auto EC = Mapping.visitSymbolEnd(Record)) + return EC; + + uint32_t RecordEnd = Writer.getOffset(); + uint16_t Length = RecordEnd - 2; + Writer.setOffset(0); + if (auto EC = Writer.writeInteger(Length)) + return EC; + + uint8_t *StableStorage = Storage.Allocate<uint8_t>(RecordEnd); + ::memcpy(StableStorage, &RecordBuffer[0], RecordEnd); + Record.RecordData = ArrayRef<uint8_t>(StableStorage, RecordEnd); + CurrentSymbol.reset(); + + return Error::success(); +} |