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