blob: 7968b6a2d757577fc2ea624805f62a03c74d4894 [file] [log] [blame]
Zachary Turnerdeb39132017-06-09 00:28:08 +00001//===- DebugSubsectionVisitor.cpp -------------------------------*- C++ -*-===//
Zachary Turner8c099fe2017-05-30 16:36:15 +00002//
Chandler Carruth2946cd72019-01-19 08:50:56 +00003// 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 Turner8c099fe2017-05-30 16:36:15 +00006//
7//===----------------------------------------------------------------------===//
8
9#include "llvm/DebugInfo/CodeView/DebugSubsectionVisitor.h"
10
11#include "llvm/DebugInfo/CodeView/DebugChecksumsSubsection.h"
Zachary Turner349c18f2017-06-05 21:40:33 +000012#include "llvm/DebugInfo/CodeView/DebugCrossExSubsection.h"
13#include "llvm/DebugInfo/CodeView/DebugCrossImpSubsection.h"
Zachary Turnerdeb39132017-06-09 00:28:08 +000014#include "llvm/DebugInfo/CodeView/DebugFrameDataSubsection.h"
Zachary Turner8c099fe2017-05-30 16:36:15 +000015#include "llvm/DebugInfo/CodeView/DebugInlineeLinesSubsection.h"
16#include "llvm/DebugInfo/CodeView/DebugLinesSubsection.h"
Zachary Turner1bf77622017-06-08 23:49:01 +000017#include "llvm/DebugInfo/CodeView/DebugStringTableSubsection.h"
Zachary Turner8c099fe2017-05-30 16:36:15 +000018#include "llvm/DebugInfo/CodeView/DebugSubsectionRecord.h"
Zachary Turner3226fe92017-06-09 20:46:52 +000019#include "llvm/DebugInfo/CodeView/DebugSymbolRVASubsection.h"
Zachary Turnerdeb39132017-06-09 00:28:08 +000020#include "llvm/DebugInfo/CodeView/DebugSymbolsSubsection.h"
Zachary Turner8c099fe2017-05-30 16:36:15 +000021#include "llvm/DebugInfo/CodeView/DebugUnknownSubsection.h"
22#include "llvm/Support/BinaryStreamReader.h"
23#include "llvm/Support/BinaryStreamRef.h"
24
25using namespace llvm;
26using namespace llvm::codeview;
27
Zachary Turnera8cfc292017-06-14 15:59:27 +000028Error llvm::codeview::visitDebugSubsection(
29 const DebugSubsectionRecord &R, DebugSubsectionVisitor &V,
30 const StringsAndChecksumsRef &State) {
Zachary Turner8c099fe2017-05-30 16:36:15 +000031 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 Turner1bf77622017-06-08 23:49:01 +000038 return V.visitLines(Fragment, State);
Zachary Turner8c099fe2017-05-30 16:36:15 +000039 }
40 case DebugSubsectionKind::FileChecksums: {
41 DebugChecksumsSubsectionRef Fragment;
42 if (auto EC = Fragment.initialize(Reader))
43 return EC;
44
Zachary Turner1bf77622017-06-08 23:49:01 +000045 return V.visitFileChecksums(Fragment, State);
Zachary Turner8c099fe2017-05-30 16:36:15 +000046 }
47 case DebugSubsectionKind::InlineeLines: {
48 DebugInlineeLinesSubsectionRef Fragment;
49 if (auto EC = Fragment.initialize(Reader))
50 return EC;
Zachary Turner1bf77622017-06-08 23:49:01 +000051 return V.visitInlineeLines(Fragment, State);
Zachary Turner8c099fe2017-05-30 16:36:15 +000052 }
Zachary Turner349c18f2017-06-05 21:40:33 +000053 case DebugSubsectionKind::CrossScopeExports: {
54 DebugCrossModuleExportsSubsectionRef Section;
55 if (auto EC = Section.initialize(Reader))
56 return EC;
Zachary Turner1bf77622017-06-08 23:49:01 +000057 return V.visitCrossModuleExports(Section, State);
Zachary Turner349c18f2017-06-05 21:40:33 +000058 }
59 case DebugSubsectionKind::CrossScopeImports: {
60 DebugCrossModuleImportsSubsectionRef Section;
61 if (auto EC = Section.initialize(Reader))
62 return EC;
Zachary Turner1bf77622017-06-08 23:49:01 +000063 return V.visitCrossModuleImports(Section, State);
Zachary Turner349c18f2017-06-05 21:40:33 +000064 }
Zachary Turnerdeb39132017-06-09 00:28:08 +000065 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 Turner3226fe92017-06-09 20:46:52 +000083 case DebugSubsectionKind::CoffSymbolRVA: {
84 DebugSymbolRVASubsectionRef Section;
85 if (auto EC = Section.initialize(Reader))
86 return EC;
87 return V.visitCOFFSymbolRVAs(Section, State);
88 }
Zachary Turner8c099fe2017-05-30 16:36:15 +000089 default: {
90 DebugUnknownSubsectionRef Fragment(R.kind(), R.getRecordData());
91 return V.visitUnknown(Fragment);
92 }
93 }
94}