//===- NativeSession.cpp - Native implementation of IPDBSession -*- C++ -*-===// // // The LLVM Compiler Infrastructure // // This file is distributed under the University of Illinois Open Source // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// #include "llvm/DebugInfo/PDB/Native/NativeSession.h" #include "llvm/ADT/STLExtras.h" #include "llvm/DebugInfo/PDB/GenericError.h" #include "llvm/DebugInfo/PDB/IPDBEnumChildren.h" #include "llvm/DebugInfo/PDB/IPDBSourceFile.h" #include "llvm/DebugInfo/PDB/Native/NativeExeSymbol.h" #include "llvm/DebugInfo/PDB/Native/PDBFile.h" #include "llvm/DebugInfo/PDB/Native/RawError.h" #include "llvm/DebugInfo/PDB/PDBSymbolCompiland.h" #include "llvm/DebugInfo/PDB/PDBSymbolExe.h" #include "llvm/Support/Allocator.h" #include "llvm/Support/BinaryByteStream.h" #include "llvm/Support/Error.h" #include "llvm/Support/ErrorOr.h" #include "llvm/Support/MemoryBuffer.h" #include #include using namespace llvm; using namespace llvm::msf; using namespace llvm::pdb; NativeSession::NativeSession(std::unique_ptr PdbFile, std::unique_ptr Allocator) : Pdb(std::move(PdbFile)), Allocator(std::move(Allocator)) {} NativeSession::~NativeSession() = default; Error NativeSession::createFromPdb(StringRef Path, std::unique_ptr &Session) { ErrorOr> ErrorOrBuffer = MemoryBuffer::getFileOrSTDIN(Path, /*FileSize=*/-1, /*RequiresNullTerminator=*/false); if (!ErrorOrBuffer) return make_error(generic_error_code::invalid_path); std::unique_ptr Buffer = std::move(*ErrorOrBuffer); auto Stream = llvm::make_unique( std::move(Buffer), llvm::support::little); auto Allocator = llvm::make_unique(); auto File = llvm::make_unique(Path, std::move(Stream), *Allocator); if (auto EC = File->parseFileHeaders()) return EC; if (auto EC = File->parseStreamData()) return EC; Session = llvm::make_unique(std::move(File), std::move(Allocator)); return Error::success(); } Error NativeSession::createFromExe(StringRef Path, std::unique_ptr &Session) { return make_error(raw_error_code::feature_unsupported); } uint64_t NativeSession::getLoadAddress() const { return 0; } void NativeSession::setLoadAddress(uint64_t Address) {} std::unique_ptr NativeSession::getGlobalScope() const { auto RawSymbol = llvm::make_unique(const_cast(*this)); auto PdbSymbol(PDBSymbol::create(*this, std::move(RawSymbol))); std::unique_ptr ExeSymbol( static_cast(PdbSymbol.release())); return ExeSymbol; } std::unique_ptr NativeSession::getSymbolById(uint32_t SymbolId) const { return nullptr; } std::unique_ptr NativeSession::findSymbolByAddress(uint64_t Address, PDB_SymType Type) const { return nullptr; } std::unique_ptr NativeSession::findLineNumbers(const PDBSymbolCompiland &Compiland, const IPDBSourceFile &File) const { return nullptr; } std::unique_ptr NativeSession::findLineNumbersByAddress(uint64_t Address, uint32_t Length) const { return nullptr; } std::unique_ptr NativeSession::findSourceFiles(const PDBSymbolCompiland *Compiland, StringRef Pattern, PDB_NameSearchFlags Flags) const { return nullptr; } std::unique_ptr NativeSession::findOneSourceFile(const PDBSymbolCompiland *Compiland, StringRef Pattern, PDB_NameSearchFlags Flags) const { return nullptr; } std::unique_ptr> NativeSession::findCompilandsForSourceFile(StringRef Pattern, PDB_NameSearchFlags Flags) const { return nullptr; } std::unique_ptr NativeSession::findOneCompilandForSourceFile(StringRef Pattern, PDB_NameSearchFlags Flags) const { return nullptr; } std::unique_ptr NativeSession::getAllSourceFiles() const { return nullptr; } std::unique_ptr NativeSession::getSourceFilesForCompiland( const PDBSymbolCompiland &Compiland) const { return nullptr; } std::unique_ptr NativeSession::getSourceFileById(uint32_t FileId) const { return nullptr; } std::unique_ptr NativeSession::getDebugStreams() const { return nullptr; }