diff options
author | Zachary Turner <zturner@google.com> | 2017-04-27 16:12:16 +0000 |
---|---|---|
committer | Zachary Turner <zturner@google.com> | 2017-04-27 16:12:16 +0000 |
commit | c37cb0c6a5c266f102c130bfe1daaa25329cb997 (patch) | |
tree | 48cd2b14c7b818b9b1a6eec14ae4518ee2dc195d /llvm/lib/DebugInfo/CodeView/ModuleDebugFragmentVisitor.cpp | |
parent | e5094474187a9b748589aa709c3e1e172d42e87f (diff) | |
download | bcm5719-llvm-c37cb0c6a5c266f102c130bfe1daaa25329cb997.tar.gz bcm5719-llvm-c37cb0c6a5c266f102c130bfe1daaa25329cb997.zip |
[CodeView] Isolate Debug Info Fragments into standalone classes.
Previously parsing of these were all grouped together into a
single master class that could parse any type of debug info
fragment.
With writing forthcoming, the complexity of each individual
fragment is enough to warrant them having their own classes so
that reading and writing of each fragment type can be grouped
together, but isolated from the code for reading and writing
other fragment types.
In doing so, I found a place where parsing code was duplicated
for the FileChecksums fragment, across llvm-readobj and the
CodeView library, and one of the implementations had a bug.
Now that the codepaths are merged, the bug is resolved.
Differential Revision: https://reviews.llvm.org/D32547
llvm-svn: 301557
Diffstat (limited to 'llvm/lib/DebugInfo/CodeView/ModuleDebugFragmentVisitor.cpp')
-rw-r--r-- | llvm/lib/DebugInfo/CodeView/ModuleDebugFragmentVisitor.cpp | 99 |
1 files changed, 18 insertions, 81 deletions
diff --git a/llvm/lib/DebugInfo/CodeView/ModuleDebugFragmentVisitor.cpp b/llvm/lib/DebugInfo/CodeView/ModuleDebugFragmentVisitor.cpp index 37cd887d783..53dc922a649 100644 --- a/llvm/lib/DebugInfo/CodeView/ModuleDebugFragmentVisitor.cpp +++ b/llvm/lib/DebugInfo/CodeView/ModuleDebugFragmentVisitor.cpp @@ -8,99 +8,36 @@ //===----------------------------------------------------------------------===// #include "llvm/DebugInfo/CodeView/ModuleDebugFragmentVisitor.h" + +#include "llvm/DebugInfo/CodeView/ModuleDebugFileChecksumFragment.h" +#include "llvm/DebugInfo/CodeView/ModuleDebugLineFragment.h" #include "llvm/Support/BinaryStreamReader.h" #include "llvm/Support/BinaryStreamRef.h" using namespace llvm; using namespace llvm::codeview; -Error ModuleDebugFragmentVisitor::visitSymbols(BinaryStreamRef Data) { - return visitUnknown(ModuleDebugFragmentKind::Symbols, Data); -} -Error ModuleDebugFragmentVisitor::visitLines(BinaryStreamRef Data, - const LineFragmentHeader *Header, - const LineInfoArray &Lines) { - return visitUnknown(ModuleDebugFragmentKind::Lines, Data); -} -Error ModuleDebugFragmentVisitor::visitStringTable(BinaryStreamRef Data) { - return visitUnknown(ModuleDebugFragmentKind::StringTable, Data); -} -Error ModuleDebugFragmentVisitor::visitFileChecksums( - BinaryStreamRef Data, const FileChecksumArray &Checksums) { - return visitUnknown(ModuleDebugFragmentKind::FileChecksums, Data); -} -Error ModuleDebugFragmentVisitor::visitFrameData(BinaryStreamRef Data) { - return visitUnknown(ModuleDebugFragmentKind::FrameData, Data); -} -Error ModuleDebugFragmentVisitor::visitInlineeLines(BinaryStreamRef Data) { - return visitUnknown(ModuleDebugFragmentKind::InlineeLines, Data); -} -Error ModuleDebugFragmentVisitor::visitCrossScopeImports(BinaryStreamRef Data) { - return visitUnknown(ModuleDebugFragmentKind::CrossScopeExports, Data); -} -Error ModuleDebugFragmentVisitor::visitCrossScopeExports(BinaryStreamRef Data) { - return visitUnknown(ModuleDebugFragmentKind::CrossScopeImports, Data); -} -Error ModuleDebugFragmentVisitor::visitILLines(BinaryStreamRef Data) { - return visitUnknown(ModuleDebugFragmentKind::ILLines, Data); -} -Error ModuleDebugFragmentVisitor::visitFuncMDTokenMap(BinaryStreamRef Data) { - return visitUnknown(ModuleDebugFragmentKind::FuncMDTokenMap, Data); -} -Error ModuleDebugFragmentVisitor::visitTypeMDTokenMap(BinaryStreamRef Data) { - return visitUnknown(ModuleDebugFragmentKind::TypeMDTokenMap, Data); -} -Error ModuleDebugFragmentVisitor::visitMergedAssemblyInput( - BinaryStreamRef Data) { - return visitUnknown(ModuleDebugFragmentKind::MergedAssemblyInput, Data); -} -Error ModuleDebugFragmentVisitor::visitCoffSymbolRVA(BinaryStreamRef Data) { - return visitUnknown(ModuleDebugFragmentKind::CoffSymbolRVA, Data); -} - -Error llvm::codeview::visitModuleDebugFragment(const ModuleDebugFragment &R, - ModuleDebugFragmentVisitor &V) { +Error llvm::codeview::visitModuleDebugFragment( + const ModuleDebugFragmentRecord &R, ModuleDebugFragmentVisitor &V) { + BinaryStreamReader Reader(R.getRecordData()); switch (R.kind()) { - case ModuleDebugFragmentKind::Symbols: - return V.visitSymbols(R.getRecordData()); case ModuleDebugFragmentKind::Lines: { - BinaryStreamReader Reader(R.getRecordData()); - const LineFragmentHeader *Header; - if (auto EC = Reader.readObject(Header)) + ModuleDebugLineFragment Fragment; + if (auto EC = Fragment.initialize(Reader)) return EC; - LineInfoArray LineInfos; - if (auto EC = Reader.readArray(LineInfos, Reader.bytesRemaining(), Header)) - return EC; - return V.visitLines(R.getRecordData(), Header, LineInfos); + + return V.visitLines(Fragment); } - case ModuleDebugFragmentKind::StringTable: - return V.visitStringTable(R.getRecordData()); case ModuleDebugFragmentKind::FileChecksums: { - BinaryStreamReader Reader(R.getRecordData()); - FileChecksumArray Checksums; - if (auto EC = Reader.readArray(Checksums, Reader.bytesRemaining())) + ModuleDebugFileChecksumFragment Fragment; + if (auto EC = Fragment.initialize(Reader)) return EC; - return V.visitFileChecksums(R.getRecordData(), Checksums); + + return V.visitFileChecksums(Fragment); + } + default: { + ModuleDebugUnknownFragment Fragment(R.kind(), R.getRecordData()); + return V.visitUnknown(Fragment); } - case ModuleDebugFragmentKind::FrameData: - return V.visitFrameData(R.getRecordData()); - case ModuleDebugFragmentKind::InlineeLines: - return V.visitInlineeLines(R.getRecordData()); - case ModuleDebugFragmentKind::CrossScopeImports: - return V.visitCrossScopeImports(R.getRecordData()); - case ModuleDebugFragmentKind::CrossScopeExports: - return V.visitCrossScopeExports(R.getRecordData()); - case ModuleDebugFragmentKind::ILLines: - return V.visitILLines(R.getRecordData()); - case ModuleDebugFragmentKind::FuncMDTokenMap: - return V.visitFuncMDTokenMap(R.getRecordData()); - case ModuleDebugFragmentKind::TypeMDTokenMap: - return V.visitTypeMDTokenMap(R.getRecordData()); - case ModuleDebugFragmentKind::MergedAssemblyInput: - return V.visitMergedAssemblyInput(R.getRecordData()); - case ModuleDebugFragmentKind::CoffSymbolRVA: - return V.visitCoffSymbolRVA(R.getRecordData()); - default: - return V.visitUnknown(R.kind(), R.getRecordData()); } } |