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 
12 #include "llvm/DebugInfo/PDB/Native/DbiStream.h"
13 #include "llvm/DebugInfo/PDB/Native/InfoStream.h"
14 #include "llvm/DebugInfo/PDB/Native/NativeEnumModules.h"
15 #include "llvm/DebugInfo/PDB/Native/PDBFile.h"
16 
17 namespace llvm {
18 namespace pdb {
19 
20 NativeExeSymbol::NativeExeSymbol(NativeSession &Session, uint32_t SymbolId)
21     : NativeRawSymbol(Session, SymbolId), File(Session.getPDBFile()) {}
22 
23 std::unique_ptr<NativeRawSymbol> NativeExeSymbol::clone() const {
24   return std::make_unique<NativeExeSymbol>(Session, SymbolId);
25 }
26 
27 std::unique_ptr<IPDBEnumSymbols>
28 NativeExeSymbol::findChildren(PDB_SymType Type) const {
29   switch (Type) {
30   case PDB_SymType::Compiland: {
31     auto Dbi = File.getPDBDbiStream();
32     if (Dbi) {
33       const DbiModuleList &Modules = Dbi->modules();
34       return std::unique_ptr<IPDBEnumSymbols>(
35           new NativeEnumModules(Session, Modules));
36     }
37     consumeError(Dbi.takeError());
38     break;
39   }
40   default:
41     break;
42   }
43   return nullptr;
44 }
45 
46 uint32_t NativeExeSymbol::getAge() const {
47   auto IS = File.getPDBInfoStream();
48   if (IS)
49     return IS->getAge();
50   consumeError(IS.takeError());
51   return 0;
52 }
53 
54 std::string NativeExeSymbol::getSymbolsFileName() const {
55   return File.getFilePath();
56 }
57 
58 PDB_UniqueId NativeExeSymbol::getGuid() const {
59   auto IS = File.getPDBInfoStream();
60   if (IS)
61     return IS->getGuid();
62   consumeError(IS.takeError());
63   return PDB_UniqueId{{0}};
64 }
65 
66 bool NativeExeSymbol::hasCTypes() const {
67   auto Dbi = File.getPDBDbiStream();
68   if (Dbi)
69     return Dbi->hasCTypes();
70   consumeError(Dbi.takeError());
71   return false;
72 }
73 
74 bool NativeExeSymbol::hasPrivateSymbols() const {
75   auto Dbi = File.getPDBDbiStream();
76   if (Dbi)
77     return !Dbi->isStripped();
78   consumeError(Dbi.takeError());
79   return false;
80 }
81 
82 } // namespace pdb
83 } // namespace llvm
84