2017-03-29 19:27:08 +00:00
|
|
|
//===- NativeExeSymbol.cpp - native impl for PDBSymbolExe -------*- C++ -*-===//
|
|
|
|
|
//
|
2019-01-19 08:50:56 +00:00
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
2017-03-29 19:27:08 +00:00
|
|
|
//
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
|
|
#include "llvm/DebugInfo/PDB/Native/NativeExeSymbol.h"
|
|
|
|
|
|
2017-06-22 18:57:51 +00:00
|
|
|
#include "llvm/ADT/STLExtras.h"
|
2017-03-29 19:27:08 +00:00
|
|
|
#include "llvm/DebugInfo/PDB/Native/DbiStream.h"
|
|
|
|
|
#include "llvm/DebugInfo/PDB/Native/InfoStream.h"
|
2018-09-05 23:30:38 +00:00
|
|
|
#include "llvm/DebugInfo/PDB/Native/NativeCompilandSymbol.h"
|
2017-03-29 19:27:08 +00:00
|
|
|
#include "llvm/DebugInfo/PDB/Native/NativeEnumModules.h"
|
|
|
|
|
#include "llvm/DebugInfo/PDB/Native/PDBFile.h"
|
2018-09-07 00:12:34 +00:00
|
|
|
#include "llvm/DebugInfo/PDB/Native/SymbolCache.h"
|
2018-09-05 23:30:38 +00:00
|
|
|
#include "llvm/DebugInfo/PDB/PDBSymbolCompiland.h"
|
2017-03-29 19:27:08 +00:00
|
|
|
|
2018-09-05 23:30:38 +00:00
|
|
|
using namespace llvm;
|
|
|
|
|
using namespace llvm::pdb;
|
2017-03-29 19:27:08 +00:00
|
|
|
|
2018-09-07 00:12:34 +00:00
|
|
|
static DbiStream *getDbiStreamPtr(NativeSession &Session) {
|
|
|
|
|
Expected<DbiStream &> DbiS = Session.getPDBFile().getPDBDbiStream();
|
|
|
|
|
if (DbiS)
|
|
|
|
|
return &DbiS.get();
|
|
|
|
|
|
|
|
|
|
consumeError(DbiS.takeError());
|
|
|
|
|
return nullptr;
|
|
|
|
|
}
|
|
|
|
|
|
2017-07-12 19:38:11 +00:00
|
|
|
NativeExeSymbol::NativeExeSymbol(NativeSession &Session, SymIndexId SymbolId)
|
2018-09-05 23:30:38 +00:00
|
|
|
: NativeRawSymbol(Session, PDB_SymType::Exe, SymbolId),
|
2018-09-07 00:12:34 +00:00
|
|
|
Dbi(getDbiStreamPtr(Session)) {}
|
2017-06-22 18:43:18 +00:00
|
|
|
|
2017-03-29 19:27:08 +00:00
|
|
|
std::unique_ptr<IPDBEnumSymbols>
|
|
|
|
|
NativeExeSymbol::findChildren(PDB_SymType Type) const {
|
|
|
|
|
switch (Type) {
|
|
|
|
|
case PDB_SymType::Compiland: {
|
2018-09-05 23:30:38 +00:00
|
|
|
return std::unique_ptr<IPDBEnumSymbols>(new NativeEnumModules(Session));
|
2017-03-29 19:27:08 +00:00
|
|
|
break;
|
|
|
|
|
}
|
2018-09-30 16:19:18 +00:00
|
|
|
case PDB_SymType::ArrayType:
|
|
|
|
|
return Session.getSymbolCache().createTypeEnumerator(codeview::LF_ARRAY);
|
2017-08-04 22:37:58 +00:00
|
|
|
case PDB_SymType::Enum:
|
2018-09-07 00:12:34 +00:00
|
|
|
return Session.getSymbolCache().createTypeEnumerator(codeview::LF_ENUM);
|
2018-09-07 23:21:33 +00:00
|
|
|
case PDB_SymType::PointerType:
|
|
|
|
|
return Session.getSymbolCache().createTypeEnumerator(codeview::LF_POINTER);
|
2018-09-21 22:36:04 +00:00
|
|
|
case PDB_SymType::UDT:
|
|
|
|
|
return Session.getSymbolCache().createTypeEnumerator(
|
|
|
|
|
{codeview::LF_STRUCTURE, codeview::LF_CLASS, codeview::LF_UNION,
|
|
|
|
|
codeview::LF_INTERFACE});
|
2018-10-01 17:55:16 +00:00
|
|
|
case PDB_SymType::VTableShape:
|
|
|
|
|
return Session.getSymbolCache().createTypeEnumerator(codeview::LF_VTSHAPE);
|
2018-09-21 22:36:28 +00:00
|
|
|
case PDB_SymType::FunctionSig:
|
|
|
|
|
return Session.getSymbolCache().createTypeEnumerator(
|
|
|
|
|
{codeview::LF_PROCEDURE, codeview::LF_MFUNCTION});
|
2018-10-01 17:55:38 +00:00
|
|
|
case PDB_SymType::Typedef:
|
|
|
|
|
return Session.getSymbolCache().createGlobalsEnumerator(codeview::S_UDT);
|
2018-09-21 22:36:28 +00:00
|
|
|
|
2017-03-29 19:27:08 +00:00
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
return nullptr;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
uint32_t NativeExeSymbol::getAge() const {
|
2018-09-07 00:12:34 +00:00
|
|
|
auto IS = Session.getPDBFile().getPDBInfoStream();
|
2017-03-29 19:27:08 +00:00
|
|
|
if (IS)
|
|
|
|
|
return IS->getAge();
|
|
|
|
|
consumeError(IS.takeError());
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::string NativeExeSymbol::getSymbolsFileName() const {
|
2020-01-28 20:23:46 +01:00
|
|
|
return std::string(Session.getPDBFile().getFilePath());
|
2017-03-29 19:27:08 +00:00
|
|
|
}
|
|
|
|
|
|
2017-07-17 23:59:44 +00:00
|
|
|
codeview::GUID NativeExeSymbol::getGuid() const {
|
2018-09-07 00:12:34 +00:00
|
|
|
auto IS = Session.getPDBFile().getPDBInfoStream();
|
2017-03-29 19:27:08 +00:00
|
|
|
if (IS)
|
|
|
|
|
return IS->getGuid();
|
|
|
|
|
consumeError(IS.takeError());
|
2017-07-17 23:59:44 +00:00
|
|
|
return codeview::GUID{{0}};
|
2017-03-29 19:27:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool NativeExeSymbol::hasCTypes() const {
|
2018-09-07 00:12:34 +00:00
|
|
|
auto Dbi = Session.getPDBFile().getPDBDbiStream();
|
2017-03-29 19:27:08 +00:00
|
|
|
if (Dbi)
|
|
|
|
|
return Dbi->hasCTypes();
|
|
|
|
|
consumeError(Dbi.takeError());
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool NativeExeSymbol::hasPrivateSymbols() const {
|
2018-09-07 00:12:34 +00:00
|
|
|
auto Dbi = Session.getPDBFile().getPDBDbiStream();
|
2017-03-29 19:27:08 +00:00
|
|
|
if (Dbi)
|
|
|
|
|
return !Dbi->isStripped();
|
|
|
|
|
consumeError(Dbi.takeError());
|
|
|
|
|
return false;
|
|
|
|
|
}
|