LCOV - code coverage report
Current view: top level - lib/DebugInfo/PDB - PDBSymbolData.cpp (source / functions) Hit Total Coverage
Test: llvm-toolchain.info Lines: 4 34 11.8 %
Date: 2018-06-17 00:07:59 Functions: 1 4 25.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : //===- PDBSymbolData.cpp - PDB data (e.g. variable) accessors ---*- 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/PDBSymbolData.h"
      11             : #include "llvm/DebugInfo/PDB/IPDBSectionContrib.h"
      12             : #include "llvm/DebugInfo/PDB/IPDBSession.h"
      13             : #include "llvm/DebugInfo/PDB/PDBSymDumper.h"
      14             : 
      15             : #include <utility>
      16             : 
      17             : using namespace llvm;
      18             : using namespace llvm::pdb;
      19             : 
      20           1 : PDBSymbolData::PDBSymbolData(const IPDBSession &PDBSession,
      21           1 :                              std::unique_ptr<IPDBRawSymbol> DataSymbol)
      22           3 :     : PDBSymbol(PDBSession, std::move(DataSymbol)) {
      23             :   assert(RawSymbol->getSymTag() == PDB_SymType::Data);
      24           1 : }
      25             : 
      26           0 : void PDBSymbolData::dump(PDBSymDumper &Dumper) const { Dumper.dump(*this); }
      27             : 
      28           0 : std::unique_ptr<IPDBEnumLineNumbers> PDBSymbolData::getLineNumbers() const {
      29           0 :   auto Len = RawSymbol->getLength();
      30           0 :   Len = Len ? Len : 1;
      31           0 :   if (auto RVA = RawSymbol->getRelativeVirtualAddress())
      32           0 :     return Session.findLineNumbersByRVA(RVA, Len);
      33             : 
      34           0 :   if (auto Section = RawSymbol->getAddressSection())
      35           0 :     return Session.findLineNumbersBySectOffset(
      36           0 :         Section, RawSymbol->getAddressOffset(), Len);
      37             : 
      38             :   return nullptr;
      39             : }
      40             : 
      41           0 : uint32_t PDBSymbolData::getCompilandId() const {
      42           0 :   if (auto Lines = getLineNumbers()) {
      43           0 :     if (auto FirstLine = Lines->getNext())
      44           0 :       return FirstLine->getCompilandId();
      45             :   }
      46             : 
      47           0 :   uint32_t DataSection = RawSymbol->getAddressSection();
      48           0 :   uint32_t DataOffset = RawSymbol->getAddressOffset();
      49           0 :   if (DataSection == 0) {
      50           0 :     if (auto RVA = RawSymbol->getRelativeVirtualAddress())
      51           0 :       Session.addressForRVA(RVA, DataSection, DataOffset);
      52             :   }
      53             : 
      54           0 :   if (DataSection) {
      55           0 :     if (auto SecContribs = Session.getSectionContribs()) {
      56           0 :       while (auto Section = SecContribs->getNext()) {
      57           0 :         if (Section->getAddressSection() == DataSection &&
      58           0 :             Section->getAddressOffset() <= DataOffset &&
      59           0 :             (Section->getAddressOffset() + Section->getLength()) > DataOffset)
      60           0 :           return Section->getCompilandId();
      61             :       }
      62             :     }
      63             :   } else {
      64           0 :     auto LexParentId = RawSymbol->getLexicalParentId();
      65           0 :     while (auto LexParent = Session.getSymbolById(LexParentId)) {
      66           0 :       if (LexParent->getSymTag() == PDB_SymType::Exe)
      67             :         break;
      68           0 :       if (LexParent->getSymTag() == PDB_SymType::Compiland)
      69             :         return LexParentId;
      70           0 :       LexParentId = LexParent->getRawSymbol().getLexicalParentId();
      71             :     }
      72             :   }
      73             : 
      74             :   return 0;
      75             : }

Generated by: LCOV version 1.13