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