LCOV - code coverage report
Current view: top level - lib/DebugInfo/PDB - PDBSymbol.cpp (source / functions) Hit Total Coverage
Test: llvm-toolchain.info Lines: 44 77 57.1 %
Date: 2017-09-14 15:23:50 Functions: 6 16 37.5 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : //===- PDBSymbol.cpp - base class for user-facing symbol types --*- C++ -*-===//
       2             : //
       3             : //                     The LLVM Compiler Infrastructure
       4             : //
       5             : // This file is distributed under the University of Illinois Open Source
       6             : // License. See LICENSE.TXT for details.
       7             : //
       8             : //===----------------------------------------------------------------------===//
       9             : 
      10             : #include "llvm/DebugInfo/PDB/PDBSymbol.h"
      11             : #include "llvm/DebugInfo/PDB/IPDBEnumChildren.h"
      12             : #include "llvm/DebugInfo/PDB/IPDBRawSymbol.h"
      13             : #include "llvm/DebugInfo/PDB/IPDBSession.h"
      14             : #include "llvm/DebugInfo/PDB/PDBExtras.h"
      15             : #include "llvm/DebugInfo/PDB/PDBSymbolAnnotation.h"
      16             : #include "llvm/DebugInfo/PDB/PDBSymbolBlock.h"
      17             : #include "llvm/DebugInfo/PDB/PDBSymbolCompiland.h"
      18             : #include "llvm/DebugInfo/PDB/PDBSymbolCompilandDetails.h"
      19             : #include "llvm/DebugInfo/PDB/PDBSymbolCompilandEnv.h"
      20             : #include "llvm/DebugInfo/PDB/PDBSymbolCustom.h"
      21             : #include "llvm/DebugInfo/PDB/PDBSymbolData.h"
      22             : #include "llvm/DebugInfo/PDB/PDBSymbolExe.h"
      23             : #include "llvm/DebugInfo/PDB/PDBSymbolFunc.h"
      24             : #include "llvm/DebugInfo/PDB/PDBSymbolFuncDebugEnd.h"
      25             : #include "llvm/DebugInfo/PDB/PDBSymbolFuncDebugStart.h"
      26             : #include "llvm/DebugInfo/PDB/PDBSymbolLabel.h"
      27             : #include "llvm/DebugInfo/PDB/PDBSymbolPublicSymbol.h"
      28             : #include "llvm/DebugInfo/PDB/PDBSymbolThunk.h"
      29             : #include "llvm/DebugInfo/PDB/PDBSymbolTypeArray.h"
      30             : #include "llvm/DebugInfo/PDB/PDBSymbolTypeBaseClass.h"
      31             : #include "llvm/DebugInfo/PDB/PDBSymbolTypeBuiltin.h"
      32             : #include "llvm/DebugInfo/PDB/PDBSymbolTypeCustom.h"
      33             : #include "llvm/DebugInfo/PDB/PDBSymbolTypeDimension.h"
      34             : #include "llvm/DebugInfo/PDB/PDBSymbolTypeEnum.h"
      35             : #include "llvm/DebugInfo/PDB/PDBSymbolTypeFriend.h"
      36             : #include "llvm/DebugInfo/PDB/PDBSymbolTypeFunctionArg.h"
      37             : #include "llvm/DebugInfo/PDB/PDBSymbolTypeFunctionSig.h"
      38             : #include "llvm/DebugInfo/PDB/PDBSymbolTypeManaged.h"
      39             : #include "llvm/DebugInfo/PDB/PDBSymbolTypePointer.h"
      40             : #include "llvm/DebugInfo/PDB/PDBSymbolTypeTypedef.h"
      41             : #include "llvm/DebugInfo/PDB/PDBSymbolTypeUDT.h"
      42             : #include "llvm/DebugInfo/PDB/PDBSymbolTypeVTable.h"
      43             : #include "llvm/DebugInfo/PDB/PDBSymbolTypeVTableShape.h"
      44             : #include "llvm/DebugInfo/PDB/PDBSymbolUnknown.h"
      45             : #include "llvm/DebugInfo/PDB/PDBSymbolUsingNamespace.h"
      46             : #include "llvm/DebugInfo/PDB/PDBTypes.h"
      47             : #include <algorithm>
      48             : #include <memory>
      49             : 
      50             : using namespace llvm;
      51             : using namespace llvm::pdb;
      52             : 
      53         113 : PDBSymbol::PDBSymbol(const IPDBSession &PDBSession,
      54         113 :                      std::unique_ptr<IPDBRawSymbol> Symbol)
      55         226 :     : Session(PDBSession), RawSymbol(std::move(Symbol)) {}
      56             : 
      57           0 : PDBSymbol::PDBSymbol(PDBSymbol &Symbol)
      58           0 :     : Session(Symbol.Session), RawSymbol(std::move(Symbol.RawSymbol)) {}
      59             : 
      60             : PDBSymbol::~PDBSymbol() = default;
      61             : 
      62             : #define FACTORY_SYMTAG_CASE(Tag, Type)                                         \
      63             :   case PDB_SymType::Tag:                                                       \
      64             :     return std::unique_ptr<PDBSymbol>(new Type(PDBSession, std::move(Symbol)));
      65             : 
      66             : std::unique_ptr<PDBSymbol>
      67          54 : PDBSymbol::create(const IPDBSession &PDBSession,
      68             :                   std::unique_ptr<IPDBRawSymbol> Symbol) {
      69          54 :   switch (Symbol->getSymTag()) {
      70           4 :     FACTORY_SYMTAG_CASE(Exe, PDBSymbolExe)
      71           4 :     FACTORY_SYMTAG_CASE(Compiland, PDBSymbolCompiland)
      72           4 :     FACTORY_SYMTAG_CASE(CompilandDetails, PDBSymbolCompilandDetails)
      73           4 :     FACTORY_SYMTAG_CASE(CompilandEnv, PDBSymbolCompilandEnv)
      74           4 :     FACTORY_SYMTAG_CASE(Function, PDBSymbolFunc)
      75           4 :     FACTORY_SYMTAG_CASE(Block, PDBSymbolBlock)
      76           4 :     FACTORY_SYMTAG_CASE(Data, PDBSymbolData)
      77           4 :     FACTORY_SYMTAG_CASE(Annotation, PDBSymbolAnnotation)
      78           4 :     FACTORY_SYMTAG_CASE(Label, PDBSymbolLabel)
      79           4 :     FACTORY_SYMTAG_CASE(PublicSymbol, PDBSymbolPublicSymbol)
      80           4 :     FACTORY_SYMTAG_CASE(UDT, PDBSymbolTypeUDT)
      81           4 :     FACTORY_SYMTAG_CASE(Enum, PDBSymbolTypeEnum)
      82           4 :     FACTORY_SYMTAG_CASE(FunctionSig, PDBSymbolTypeFunctionSig)
      83           4 :     FACTORY_SYMTAG_CASE(PointerType, PDBSymbolTypePointer)
      84           4 :     FACTORY_SYMTAG_CASE(ArrayType, PDBSymbolTypeArray)
      85          76 :     FACTORY_SYMTAG_CASE(BuiltinType, PDBSymbolTypeBuiltin)
      86           4 :     FACTORY_SYMTAG_CASE(Typedef, PDBSymbolTypeTypedef)
      87           4 :     FACTORY_SYMTAG_CASE(BaseClass, PDBSymbolTypeBaseClass)
      88           4 :     FACTORY_SYMTAG_CASE(Friend, PDBSymbolTypeFriend)
      89           4 :     FACTORY_SYMTAG_CASE(FunctionArg, PDBSymbolTypeFunctionArg)
      90           4 :     FACTORY_SYMTAG_CASE(FuncDebugStart, PDBSymbolFuncDebugStart)
      91           4 :     FACTORY_SYMTAG_CASE(FuncDebugEnd, PDBSymbolFuncDebugEnd)
      92           4 :     FACTORY_SYMTAG_CASE(UsingNamespace, PDBSymbolUsingNamespace)
      93           4 :     FACTORY_SYMTAG_CASE(VTableShape, PDBSymbolTypeVTableShape)
      94           4 :     FACTORY_SYMTAG_CASE(VTable, PDBSymbolTypeVTable)
      95           4 :     FACTORY_SYMTAG_CASE(Custom, PDBSymbolCustom)
      96           4 :     FACTORY_SYMTAG_CASE(Thunk, PDBSymbolThunk)
      97           4 :     FACTORY_SYMTAG_CASE(CustomType, PDBSymbolTypeCustom)
      98           4 :     FACTORY_SYMTAG_CASE(ManagedType, PDBSymbolTypeManaged)
      99           4 :     FACTORY_SYMTAG_CASE(Dimension, PDBSymbolTypeDimension)
     100           6 :   default:
     101             :     return std::unique_ptr<PDBSymbol>(
     102          24 :         new PDBSymbolUnknown(PDBSession, std::move(Symbol)));
     103             :   }
     104             : }
     105             : 
     106           0 : void PDBSymbol::defaultDump(raw_ostream &OS, int Indent) const {
     107           0 :   RawSymbol->dump(OS, Indent);
     108           0 : }
     109             : 
     110           0 : void PDBSymbol::dumpProperties() const {
     111           0 :   outs() << "\n";
     112           0 :   defaultDump(outs(), 0);
     113           0 :   outs().flush();
     114           0 : }
     115             : 
     116           0 : void PDBSymbol::dumpChildStats() const {
     117           0 :   TagStats Stats;
     118           0 :   getChildStats(Stats);
     119           0 :   outs() << "\n";
     120           0 :   for (auto &Stat : Stats) {
     121           0 :     outs() << Stat.first << ": " << Stat.second << "\n";
     122             :   }
     123           0 :   outs().flush();
     124           0 : }
     125             : 
     126           0 : std::unique_ptr<PDBSymbol> PDBSymbol::clone() const {
     127           0 :   return Session.getSymbolById(getSymIndexId());
     128             : }
     129             : 
     130        2200 : PDB_SymType PDBSymbol::getSymTag() const { return RawSymbol->getSymTag(); }
     131           0 : uint32_t PDBSymbol::getSymIndexId() const { return RawSymbol->getSymIndexId(); }
     132             : 
     133           1 : std::unique_ptr<IPDBEnumSymbols> PDBSymbol::findAllChildren() const {
     134           1 :   return findAllChildren(PDB_SymType::None);
     135             : }
     136             : 
     137             : std::unique_ptr<IPDBEnumSymbols>
     138           1 : PDBSymbol::findAllChildren(PDB_SymType Type) const {
     139           2 :   return RawSymbol->findChildren(Type);
     140             : }
     141             : 
     142             : std::unique_ptr<IPDBEnumSymbols>
     143           0 : PDBSymbol::findChildren(PDB_SymType Type, StringRef Name,
     144             :                         PDB_NameSearchFlags Flags) const {
     145           0 :   return RawSymbol->findChildren(Type, Name, Flags);
     146             : }
     147             : 
     148             : std::unique_ptr<IPDBEnumSymbols>
     149           0 : PDBSymbol::findChildrenByRVA(PDB_SymType Type, StringRef Name,
     150             :                              PDB_NameSearchFlags Flags, uint32_t RVA) const {
     151           0 :   return RawSymbol->findChildrenByRVA(Type, Name, Flags, RVA);
     152             : }
     153             : 
     154             : std::unique_ptr<IPDBEnumSymbols>
     155           0 : PDBSymbol::findInlineFramesByRVA(uint32_t RVA) const {
     156           0 :   return RawSymbol->findInlineFramesByRVA(RVA);
     157             : }
     158             : 
     159             : std::unique_ptr<IPDBEnumSymbols>
     160           0 : PDBSymbol::getChildStats(TagStats &Stats) const {
     161           0 :   std::unique_ptr<IPDBEnumSymbols> Result(findAllChildren());
     162           0 :   if (!Result)
     163             :     return nullptr;
     164             :   Stats.clear();
     165           0 :   while (auto Child = Result->getNext()) {
     166           0 :     ++Stats[Child->getSymTag()];
     167             :   }
     168           0 :   Result->reset();
     169             :   return Result;
     170             : }
     171             : 
     172          18 : std::unique_ptr<PDBSymbol> PDBSymbol::getSymbolByIdHelper(uint32_t Id) const {
     173          18 :   return Session.getSymbolById(Id);
     174             : }

Generated by: LCOV version 1.13