LCOV - code coverage report
Current view: top level - lib/DebugInfo - DWARFAbbreviationDeclaration.cpp (source / functions) Hit Total Coverage
Test: llvm-toolchain.info Lines: 49 57 86.0 %
Date: 2015-01-30 11:55:44 Functions: 5 5 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : //===-- DWARFAbbreviationDeclaration.cpp ----------------------------------===//
       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/DWARFAbbreviationDeclaration.h"
      11             : #include "llvm/Support/Dwarf.h"
      12             : #include "llvm/Support/Format.h"
      13             : #include "llvm/Support/raw_ostream.h"
      14             : using namespace llvm;
      15             : using namespace dwarf;
      16             : 
      17     3596471 : void DWARFAbbreviationDeclaration::clear() {
      18     3596471 :   Code = 0;
      19     3596471 :   Tag = 0;
      20     3596471 :   HasChildren = false;
      21     3596471 :   AttributeSpecs.clear();
      22     3596471 : }
      23             : 
      24       13273 : DWARFAbbreviationDeclaration::DWARFAbbreviationDeclaration() {
      25       13273 :   clear();
      26       13273 : }
      27             : 
      28             : bool
      29     3583198 : DWARFAbbreviationDeclaration::extract(DataExtractor Data, uint32_t* OffsetPtr) {
      30     3583198 :   clear();
      31     3583198 :   Code = Data.getULEB128(OffsetPtr);
      32     3583198 :   if (Code == 0) {
      33             :     return false;
      34             :   }
      35     3569925 :   Tag = Data.getULEB128(OffsetPtr);
      36     3569925 :   uint8_t ChildrenByte = Data.getU8(OffsetPtr);
      37     3569925 :   HasChildren = (ChildrenByte == DW_CHILDREN_yes);
      38             : 
      39             :   while (true) {
      40    22279055 :     uint32_t CurOffset = *OffsetPtr;
      41    22279055 :     uint16_t Attr = Data.getULEB128(OffsetPtr);
      42    22279055 :     if (CurOffset == *OffsetPtr) {
      43           0 :       clear();
      44           0 :       return false;
      45             :     }
      46    22279055 :     CurOffset = *OffsetPtr;
      47    22279055 :     uint16_t Form = Data.getULEB128(OffsetPtr);
      48    22279055 :     if (CurOffset == *OffsetPtr) {
      49           0 :       clear();
      50           0 :       return false;
      51             :     }
      52    22279055 :     if (Attr == 0 && Form == 0)
      53             :       break;
      54    37418260 :     AttributeSpecs.push_back(AttributeSpec(Attr, Form));
      55             :   }
      56             : 
      57     3569925 :   if (Tag == 0) {
      58           0 :     clear();
      59           0 :     return false;
      60             :   }
      61    18709130 :   return true;
      62             : }
      63             : 
      64         599 : void DWARFAbbreviationDeclaration::dump(raw_ostream &OS) const {
      65         599 :   const char *tagString = TagString(getTag());
      66        1198 :   OS << '[' << getCode() << "] ";
      67         599 :   if (tagString)
      68         599 :     OS << tagString;
      69             :   else
      70           0 :     OS << format("DW_TAG_Unknown_%x", getTag());
      71         599 :   OS << "\tDW_CHILDREN_" << (hasChildren() ? "yes" : "no") << '\n';
      72        3463 :   for (const AttributeSpec &Spec : AttributeSpecs) {
      73        2864 :     OS << '\t';
      74        2864 :     const char *attrString = AttributeString(Spec.Attr);
      75        2864 :     if (attrString)
      76        2863 :       OS << attrString;
      77             :     else
      78           3 :       OS << format("DW_AT_Unknown_%x", Spec.Attr);
      79        2864 :     OS << '\t';
      80        2864 :     const char *formString = FormEncodingString(Spec.Form);
      81        2864 :     if (formString)
      82        2864 :       OS << formString;
      83             :     else
      84           0 :       OS << format("DW_FORM_Unknown_%x", Spec.Form);
      85        2864 :     OS << '\n';
      86             :   }
      87         599 :   OS << '\n';
      88         599 : }
      89             : 
      90             : uint32_t
      91     6277017 : DWARFAbbreviationDeclaration::findAttributeIndex(uint16_t attr) const {
      92    66720299 :   for (uint32_t i = 0, e = AttributeSpecs.size(); i != e; ++i) {
      93   108515426 :     if (AttributeSpecs[i].Attr == attr)
      94       91448 :       return i;
      95             :   }
      96             :   return -1U;
      97             : }

Generated by: LCOV version 1.11