LCOV - code coverage report
Current view: top level - lib/DebugInfo/DWARF - DWARFDebugPubTable.cpp (source / functions) Hit Total Coverage
Test: llvm-toolchain.info Lines: 37 37 100.0 %
Date: 2017-09-14 15:23:50 Functions: 2 2 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : //===- DWARFDebugPubTable.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/DWARF/DWARFDebugPubTable.h"
      11             : #include "llvm/ADT/StringRef.h"
      12             : #include "llvm/BinaryFormat/Dwarf.h"
      13             : #include "llvm/Support/DataExtractor.h"
      14             : #include "llvm/Support/Format.h"
      15             : #include "llvm/Support/raw_ostream.h"
      16             : #include <cstdint>
      17             : 
      18             : using namespace llvm;
      19             : using namespace dwarf;
      20             : 
      21         687 : DWARFDebugPubTable::DWARFDebugPubTable(StringRef Data, bool LittleEndian,
      22         687 :                                        bool GnuStyle)
      23        1374 :     : GnuStyle(GnuStyle) {
      24        1374 :   DataExtractor PubNames(Data, LittleEndian, 0);
      25         687 :   uint32_t Offset = 0;
      26        1918 :   while (PubNames.isValidOffset(Offset)) {
      27        1088 :     Sets.push_back({});
      28         544 :     Set &SetData = Sets.back();
      29             : 
      30         272 :     SetData.Length = PubNames.getU32(&Offset);
      31         272 :     SetData.Version = PubNames.getU16(&Offset);
      32         272 :     SetData.Offset = PubNames.getU32(&Offset);
      33         272 :     SetData.Size = PubNames.getU32(&Offset);
      34             : 
      35        1338 :     while (Offset < Data.size()) {
      36         805 :       uint32_t DieRef = PubNames.getU32(&Offset);
      37         805 :       if (DieRef == 0)
      38             :         break;
      39         533 :       uint8_t IndexEntryValue = GnuStyle ? PubNames.getU8(&Offset) : 0;
      40         533 :       const char *Name = PubNames.getCStr(&Offset);
      41        1599 :       SetData.Entries.push_back(
      42             :           {DieRef, PubIndexEntryDescriptor(IndexEntryValue), Name});
      43             :     }
      44             :   }
      45         687 : }
      46             : 
      47         669 : void DWARFDebugPubTable::dump(StringRef Name, raw_ostream &OS) const {
      48         669 :   OS << "\n." << Name << " contents:\n";
      49        2943 :   for (const Set &S : Sets) {
      50         534 :     OS << "length = " << format("0x%08x", S.Length);
      51         534 :     OS << " version = " << format("0x%04x", S.Version);
      52         534 :     OS << " unit_offset = " << format("0x%08x", S.Offset);
      53         801 :     OS << " unit_size = " << format("0x%08x", S.Size) << '\n';
      54         534 :     OS << (GnuStyle ? "Offset     Linkage  Kind     Name\n"
      55         267 :                     : "Offset     Name\n");
      56             : 
      57        1595 :     for (const Entry &E : S.Entries) {
      58        1054 :       OS << format("0x%8.8x ", E.SecOffset);
      59         527 :       if (GnuStyle) {
      60             :         StringRef EntryLinkage =
      61          29 :             GDBIndexEntryLinkageString(E.Descriptor.Linkage);
      62          29 :         StringRef EntryKind = dwarf::GDBIndexEntryKindString(E.Descriptor.Kind);
      63         116 :         OS << format("%-8s", EntryLinkage.data()) << ' '
      64          87 :            << format("%-8s", EntryKind.data()) << ' ';
      65             :       }
      66         527 :       OS << '\"' << E.Name << "\"\n";
      67             :     }
      68             :   }
      69         669 : }

Generated by: LCOV version 1.13