Files
archived-llvm/lib/DebugInfo/PDB/Native/NativeExeSymbol.cpp
Adrian McCarthy 39bfdfaa94 [PDB] Enable NativeSession to create symbols for built-in types on demand
Summary:
There is a reserved range of type indexes for built-in types (like integers).
This will create a symbol for a built-in type if the caller askes for one by
type index.  This is also plumbing for being able to recall symbols by type
index in general, but user-defined types will come in subsequent patches.

Reviewers: rnk, zturner

Subscribers: mgorny, hiraditya, llvm-commits

Differential Revision: https://reviews.llvm.org/D35163

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@307834 91177308-0d34-0410-b5e6-96231b3b80d8
2017-07-12 19:38:11 +00:00

85 lines
2.2 KiB
C++

//===- NativeExeSymbol.cpp - native impl for PDBSymbolExe -------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#include "llvm/DebugInfo/PDB/Native/NativeExeSymbol.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/DebugInfo/PDB/Native/DbiStream.h"
#include "llvm/DebugInfo/PDB/Native/InfoStream.h"
#include "llvm/DebugInfo/PDB/Native/NativeEnumModules.h"
#include "llvm/DebugInfo/PDB/Native/PDBFile.h"
namespace llvm {
namespace pdb {
NativeExeSymbol::NativeExeSymbol(NativeSession &Session, SymIndexId SymbolId)
: NativeRawSymbol(Session, SymbolId), File(Session.getPDBFile()) {}
std::unique_ptr<NativeRawSymbol> NativeExeSymbol::clone() const {
return llvm::make_unique<NativeExeSymbol>(Session, SymbolId);
}
std::unique_ptr<IPDBEnumSymbols>
NativeExeSymbol::findChildren(PDB_SymType Type) const {
switch (Type) {
case PDB_SymType::Compiland: {
auto Dbi = File.getPDBDbiStream();
if (Dbi) {
const DbiModuleList &Modules = Dbi->modules();
return std::unique_ptr<IPDBEnumSymbols>(
new NativeEnumModules(Session, Modules));
}
consumeError(Dbi.takeError());
break;
}
default:
break;
}
return nullptr;
}
uint32_t NativeExeSymbol::getAge() const {
auto IS = File.getPDBInfoStream();
if (IS)
return IS->getAge();
consumeError(IS.takeError());
return 0;
}
std::string NativeExeSymbol::getSymbolsFileName() const {
return File.getFilePath();
}
PDB_UniqueId NativeExeSymbol::getGuid() const {
auto IS = File.getPDBInfoStream();
if (IS)
return IS->getGuid();
consumeError(IS.takeError());
return PDB_UniqueId{{0}};
}
bool NativeExeSymbol::hasCTypes() const {
auto Dbi = File.getPDBDbiStream();
if (Dbi)
return Dbi->hasCTypes();
consumeError(Dbi.takeError());
return false;
}
bool NativeExeSymbol::hasPrivateSymbols() const {
auto Dbi = File.getPDBDbiStream();
if (Dbi)
return !Dbi->isStripped();
consumeError(Dbi.takeError());
return false;
}
} // namespace pdb
} // namespace llvm