LLVM  4.0.0
RawSession.cpp
Go to the documentation of this file.
1 //===- 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/ADT/STLExtras.h"
20 #include "llvm/Support/Allocator.h"
21 #include "llvm/Support/Error.h"
22 #include "llvm/Support/ErrorOr.h"
24 #include <algorithm>
25 #include <memory>
26 
27 using namespace llvm;
28 using namespace llvm::msf;
29 using namespace llvm::pdb;
30 
31 RawSession::RawSession(std::unique_ptr<PDBFile> PdbFile,
32  std::unique_ptr<BumpPtrAllocator> Allocator)
33  : Pdb(std::move(PdbFile)), Allocator(std::move(Allocator)) {}
34 
35 RawSession::~RawSession() = default;
36 
38  std::unique_ptr<IPDBSession> &Session) {
40  MemoryBuffer::getFileOrSTDIN(Path, /*FileSize=*/-1,
41  /*RequiresNullTerminator=*/false);
42  if (!ErrorOrBuffer)
43  return make_error<GenericError>(generic_error_code::invalid_path);
44 
45  std::unique_ptr<MemoryBuffer> Buffer = std::move(*ErrorOrBuffer);
46  auto Stream = llvm::make_unique<MemoryBufferByteStream>(std::move(Buffer));
47 
48  auto Allocator = llvm::make_unique<BumpPtrAllocator>();
49  auto File = llvm::make_unique<PDBFile>(std::move(Stream), *Allocator);
50  if (auto EC = File->parseFileHeaders())
51  return EC;
52  if (auto EC = File->parseStreamData())
53  return EC;
54 
55  Session =
56  llvm::make_unique<RawSession>(std::move(File), std::move(Allocator));
57 
58  return Error::success();
59 }
60 
62  std::unique_ptr<IPDBSession> &Session) {
63  return make_error<RawError>(raw_error_code::feature_unsupported);
64 }
65 
66 uint64_t RawSession::getLoadAddress() const { return 0; }
67 
69 
70 std::unique_ptr<PDBSymbolExe> RawSession::getGlobalScope() const {
71  return nullptr;
72 }
73 
74 std::unique_ptr<PDBSymbol> RawSession::getSymbolById(uint32_t SymbolId) const {
75  return nullptr;
76 }
77 
78 std::unique_ptr<PDBSymbol>
80  return nullptr;
81 }
82 
83 std::unique_ptr<IPDBEnumLineNumbers>
85  const IPDBSourceFile &File) const {
86  return nullptr;
87 }
88 
89 std::unique_ptr<IPDBEnumLineNumbers>
91  return nullptr;
92 }
93 
94 std::unique_ptr<IPDBEnumSourceFiles>
96  StringRef Pattern,
97  PDB_NameSearchFlags Flags) const {
98  return nullptr;
99 }
100 
101 std::unique_ptr<IPDBSourceFile>
103  StringRef Pattern,
104  PDB_NameSearchFlags Flags) const {
105  return nullptr;
106 }
107 
108 std::unique_ptr<IPDBEnumChildren<PDBSymbolCompiland>>
110  PDB_NameSearchFlags Flags) const {
111  return nullptr;
112 }
113 
114 std::unique_ptr<PDBSymbolCompiland>
116  PDB_NameSearchFlags Flags) const {
117  return nullptr;
118 }
119 
120 std::unique_ptr<IPDBEnumSourceFiles> RawSession::getAllSourceFiles() const {
121  return nullptr;
122 }
123 
124 std::unique_ptr<IPDBEnumSourceFiles> RawSession::getSourceFilesForCompiland(
125  const PDBSymbolCompiland &Compiland) const {
126  return nullptr;
127 }
128 
129 std::unique_ptr<IPDBSourceFile>
131  return nullptr;
132 }
133 
134 std::unique_ptr<IPDBEnumDataStreams> RawSession::getDebugStreams() const {
135  return nullptr;
136 }
Represents either an error or a value T.
Definition: ErrorOr.h:68
void setLoadAddress(uint64_t Address) override
Definition: RawSession.cpp:68
std::unique_ptr< IPDBSourceFile > findOneSourceFile(const PDBSymbolCompiland *Compiland, llvm::StringRef Pattern, PDB_NameSearchFlags Flags) const override
Definition: RawSession.cpp:102
PDB_NameSearchFlags
Defines flags used for enumerating child symbols.
Definition: PDBTypes.h:91
std::unique_ptr< PDBSymbolExe > getGlobalScope() const override
Definition: RawSession.cpp:70
This file defines the MallocAllocator and BumpPtrAllocator interfaces.
IPDBSourceFile defines an interface used to represent source files whose information are stored in th...
std::unique_ptr< IPDBEnumLineNumbers > findLineNumbersByAddress(uint64_t Address, uint32_t Length) const override
Definition: RawSession.cpp:90
std::unique_ptr< IPDBEnumSourceFiles > findSourceFiles(const PDBSymbolCompiland *Compiland, llvm::StringRef Pattern, PDB_NameSearchFlags Flags) const override
Definition: RawSession.cpp:95
struct fuzzer::@269 Flags
std::unique_ptr< PDBSymbol > getSymbolById(uint32_t SymbolId) const override
Definition: RawSession.cpp:74
std::unique_ptr< PDBSymbolCompiland > findOneCompilandForSourceFile(llvm::StringRef Pattern, PDB_NameSearchFlags Flags) const override
Definition: RawSession.cpp:115
std::unique_ptr< IPDBSourceFile > getSourceFileById(uint32_t FileId) const override
Definition: RawSession.cpp:130
PDB_SymType
These values correspond to the SymTagEnum enumeration, and are documented here: https://msdn.microsoft.com/en-us/library/bkedss5f.aspx.
Definition: PDBTypes.h:162
std::unique_ptr< IPDBEnumSourceFiles > getAllSourceFiles() const override
Definition: RawSession.cpp:120
The instances of the Type class are immutable: once they are created, they are never changed...
Definition: Type.h:45
std::unique_ptr< IPDBEnumDataStreams > getDebugStreams() const override
Definition: RawSession.cpp:134
Greedy Register Allocator
std::unique_ptr< IPDBEnumChildren< PDBSymbolCompiland > > findCompilandsForSourceFile(llvm::StringRef Pattern, PDB_NameSearchFlags Flags) const override
Definition: RawSession.cpp:109
static Error createFromPdb(StringRef Path, std::unique_ptr< IPDBSession > &Session)
Definition: RawSession.cpp:37
static ErrorSuccess success()
Create a success value.
std::unique_ptr< IPDBEnumLineNumbers > findLineNumbers(const PDBSymbolCompiland &Compiland, const IPDBSourceFile &File) const override
Definition: RawSession.cpp:84
std::unique_ptr< PDBSymbol > findSymbolByAddress(uint64_t Address, PDB_SymType Type) const override
Definition: RawSession.cpp:79
static ErrorOr< std::unique_ptr< MemoryBuffer > > getFileOrSTDIN(const Twine &Filename, int64_t FileSize=-1, bool RequiresNullTerminator=true)
Open the specified file as a MemoryBuffer, or open stdin if the Filename is "-".
std::unique_ptr< IPDBEnumSourceFiles > getSourceFilesForCompiland(const PDBSymbolCompiland &Compiland) const override
Definition: RawSession.cpp:124
Provides ErrorOr<T> smart pointer.
static Error createFromExe(StringRef Path, std::unique_ptr< IPDBSession > &Session)
Definition: RawSession.cpp:61
Lightweight error class with error context and mandatory checking.
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:47
uint64_t getLoadAddress() const override
Definition: RawSession.cpp:66