Adrian McCarthy | 4d93d66 | 2017-03-29 19:27:08 +0000 | [diff] [blame] | 1 | //===- NativeExeSymbol.cpp - native impl for PDBSymbolExe -------*- 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/Native/NativeExeSymbol.h" |
| 11 | |
Adrian McCarthy | 4aedc81 | 2017-06-22 18:57:51 +0000 | [diff] [blame] | 12 | #include "llvm/ADT/STLExtras.h" |
Adrian McCarthy | 4d93d66 | 2017-03-29 19:27:08 +0000 | [diff] [blame] | 13 | #include "llvm/DebugInfo/PDB/Native/DbiStream.h" |
| 14 | #include "llvm/DebugInfo/PDB/Native/InfoStream.h" |
| 15 | #include "llvm/DebugInfo/PDB/Native/NativeEnumModules.h" |
| 16 | #include "llvm/DebugInfo/PDB/Native/PDBFile.h" |
| 17 | |
| 18 | namespace llvm { |
| 19 | namespace pdb { |
| 20 | |
Adrian McCarthy | 8d090fc | 2017-07-12 19:38:11 +0000 | [diff] [blame] | 21 | NativeExeSymbol::NativeExeSymbol(NativeSession &Session, SymIndexId SymbolId) |
Adrian McCarthy | 31bcb6f | 2017-06-22 18:43:18 +0000 | [diff] [blame] | 22 | : NativeRawSymbol(Session, SymbolId), File(Session.getPDBFile()) {} |
| 23 | |
| 24 | std::unique_ptr<NativeRawSymbol> NativeExeSymbol::clone() const { |
Adrian McCarthy | 4aedc81 | 2017-06-22 18:57:51 +0000 | [diff] [blame] | 25 | return llvm::make_unique<NativeExeSymbol>(Session, SymbolId); |
Adrian McCarthy | 31bcb6f | 2017-06-22 18:43:18 +0000 | [diff] [blame] | 26 | } |
Adrian McCarthy | 4d93d66 | 2017-03-29 19:27:08 +0000 | [diff] [blame] | 27 | |
| 28 | std::unique_ptr<IPDBEnumSymbols> |
| 29 | NativeExeSymbol::findChildren(PDB_SymType Type) const { |
| 30 | switch (Type) { |
| 31 | case PDB_SymType::Compiland: { |
| 32 | auto Dbi = File.getPDBDbiStream(); |
| 33 | if (Dbi) { |
Zachary Turner | 1eb9a02 | 2017-05-04 23:53:29 +0000 | [diff] [blame] | 34 | const DbiModuleList &Modules = Dbi->modules(); |
Adrian McCarthy | 4d93d66 | 2017-03-29 19:27:08 +0000 | [diff] [blame] | 35 | return std::unique_ptr<IPDBEnumSymbols>( |
| 36 | new NativeEnumModules(Session, Modules)); |
| 37 | } |
| 38 | consumeError(Dbi.takeError()); |
| 39 | break; |
| 40 | } |
| 41 | default: |
| 42 | break; |
| 43 | } |
| 44 | return nullptr; |
| 45 | } |
| 46 | |
| 47 | uint32_t NativeExeSymbol::getAge() const { |
| 48 | auto IS = File.getPDBInfoStream(); |
| 49 | if (IS) |
| 50 | return IS->getAge(); |
| 51 | consumeError(IS.takeError()); |
| 52 | return 0; |
| 53 | } |
| 54 | |
| 55 | std::string NativeExeSymbol::getSymbolsFileName() const { |
| 56 | return File.getFilePath(); |
| 57 | } |
| 58 | |
Reid Kleckner | 67653ee | 2017-07-17 23:59:44 +0000 | [diff] [blame^] | 59 | codeview::GUID NativeExeSymbol::getGuid() const { |
Adrian McCarthy | 4d93d66 | 2017-03-29 19:27:08 +0000 | [diff] [blame] | 60 | auto IS = File.getPDBInfoStream(); |
| 61 | if (IS) |
| 62 | return IS->getGuid(); |
| 63 | consumeError(IS.takeError()); |
Reid Kleckner | 67653ee | 2017-07-17 23:59:44 +0000 | [diff] [blame^] | 64 | return codeview::GUID{{0}}; |
Adrian McCarthy | 4d93d66 | 2017-03-29 19:27:08 +0000 | [diff] [blame] | 65 | } |
| 66 | |
| 67 | bool NativeExeSymbol::hasCTypes() const { |
| 68 | auto Dbi = File.getPDBDbiStream(); |
| 69 | if (Dbi) |
| 70 | return Dbi->hasCTypes(); |
| 71 | consumeError(Dbi.takeError()); |
| 72 | return false; |
| 73 | } |
| 74 | |
| 75 | bool NativeExeSymbol::hasPrivateSymbols() const { |
| 76 | auto Dbi = File.getPDBDbiStream(); |
| 77 | if (Dbi) |
| 78 | return !Dbi->isStripped(); |
| 79 | consumeError(Dbi.takeError()); |
| 80 | return false; |
| 81 | } |
| 82 | |
| 83 | } // namespace pdb |
| 84 | } // namespace llvm |