Path: blob/main/contrib/llvm-project/llvm/lib/DebugInfo/PDB/Native/NativeExeSymbol.cpp
35293 views
//===- NativeExeSymbol.cpp - native impl for PDBSymbolExe -------*- C++ -*-===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//78#include "llvm/DebugInfo/PDB/Native/NativeExeSymbol.h"910#include "llvm/DebugInfo/CodeView/CodeView.h"11#include "llvm/DebugInfo/PDB/IPDBEnumChildren.h"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/NativeSession.h"16#include "llvm/DebugInfo/PDB/Native/PDBFile.h"17#include "llvm/DebugInfo/PDB/Native/SymbolCache.h"1819using namespace llvm;20using namespace llvm::pdb;2122static DbiStream *getDbiStreamPtr(NativeSession &Session) {23Expected<DbiStream &> DbiS = Session.getPDBFile().getPDBDbiStream();24if (DbiS)25return &DbiS.get();2627consumeError(DbiS.takeError());28return nullptr;29}3031NativeExeSymbol::NativeExeSymbol(NativeSession &Session, SymIndexId SymbolId)32: NativeRawSymbol(Session, PDB_SymType::Exe, SymbolId),33Dbi(getDbiStreamPtr(Session)) {}3435std::unique_ptr<IPDBEnumSymbols>36NativeExeSymbol::findChildren(PDB_SymType Type) const {37switch (Type) {38case PDB_SymType::Compiland: {39return std::unique_ptr<IPDBEnumSymbols>(new NativeEnumModules(Session));40break;41}42case PDB_SymType::ArrayType:43return Session.getSymbolCache().createTypeEnumerator(codeview::LF_ARRAY);44case PDB_SymType::Enum:45return Session.getSymbolCache().createTypeEnumerator(codeview::LF_ENUM);46case PDB_SymType::PointerType:47return Session.getSymbolCache().createTypeEnumerator(codeview::LF_POINTER);48case PDB_SymType::UDT:49return Session.getSymbolCache().createTypeEnumerator(50{codeview::LF_STRUCTURE, codeview::LF_CLASS, codeview::LF_UNION,51codeview::LF_INTERFACE});52case PDB_SymType::VTableShape:53return Session.getSymbolCache().createTypeEnumerator(codeview::LF_VTSHAPE);54case PDB_SymType::FunctionSig:55return Session.getSymbolCache().createTypeEnumerator(56{codeview::LF_PROCEDURE, codeview::LF_MFUNCTION});57case PDB_SymType::Typedef:58return Session.getSymbolCache().createGlobalsEnumerator(codeview::S_UDT);5960default:61break;62}63return nullptr;64}6566uint32_t NativeExeSymbol::getAge() const {67auto IS = Session.getPDBFile().getPDBInfoStream();68if (IS)69return IS->getAge();70consumeError(IS.takeError());71return 0;72}7374std::string NativeExeSymbol::getSymbolsFileName() const {75return std::string(Session.getPDBFile().getFilePath());76}7778codeview::GUID NativeExeSymbol::getGuid() const {79auto IS = Session.getPDBFile().getPDBInfoStream();80if (IS)81return IS->getGuid();82consumeError(IS.takeError());83return codeview::GUID{{0}};84}8586bool NativeExeSymbol::hasCTypes() const {87auto Dbi = Session.getPDBFile().getPDBDbiStream();88if (Dbi)89return Dbi->hasCTypes();90consumeError(Dbi.takeError());91return false;92}9394bool NativeExeSymbol::hasPrivateSymbols() const {95auto Dbi = Session.getPDBFile().getPDBDbiStream();96if (Dbi)97return !Dbi->isStripped();98consumeError(Dbi.takeError());99return false;100}101102103