[ARM] Split large truncating MVE stores
[llvm-complete.git] / lib / DebugInfo / PDB / Native / NativeSession.cpp
blobb45a5881dcb5ca0a3449aeca555900792c77acbf
1 //===- NativeSession.cpp - Native implementation of IPDBSession -*- C++ -*-===//
2 //
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
6 //
7 //===----------------------------------------------------------------------===//
9 #include "llvm/DebugInfo/PDB/Native/NativeSession.h"
11 #include "llvm/ADT/STLExtras.h"
12 #include "llvm/DebugInfo/CodeView/TypeIndex.h"
13 #include "llvm/DebugInfo/PDB/IPDBEnumChildren.h"
14 #include "llvm/DebugInfo/PDB/IPDBSourceFile.h"
15 #include "llvm/DebugInfo/PDB/Native/NativeCompilandSymbol.h"
16 #include "llvm/DebugInfo/PDB/Native/NativeEnumInjectedSources.h"
17 #include "llvm/DebugInfo/PDB/Native/NativeEnumTypes.h"
18 #include "llvm/DebugInfo/PDB/Native/NativeExeSymbol.h"
19 #include "llvm/DebugInfo/PDB/Native/NativeTypeBuiltin.h"
20 #include "llvm/DebugInfo/PDB/Native/NativeTypeEnum.h"
21 #include "llvm/DebugInfo/PDB/Native/PDBFile.h"
22 #include "llvm/DebugInfo/PDB/Native/RawError.h"
23 #include "llvm/DebugInfo/PDB/Native/SymbolCache.h"
24 #include "llvm/DebugInfo/PDB/Native/TpiStream.h"
25 #include "llvm/DebugInfo/PDB/PDBSymbolCompiland.h"
26 #include "llvm/DebugInfo/PDB/PDBSymbolExe.h"
27 #include "llvm/DebugInfo/PDB/PDBSymbolTypeEnum.h"
28 #include "llvm/Support/Allocator.h"
29 #include "llvm/Support/BinaryByteStream.h"
30 #include "llvm/Support/Error.h"
31 #include "llvm/Support/ErrorOr.h"
32 #include "llvm/Support/MemoryBuffer.h"
34 #include <algorithm>
35 #include <cassert>
36 #include <memory>
37 #include <utility>
39 using namespace llvm;
40 using namespace llvm::msf;
41 using namespace llvm::pdb;
43 static DbiStream *getDbiStreamPtr(PDBFile &File) {
44 Expected<DbiStream &> DbiS = File.getPDBDbiStream();
45 if (DbiS)
46 return &DbiS.get();
48 consumeError(DbiS.takeError());
49 return nullptr;
52 NativeSession::NativeSession(std::unique_ptr<PDBFile> PdbFile,
53 std::unique_ptr<BumpPtrAllocator> Allocator)
54 : Pdb(std::move(PdbFile)), Allocator(std::move(Allocator)),
55 Cache(*this, getDbiStreamPtr(*Pdb)) {}
57 NativeSession::~NativeSession() = default;
59 Error NativeSession::createFromPdb(std::unique_ptr<MemoryBuffer> Buffer,
60 std::unique_ptr<IPDBSession> &Session) {
61 StringRef Path = Buffer->getBufferIdentifier();
62 auto Stream = std::make_unique<MemoryBufferByteStream>(
63 std::move(Buffer), llvm::support::little);
65 auto Allocator = std::make_unique<BumpPtrAllocator>();
66 auto File = std::make_unique<PDBFile>(Path, std::move(Stream), *Allocator);
67 if (auto EC = File->parseFileHeaders())
68 return EC;
69 if (auto EC = File->parseStreamData())
70 return EC;
72 Session =
73 std::make_unique<NativeSession>(std::move(File), std::move(Allocator));
75 return Error::success();
78 Error NativeSession::createFromExe(StringRef Path,
79 std::unique_ptr<IPDBSession> &Session) {
80 return make_error<RawError>(raw_error_code::feature_unsupported);
83 uint64_t NativeSession::getLoadAddress() const { return 0; }
85 bool NativeSession::setLoadAddress(uint64_t Address) { return false; }
87 std::unique_ptr<PDBSymbolExe> NativeSession::getGlobalScope() {
88 return PDBSymbol::createAs<PDBSymbolExe>(*this, getNativeGlobalScope());
91 std::unique_ptr<PDBSymbol>
92 NativeSession::getSymbolById(SymIndexId SymbolId) const {
93 return Cache.getSymbolById(SymbolId);
96 bool NativeSession::addressForVA(uint64_t VA, uint32_t &Section,
97 uint32_t &Offset) const {
98 return false;
101 bool NativeSession::addressForRVA(uint32_t VA, uint32_t &Section,
102 uint32_t &Offset) const {
103 return false;
106 std::unique_ptr<PDBSymbol>
107 NativeSession::findSymbolByAddress(uint64_t Address, PDB_SymType Type) const {
108 return nullptr;
111 std::unique_ptr<PDBSymbol>
112 NativeSession::findSymbolByRVA(uint32_t RVA, PDB_SymType Type) const {
113 return nullptr;
116 std::unique_ptr<PDBSymbol>
117 NativeSession::findSymbolBySectOffset(uint32_t Sect, uint32_t Offset,
118 PDB_SymType Type) const {
119 return nullptr;
122 std::unique_ptr<IPDBEnumLineNumbers>
123 NativeSession::findLineNumbers(const PDBSymbolCompiland &Compiland,
124 const IPDBSourceFile &File) const {
125 return nullptr;
128 std::unique_ptr<IPDBEnumLineNumbers>
129 NativeSession::findLineNumbersByAddress(uint64_t Address,
130 uint32_t Length) const {
131 return nullptr;
134 std::unique_ptr<IPDBEnumLineNumbers>
135 NativeSession::findLineNumbersByRVA(uint32_t RVA, uint32_t Length) const {
136 return nullptr;
139 std::unique_ptr<IPDBEnumLineNumbers>
140 NativeSession::findLineNumbersBySectOffset(uint32_t Section, uint32_t Offset,
141 uint32_t Length) const {
142 return nullptr;
145 std::unique_ptr<IPDBEnumSourceFiles>
146 NativeSession::findSourceFiles(const PDBSymbolCompiland *Compiland,
147 StringRef Pattern,
148 PDB_NameSearchFlags Flags) const {
149 return nullptr;
152 std::unique_ptr<IPDBSourceFile>
153 NativeSession::findOneSourceFile(const PDBSymbolCompiland *Compiland,
154 StringRef Pattern,
155 PDB_NameSearchFlags Flags) const {
156 return nullptr;
159 std::unique_ptr<IPDBEnumChildren<PDBSymbolCompiland>>
160 NativeSession::findCompilandsForSourceFile(StringRef Pattern,
161 PDB_NameSearchFlags Flags) const {
162 return nullptr;
165 std::unique_ptr<PDBSymbolCompiland>
166 NativeSession::findOneCompilandForSourceFile(StringRef Pattern,
167 PDB_NameSearchFlags Flags) const {
168 return nullptr;
171 std::unique_ptr<IPDBEnumSourceFiles> NativeSession::getAllSourceFiles() const {
172 return nullptr;
175 std::unique_ptr<IPDBEnumSourceFiles> NativeSession::getSourceFilesForCompiland(
176 const PDBSymbolCompiland &Compiland) const {
177 return nullptr;
180 std::unique_ptr<IPDBSourceFile>
181 NativeSession::getSourceFileById(uint32_t FileId) const {
182 return nullptr;
185 std::unique_ptr<IPDBEnumDataStreams> NativeSession::getDebugStreams() const {
186 return nullptr;
189 std::unique_ptr<IPDBEnumTables> NativeSession::getEnumTables() const {
190 return nullptr;
193 std::unique_ptr<IPDBEnumInjectedSources>
194 NativeSession::getInjectedSources() const {
195 auto ISS = Pdb->getInjectedSourceStream();
196 if (!ISS) {
197 consumeError(ISS.takeError());
198 return nullptr;
200 auto Strings = Pdb->getStringTable();
201 if (!Strings) {
202 consumeError(Strings.takeError());
203 return nullptr;
205 return std::make_unique<NativeEnumInjectedSources>(*Pdb, *ISS, *Strings);
208 std::unique_ptr<IPDBEnumSectionContribs>
209 NativeSession::getSectionContribs() const {
210 return nullptr;
213 std::unique_ptr<IPDBEnumFrameData>
214 NativeSession::getFrameData() const {
215 return nullptr;
218 void NativeSession::initializeExeSymbol() {
219 if (ExeSymbol == 0)
220 ExeSymbol = Cache.createSymbol<NativeExeSymbol>();
223 NativeExeSymbol &NativeSession::getNativeGlobalScope() const {
224 const_cast<NativeSession &>(*this).initializeExeSymbol();
226 return Cache.getNativeSymbolById<NativeExeSymbol>(ExeSymbol);