blob: 36731f586d2f141413ff0637ba976d295aef491c [file] [log] [blame]
Adrian McCarthy4d93d662017-03-29 19:27:08 +00001//===- 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
17namespace llvm {
18namespace pdb {
19
Adrian McCarthy31bcb6f2017-06-22 18:43:18 +000020NativeExeSymbol::NativeExeSymbol(NativeSession &Session, uint32_t SymbolId)
21 : NativeRawSymbol(Session, SymbolId), File(Session.getPDBFile()) {}
22
23std::unique_ptr<NativeRawSymbol> NativeExeSymbol::clone() const {
24 return std::make_unique<NativeExeSymbol>(Session, SymbolId);
25}
Adrian McCarthy4d93d662017-03-29 19:27:08 +000026
27std::unique_ptr<IPDBEnumSymbols>
28NativeExeSymbol::findChildren(PDB_SymType Type) const {
29 switch (Type) {
30 case PDB_SymType::Compiland: {
31 auto Dbi = File.getPDBDbiStream();
32 if (Dbi) {
Zachary Turner1eb9a022017-05-04 23:53:29 +000033 const DbiModuleList &Modules = Dbi->modules();
Adrian McCarthy4d93d662017-03-29 19:27:08 +000034 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
46uint32_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
54std::string NativeExeSymbol::getSymbolsFileName() const {
55 return File.getFilePath();
56}
57
58PDB_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
66bool NativeExeSymbol::hasCTypes() const {
67 auto Dbi = File.getPDBDbiStream();
68 if (Dbi)
69 return Dbi->hasCTypes();
70 consumeError(Dbi.takeError());
71 return false;
72}
73
74bool 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