LCOV - code coverage report
Current view: top level - lib/DebugInfo/DWARF - DWARFDebugPubTable.cpp (source / functions) Hit Total Coverage
Test: llvm-toolchain.info Lines: 34 34 100.0 %
Date: 2018-09-23 13:06:45 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         245 : DWARFDebugPubTable::DWARFDebugPubTable(StringRef Data, bool LittleEndian,
      22         245 :                                        bool GnuStyle)
      23         490 :     : GnuStyle(GnuStyle) {
      24             :   DataExtractor PubNames(Data, LittleEndian, 0);
      25         245 :   uint32_t Offset = 0;
      26        1192 :   while (PubNames.isValidOffset(Offset)) {
      27         702 :     Sets.push_back({});
      28             :     Set &SetData = Sets.back();
      29             : 
      30         351 :     SetData.Length = PubNames.getU32(&Offset);
      31         351 :     SetData.Version = PubNames.getU16(&Offset);
      32         351 :     SetData.Offset = PubNames.getU32(&Offset);
      33         351 :     SetData.Size = PubNames.getU32(&Offset);
      34             : 
      35        1000 :     while (Offset < Data.size()) {
      36        1000 :       uint32_t DieRef = PubNames.getU32(&Offset);
      37        1000 :       if (DieRef == 0)
      38             :         break;
      39         649 :       uint8_t IndexEntryValue = GnuStyle ? PubNames.getU8(&Offset) : 0;
      40         649 :       StringRef Name = PubNames.getCStrRef(&Offset);
      41        1298 :       SetData.Entries.push_back(
      42             :           {DieRef, PubIndexEntryDescriptor(IndexEntryValue), Name});
      43             :     }
      44             :   }
      45         245 : }
      46             : 
      47         223 : void DWARFDebugPubTable::dump(raw_ostream &OS) const {
      48         566 :   for (const Set &S : Sets) {
      49         343 :     OS << "length = " << format("0x%08x", S.Length);
      50         343 :     OS << " version = " << format("0x%04x", S.Version);
      51         343 :     OS << " unit_offset = " << format("0x%08x", S.Offset);
      52         343 :     OS << " unit_size = " << format("0x%08x", S.Size) << '\n';
      53         343 :     OS << (GnuStyle ? "Offset     Linkage  Kind     Name\n"
      54         678 :                     : "Offset     Name\n");
      55             : 
      56         984 :     for (const Entry &E : S.Entries) {
      57        1282 :       OS << format("0x%8.8x ", E.SecOffset);
      58         641 :       if (GnuStyle) {
      59             :         StringRef EntryLinkage =
      60          29 :             GDBIndexEntryLinkageString(E.Descriptor.Linkage);
      61          29 :         StringRef EntryKind = dwarf::GDBIndexEntryKindString(E.Descriptor.Kind);
      62          29 :         OS << format("%-8s", EntryLinkage.data()) << ' '
      63          58 :            << format("%-8s", EntryKind.data()) << ' ';
      64             :       }
      65         641 :       OS << '\"' << E.Name << "\"\n";
      66             :     }
      67             :   }
      68         223 : }

Generated by: LCOV version 1.13