17a7e6055SDimitry Andric //===- NativeExeSymbol.cpp - native impl for PDBSymbolExe -------*- C++ -*-===//
27a7e6055SDimitry Andric //
37a7e6055SDimitry Andric //                     The LLVM Compiler Infrastructure
47a7e6055SDimitry Andric //
57a7e6055SDimitry Andric // This file is distributed under the University of Illinois Open Source
67a7e6055SDimitry Andric // License. See LICENSE.TXT for details.
77a7e6055SDimitry Andric //
87a7e6055SDimitry Andric //===----------------------------------------------------------------------===//
97a7e6055SDimitry Andric 
107a7e6055SDimitry Andric #include "llvm/DebugInfo/PDB/Native/NativeExeSymbol.h"
117a7e6055SDimitry Andric 
127a7e6055SDimitry Andric #include "llvm/DebugInfo/PDB/Native/DbiStream.h"
137a7e6055SDimitry Andric #include "llvm/DebugInfo/PDB/Native/InfoStream.h"
147a7e6055SDimitry Andric #include "llvm/DebugInfo/PDB/Native/NativeEnumModules.h"
157a7e6055SDimitry Andric #include "llvm/DebugInfo/PDB/Native/PDBFile.h"
167a7e6055SDimitry Andric 
177a7e6055SDimitry Andric namespace llvm {
187a7e6055SDimitry Andric namespace pdb {
197a7e6055SDimitry Andric 
207a7e6055SDimitry Andric NativeExeSymbol::NativeExeSymbol(NativeSession &Session)
217a7e6055SDimitry Andric     : NativeRawSymbol(Session), File(Session.getPDBFile()) {}
227a7e6055SDimitry Andric 
237a7e6055SDimitry Andric std::unique_ptr<IPDBEnumSymbols>
247a7e6055SDimitry Andric NativeExeSymbol::findChildren(PDB_SymType Type) const {
257a7e6055SDimitry Andric   switch (Type) {
267a7e6055SDimitry Andric   case PDB_SymType::Compiland: {
277a7e6055SDimitry Andric     auto Dbi = File.getPDBDbiStream();
287a7e6055SDimitry Andric     if (Dbi) {
290f5676f4SDimitry Andric       const DbiModuleList &Modules = Dbi->modules();
307a7e6055SDimitry Andric       return std::unique_ptr<IPDBEnumSymbols>(
317a7e6055SDimitry Andric           new NativeEnumModules(Session, Modules));
327a7e6055SDimitry Andric     }
337a7e6055SDimitry Andric     consumeError(Dbi.takeError());
347a7e6055SDimitry Andric     break;
357a7e6055SDimitry Andric   }
367a7e6055SDimitry Andric   default:
377a7e6055SDimitry Andric     break;
387a7e6055SDimitry Andric   }
397a7e6055SDimitry Andric   return nullptr;
407a7e6055SDimitry Andric }
417a7e6055SDimitry Andric 
427a7e6055SDimitry Andric uint32_t NativeExeSymbol::getAge() const {
437a7e6055SDimitry Andric   auto IS = File.getPDBInfoStream();
447a7e6055SDimitry Andric   if (IS)
457a7e6055SDimitry Andric     return IS->getAge();
467a7e6055SDimitry Andric   consumeError(IS.takeError());
477a7e6055SDimitry Andric   return 0;
487a7e6055SDimitry Andric }
497a7e6055SDimitry Andric 
507a7e6055SDimitry Andric std::string NativeExeSymbol::getSymbolsFileName() const {
517a7e6055SDimitry Andric   return File.getFilePath();
527a7e6055SDimitry Andric }
537a7e6055SDimitry Andric 
547a7e6055SDimitry Andric PDB_UniqueId NativeExeSymbol::getGuid() const {
557a7e6055SDimitry Andric   auto IS = File.getPDBInfoStream();
567a7e6055SDimitry Andric   if (IS)
577a7e6055SDimitry Andric     return IS->getGuid();
587a7e6055SDimitry Andric   consumeError(IS.takeError());
597a7e6055SDimitry Andric   return PDB_UniqueId{{0}};
607a7e6055SDimitry Andric }
617a7e6055SDimitry Andric 
627a7e6055SDimitry Andric bool NativeExeSymbol::hasCTypes() const {
637a7e6055SDimitry Andric   auto Dbi = File.getPDBDbiStream();
647a7e6055SDimitry Andric   if (Dbi)
657a7e6055SDimitry Andric     return Dbi->hasCTypes();
667a7e6055SDimitry Andric   consumeError(Dbi.takeError());
677a7e6055SDimitry Andric   return false;
687a7e6055SDimitry Andric }
697a7e6055SDimitry Andric 
707a7e6055SDimitry Andric bool NativeExeSymbol::hasPrivateSymbols() const {
717a7e6055SDimitry Andric   auto Dbi = File.getPDBDbiStream();
727a7e6055SDimitry Andric   if (Dbi)
737a7e6055SDimitry Andric     return !Dbi->isStripped();
747a7e6055SDimitry Andric   consumeError(Dbi.takeError());
757a7e6055SDimitry Andric   return false;
767a7e6055SDimitry Andric }
777a7e6055SDimitry Andric 
787a7e6055SDimitry Andric } // namespace pdb
797a7e6055SDimitry Andric } // namespace llvm
80