blob: bb52560be167a84c5e83e152f1760dc8a55ebd05 [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
20NativeExeSymbol::NativeExeSymbol(NativeSession &Session)
21 : NativeRawSymbol(Session), File(Session.getPDBFile()) {}
22
23std::unique_ptr<IPDBEnumSymbols>
24NativeExeSymbol::findChildren(PDB_SymType Type) const {
25 switch (Type) {
26 case PDB_SymType::Compiland: {
27 auto Dbi = File.getPDBDbiStream();
28 if (Dbi) {
Zachary Turner1eb9a022017-05-04 23:53:29 +000029 const DbiModuleList &Modules = Dbi->modules();
Adrian McCarthy4d93d662017-03-29 19:27:08 +000030 return std::unique_ptr<IPDBEnumSymbols>(
31 new NativeEnumModules(Session, Modules));
32 }
33 consumeError(Dbi.takeError());
34 break;
35 }
36 default:
37 break;
38 }
39 return nullptr;
40}
41
42uint32_t NativeExeSymbol::getAge() const {
43 auto IS = File.getPDBInfoStream();
44 if (IS)
45 return IS->getAge();
46 consumeError(IS.takeError());
47 return 0;
48}
49
50std::string NativeExeSymbol::getSymbolsFileName() const {
51 return File.getFilePath();
52}
53
54PDB_UniqueId NativeExeSymbol::getGuid() const {
55 auto IS = File.getPDBInfoStream();
56 if (IS)
57 return IS->getGuid();
58 consumeError(IS.takeError());
59 return PDB_UniqueId{{0}};
60}
61
62bool NativeExeSymbol::hasCTypes() const {
63 auto Dbi = File.getPDBDbiStream();
64 if (Dbi)
65 return Dbi->hasCTypes();
66 consumeError(Dbi.takeError());
67 return false;
68}
69
70bool NativeExeSymbol::hasPrivateSymbols() const {
71 auto Dbi = File.getPDBDbiStream();
72 if (Dbi)
73 return !Dbi->isStripped();
74 consumeError(Dbi.takeError());
75 return false;
76}
77
78} // namespace pdb
79} // namespace llvm