Zachary Turner | deb3913 | 2017-06-09 00:28:08 +0000 | [diff] [blame] | 1 | //===- DebugSubsectionVisitor.cpp -------------------------------*- C++ -*-===// |
Zachary Turner | 8c099fe | 2017-05-30 16:36:15 +0000 | [diff] [blame] | 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | |
| 10 | #include "llvm/DebugInfo/CodeView/DebugSubsectionVisitor.h" |
| 11 | |
| 12 | #include "llvm/DebugInfo/CodeView/DebugChecksumsSubsection.h" |
Zachary Turner | 349c18f | 2017-06-05 21:40:33 +0000 | [diff] [blame] | 13 | #include "llvm/DebugInfo/CodeView/DebugCrossExSubsection.h" |
| 14 | #include "llvm/DebugInfo/CodeView/DebugCrossImpSubsection.h" |
Zachary Turner | deb3913 | 2017-06-09 00:28:08 +0000 | [diff] [blame] | 15 | #include "llvm/DebugInfo/CodeView/DebugFrameDataSubsection.h" |
Zachary Turner | 8c099fe | 2017-05-30 16:36:15 +0000 | [diff] [blame] | 16 | #include "llvm/DebugInfo/CodeView/DebugInlineeLinesSubsection.h" |
| 17 | #include "llvm/DebugInfo/CodeView/DebugLinesSubsection.h" |
Zachary Turner | 1bf7762 | 2017-06-08 23:49:01 +0000 | [diff] [blame] | 18 | #include "llvm/DebugInfo/CodeView/DebugStringTableSubsection.h" |
Zachary Turner | 8c099fe | 2017-05-30 16:36:15 +0000 | [diff] [blame] | 19 | #include "llvm/DebugInfo/CodeView/DebugSubsectionRecord.h" |
Zachary Turner | 3226fe9 | 2017-06-09 20:46:52 +0000 | [diff] [blame] | 20 | #include "llvm/DebugInfo/CodeView/DebugSymbolRVASubsection.h" |
Zachary Turner | deb3913 | 2017-06-09 00:28:08 +0000 | [diff] [blame] | 21 | #include "llvm/DebugInfo/CodeView/DebugSymbolsSubsection.h" |
Zachary Turner | 8c099fe | 2017-05-30 16:36:15 +0000 | [diff] [blame] | 22 | #include "llvm/DebugInfo/CodeView/DebugUnknownSubsection.h" |
| 23 | #include "llvm/Support/BinaryStreamReader.h" |
| 24 | #include "llvm/Support/BinaryStreamRef.h" |
| 25 | |
| 26 | using namespace llvm; |
| 27 | using namespace llvm::codeview; |
| 28 | |
Zachary Turner | a8cfc29 | 2017-06-14 15:59:27 +0000 | [diff] [blame] | 29 | Error llvm::codeview::visitDebugSubsection( |
| 30 | const DebugSubsectionRecord &R, DebugSubsectionVisitor &V, |
| 31 | const StringsAndChecksumsRef &State) { |
Zachary Turner | 8c099fe | 2017-05-30 16:36:15 +0000 | [diff] [blame] | 32 | BinaryStreamReader Reader(R.getRecordData()); |
| 33 | switch (R.kind()) { |
| 34 | case DebugSubsectionKind::Lines: { |
| 35 | DebugLinesSubsectionRef Fragment; |
| 36 | if (auto EC = Fragment.initialize(Reader)) |
| 37 | return EC; |
| 38 | |
Zachary Turner | 1bf7762 | 2017-06-08 23:49:01 +0000 | [diff] [blame] | 39 | return V.visitLines(Fragment, State); |
Zachary Turner | 8c099fe | 2017-05-30 16:36:15 +0000 | [diff] [blame] | 40 | } |
| 41 | case DebugSubsectionKind::FileChecksums: { |
| 42 | DebugChecksumsSubsectionRef Fragment; |
| 43 | if (auto EC = Fragment.initialize(Reader)) |
| 44 | return EC; |
| 45 | |
Zachary Turner | 1bf7762 | 2017-06-08 23:49:01 +0000 | [diff] [blame] | 46 | return V.visitFileChecksums(Fragment, State); |
Zachary Turner | 8c099fe | 2017-05-30 16:36:15 +0000 | [diff] [blame] | 47 | } |
| 48 | case DebugSubsectionKind::InlineeLines: { |
| 49 | DebugInlineeLinesSubsectionRef Fragment; |
| 50 | if (auto EC = Fragment.initialize(Reader)) |
| 51 | return EC; |
Zachary Turner | 1bf7762 | 2017-06-08 23:49:01 +0000 | [diff] [blame] | 52 | return V.visitInlineeLines(Fragment, State); |
Zachary Turner | 8c099fe | 2017-05-30 16:36:15 +0000 | [diff] [blame] | 53 | } |
Zachary Turner | 349c18f | 2017-06-05 21:40:33 +0000 | [diff] [blame] | 54 | case DebugSubsectionKind::CrossScopeExports: { |
| 55 | DebugCrossModuleExportsSubsectionRef Section; |
| 56 | if (auto EC = Section.initialize(Reader)) |
| 57 | return EC; |
Zachary Turner | 1bf7762 | 2017-06-08 23:49:01 +0000 | [diff] [blame] | 58 | return V.visitCrossModuleExports(Section, State); |
Zachary Turner | 349c18f | 2017-06-05 21:40:33 +0000 | [diff] [blame] | 59 | } |
| 60 | case DebugSubsectionKind::CrossScopeImports: { |
| 61 | DebugCrossModuleImportsSubsectionRef Section; |
| 62 | if (auto EC = Section.initialize(Reader)) |
| 63 | return EC; |
Zachary Turner | 1bf7762 | 2017-06-08 23:49:01 +0000 | [diff] [blame] | 64 | return V.visitCrossModuleImports(Section, State); |
Zachary Turner | 349c18f | 2017-06-05 21:40:33 +0000 | [diff] [blame] | 65 | } |
Zachary Turner | deb3913 | 2017-06-09 00:28:08 +0000 | [diff] [blame] | 66 | case DebugSubsectionKind::Symbols: { |
| 67 | DebugSymbolsSubsectionRef Section; |
| 68 | if (auto EC = Section.initialize(Reader)) |
| 69 | return EC; |
| 70 | return V.visitSymbols(Section, State); |
| 71 | } |
| 72 | case DebugSubsectionKind::StringTable: { |
| 73 | DebugStringTableSubsectionRef Section; |
| 74 | if (auto EC = Section.initialize(Reader)) |
| 75 | return EC; |
| 76 | return V.visitStringTable(Section, State); |
| 77 | } |
| 78 | case DebugSubsectionKind::FrameData: { |
| 79 | DebugFrameDataSubsectionRef Section; |
| 80 | if (auto EC = Section.initialize(Reader)) |
| 81 | return EC; |
| 82 | return V.visitFrameData(Section, State); |
| 83 | } |
Zachary Turner | 3226fe9 | 2017-06-09 20:46:52 +0000 | [diff] [blame] | 84 | case DebugSubsectionKind::CoffSymbolRVA: { |
| 85 | DebugSymbolRVASubsectionRef Section; |
| 86 | if (auto EC = Section.initialize(Reader)) |
| 87 | return EC; |
| 88 | return V.visitCOFFSymbolRVAs(Section, State); |
| 89 | } |
Zachary Turner | 8c099fe | 2017-05-30 16:36:15 +0000 | [diff] [blame] | 90 | default: { |
| 91 | DebugUnknownSubsectionRef Fragment(R.kind(), R.getRecordData()); |
| 92 | return V.visitUnknown(Fragment); |
| 93 | } |
| 94 | } |
| 95 | } |