blob: cc3a7448cb8d4d12f04be598ec344b37e6411952 [file] [log] [blame]
Zachary Turner0a43efe2016-04-25 17:38:08 +00001//===- RawSession.cpp - Raw implementation of IPDBSession -------*- C++ -*-===//
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/PDB/Raw/RawSession.h"
Zachary Turner819e77d2016-05-06 20:51:57 +000011
12#include "llvm/DebugInfo/PDB/GenericError.h"
Zachary Turner0a43efe2016-04-25 17:38:08 +000013#include "llvm/DebugInfo/PDB/IPDBEnumChildren.h"
14#include "llvm/DebugInfo/PDB/IPDBSourceFile.h"
15#include "llvm/DebugInfo/PDB/PDBSymbolCompiland.h"
16#include "llvm/DebugInfo/PDB/PDBSymbolExe.h"
17#include "llvm/DebugInfo/PDB/Raw/PDBFile.h"
Zachary Turner819e77d2016-05-06 20:51:57 +000018#include "llvm/DebugInfo/PDB/Raw/RawError.h"
Zachary Turner0a43efe2016-04-25 17:38:08 +000019
20#include "llvm/Support/ErrorOr.h"
21#include "llvm/Support/MemoryBuffer.h"
22
23using namespace llvm;
Zachary Turner2f09b502016-04-29 17:28:47 +000024using namespace llvm::pdb;
Zachary Turner0a43efe2016-04-25 17:38:08 +000025
26RawSession::RawSession(std::unique_ptr<PDBFile> PdbFile)
27 : Pdb(std::move(PdbFile)) {}
28
29RawSession::~RawSession() {}
30
Zachary Turner819e77d2016-05-06 20:51:57 +000031Error RawSession::createFromPdb(StringRef Path,
32 std::unique_ptr<IPDBSession> &Session) {
Zachary Turner0a43efe2016-04-25 17:38:08 +000033
34 ErrorOr<std::unique_ptr<MemoryBuffer>> ErrorOrBuffer =
35 MemoryBuffer::getFileOrSTDIN(Path, /*FileSize=*/-1,
36 /*RequiresNullTerminator=*/false);
37
Zachary Turner819e77d2016-05-06 20:51:57 +000038 if (ErrorOrBuffer.getError())
39 return make_error<GenericError>(generic_error_code::invalid_path, Path);
Zachary Turner0a43efe2016-04-25 17:38:08 +000040
41 std::unique_ptr<MemoryBuffer> &Buffer = ErrorOrBuffer.get();
42
43 std::unique_ptr<PDBFile> File(new PDBFile(std::move(Buffer)));
Zachary Turner819e77d2016-05-06 20:51:57 +000044 if (auto EC = File->parseFileHeaders())
45 return EC;
46 if (auto EC = File->parseStreamData())
47 return EC;
Zachary Turner0a43efe2016-04-25 17:38:08 +000048
49 Session.reset(new RawSession(std::move(File)));
50
Zachary Turner819e77d2016-05-06 20:51:57 +000051 return Error::success();
Zachary Turner0a43efe2016-04-25 17:38:08 +000052}
53
Zachary Turner819e77d2016-05-06 20:51:57 +000054Error RawSession::createFromExe(StringRef Path,
55 std::unique_ptr<IPDBSession> &Session) {
56 return llvm::make_error<RawError>(raw_error_code::feature_unsupported);
Zachary Turner0a43efe2016-04-25 17:38:08 +000057}
58
59uint64_t RawSession::getLoadAddress() const { return 0; }
60
61void RawSession::setLoadAddress(uint64_t Address) {}
62
63std::unique_ptr<PDBSymbolExe> RawSession::getGlobalScope() const {
64 return nullptr;
65}
66
67std::unique_ptr<PDBSymbol> RawSession::getSymbolById(uint32_t SymbolId) const {
68 return nullptr;
69}
70
71std::unique_ptr<PDBSymbol>
72RawSession::findSymbolByAddress(uint64_t Address, PDB_SymType Type) const {
73 return nullptr;
74}
75
76std::unique_ptr<IPDBEnumLineNumbers>
77RawSession::findLineNumbers(const PDBSymbolCompiland &Compiland,
78 const IPDBSourceFile &File) const {
79 return nullptr;
80}
81
82std::unique_ptr<IPDBEnumLineNumbers>
83RawSession::findLineNumbersByAddress(uint64_t Address, uint32_t Length) const {
84 return nullptr;
85}
86
87std::unique_ptr<IPDBEnumSourceFiles>
88RawSession::findSourceFiles(const PDBSymbolCompiland *Compiland,
89 llvm::StringRef Pattern,
90 PDB_NameSearchFlags Flags) const {
91 return nullptr;
92}
93
94std::unique_ptr<IPDBSourceFile>
95RawSession::findOneSourceFile(const PDBSymbolCompiland *Compiland,
96 llvm::StringRef Pattern,
97 PDB_NameSearchFlags Flags) const {
98 return nullptr;
99}
100
101std::unique_ptr<IPDBEnumChildren<PDBSymbolCompiland>>
102RawSession::findCompilandsForSourceFile(llvm::StringRef Pattern,
103 PDB_NameSearchFlags Flags) const {
104 return nullptr;
105}
106
107std::unique_ptr<PDBSymbolCompiland>
108RawSession::findOneCompilandForSourceFile(llvm::StringRef Pattern,
109 PDB_NameSearchFlags Flags) const {
110 return nullptr;
111}
112
113std::unique_ptr<IPDBEnumSourceFiles> RawSession::getAllSourceFiles() const {
114 return nullptr;
115}
116
117std::unique_ptr<IPDBEnumSourceFiles> RawSession::getSourceFilesForCompiland(
118 const PDBSymbolCompiland &Compiland) const {
119 return nullptr;
120}
121
122std::unique_ptr<IPDBSourceFile>
123RawSession::getSourceFileById(uint32_t FileId) const {
124 return nullptr;
125}
126
127std::unique_ptr<IPDBEnumDataStreams> RawSession::getDebugStreams() const {
128 return nullptr;
129}