121
|
1 //===- NativeExeSymbol.cpp - native impl for PDBSymbolExe -------*- C++ -*-===//
|
|
2 //
|
147
|
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
4 // See https://llvm.org/LICENSE.txt for license information.
|
|
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
121
|
6 //
|
|
7 //===----------------------------------------------------------------------===//
|
|
8
|
|
9 #include "llvm/DebugInfo/PDB/Native/NativeExeSymbol.h"
|
|
10
|
|
11 #include "llvm/ADT/STLExtras.h"
|
|
12 #include "llvm/DebugInfo/PDB/Native/DbiStream.h"
|
|
13 #include "llvm/DebugInfo/PDB/Native/InfoStream.h"
|
147
|
14 #include "llvm/DebugInfo/PDB/Native/NativeCompilandSymbol.h"
|
121
|
15 #include "llvm/DebugInfo/PDB/Native/NativeEnumModules.h"
|
|
16 #include "llvm/DebugInfo/PDB/Native/PDBFile.h"
|
147
|
17 #include "llvm/DebugInfo/PDB/Native/SymbolCache.h"
|
|
18 #include "llvm/DebugInfo/PDB/PDBSymbolCompiland.h"
|
121
|
19
|
147
|
20 using namespace llvm;
|
|
21 using namespace llvm::pdb;
|
|
22
|
|
23 static DbiStream *getDbiStreamPtr(NativeSession &Session) {
|
|
24 Expected<DbiStream &> DbiS = Session.getPDBFile().getPDBDbiStream();
|
|
25 if (DbiS)
|
|
26 return &DbiS.get();
|
|
27
|
|
28 consumeError(DbiS.takeError());
|
|
29 return nullptr;
|
|
30 }
|
121
|
31
|
|
32 NativeExeSymbol::NativeExeSymbol(NativeSession &Session, SymIndexId SymbolId)
|
147
|
33 : NativeRawSymbol(Session, PDB_SymType::Exe, SymbolId),
|
|
34 Dbi(getDbiStreamPtr(Session)) {}
|
121
|
35
|
|
36 std::unique_ptr<IPDBEnumSymbols>
|
|
37 NativeExeSymbol::findChildren(PDB_SymType Type) const {
|
|
38 switch (Type) {
|
|
39 case PDB_SymType::Compiland: {
|
147
|
40 return std::unique_ptr<IPDBEnumSymbols>(new NativeEnumModules(Session));
|
121
|
41 break;
|
|
42 }
|
147
|
43 case PDB_SymType::ArrayType:
|
|
44 return Session.getSymbolCache().createTypeEnumerator(codeview::LF_ARRAY);
|
121
|
45 case PDB_SymType::Enum:
|
147
|
46 return Session.getSymbolCache().createTypeEnumerator(codeview::LF_ENUM);
|
|
47 case PDB_SymType::PointerType:
|
|
48 return Session.getSymbolCache().createTypeEnumerator(codeview::LF_POINTER);
|
|
49 case PDB_SymType::UDT:
|
|
50 return Session.getSymbolCache().createTypeEnumerator(
|
|
51 {codeview::LF_STRUCTURE, codeview::LF_CLASS, codeview::LF_UNION,
|
|
52 codeview::LF_INTERFACE});
|
|
53 case PDB_SymType::VTableShape:
|
|
54 return Session.getSymbolCache().createTypeEnumerator(codeview::LF_VTSHAPE);
|
|
55 case PDB_SymType::FunctionSig:
|
|
56 return Session.getSymbolCache().createTypeEnumerator(
|
|
57 {codeview::LF_PROCEDURE, codeview::LF_MFUNCTION});
|
|
58 case PDB_SymType::Typedef:
|
|
59 return Session.getSymbolCache().createGlobalsEnumerator(codeview::S_UDT);
|
|
60
|
121
|
61 default:
|
|
62 break;
|
|
63 }
|
|
64 return nullptr;
|
|
65 }
|
|
66
|
|
67 uint32_t NativeExeSymbol::getAge() const {
|
147
|
68 auto IS = Session.getPDBFile().getPDBInfoStream();
|
121
|
69 if (IS)
|
|
70 return IS->getAge();
|
|
71 consumeError(IS.takeError());
|
|
72 return 0;
|
|
73 }
|
|
74
|
|
75 std::string NativeExeSymbol::getSymbolsFileName() const {
|
147
|
76 return Session.getPDBFile().getFilePath();
|
121
|
77 }
|
|
78
|
|
79 codeview::GUID NativeExeSymbol::getGuid() const {
|
147
|
80 auto IS = Session.getPDBFile().getPDBInfoStream();
|
121
|
81 if (IS)
|
|
82 return IS->getGuid();
|
|
83 consumeError(IS.takeError());
|
|
84 return codeview::GUID{{0}};
|
|
85 }
|
|
86
|
|
87 bool NativeExeSymbol::hasCTypes() const {
|
147
|
88 auto Dbi = Session.getPDBFile().getPDBDbiStream();
|
121
|
89 if (Dbi)
|
|
90 return Dbi->hasCTypes();
|
|
91 consumeError(Dbi.takeError());
|
|
92 return false;
|
|
93 }
|
|
94
|
|
95 bool NativeExeSymbol::hasPrivateSymbols() const {
|
147
|
96 auto Dbi = Session.getPDBFile().getPDBDbiStream();
|
121
|
97 if (Dbi)
|
|
98 return !Dbi->isStripped();
|
|
99 consumeError(Dbi.takeError());
|
|
100 return false;
|
|
101 }
|