Coverage Report

Created: 2019-07-24 05:18

/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/lib/DebugInfo/DWARF/DWARFDebugPubTable.cpp
Line
Count
Source
1
//===- DWARFDebugPubTable.cpp ---------------------------------------------===//
2
//
3
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4
// See https://llvm.org/LICENSE.txt for license information.
5
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6
//
7
//===----------------------------------------------------------------------===//
8
9
#include "llvm/DebugInfo/DWARF/DWARFDebugPubTable.h"
10
#include "llvm/DebugInfo/DWARF/DWARFDataExtractor.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
DWARFDebugPubTable::DWARFDebugPubTable(const DWARFObject &Obj,
22
                                       const DWARFSection &Sec,
23
                                       bool LittleEndian, bool GnuStyle)
24
197
    : GnuStyle(GnuStyle) {
25
197
  DWARFDataExtractor PubNames(Obj, Sec, LittleEndian, 0);
26
197
  uint32_t Offset = 0;
27
482
  while (PubNames.isValidOffset(Offset)) {
28
285
    Sets.push_back({});
29
285
    Set &SetData = Sets.back();
30
285
31
285
    SetData.Length = PubNames.getU32(&Offset);
32
285
    SetData.Version = PubNames.getU16(&Offset);
33
285
    SetData.Offset = PubNames.getRelocatedValue(4, &Offset);
34
285
    SetData.Size = PubNames.getU32(&Offset);
35
285
36
850
    while (Offset < Sec.Data.size()) {
37
849
      uint32_t DieRef = PubNames.getU32(&Offset);
38
849
      if (DieRef == 0)
39
284
        break;
40
565
      uint8_t IndexEntryValue = GnuStyle ? 
PubNames.getU8(&Offset)47
:
0518
;
41
565
      StringRef Name = PubNames.getCStrRef(&Offset);
42
565
      SetData.Entries.push_back(
43
565
          {DieRef, PubIndexEntryDescriptor(IndexEntryValue), Name});
44
565
    }
45
285
  }
46
197
}
47
48
155
void DWARFDebugPubTable::dump(raw_ostream &OS) const {
49
272
  for (const Set &S : Sets) {
50
272
    OS << "length = " << format("0x%08x", S.Length);
51
272
    OS << " version = " << format("0x%04x", S.Version);
52
272
    OS << " unit_offset = " << format("0x%08x", S.Offset);
53
272
    OS << " unit_size = " << format("0x%08x", S.Size) << '\n';
54
272
    OS << (GnuStyle ? 
"Offset Linkage Kind Name\n"10
55
272
                    : 
"Offset Name\n"262
);
56
272
57
552
    for (const Entry &E : S.Entries) {
58
552
      OS << format("0x%8.8x ", E.SecOffset);
59
552
      if (GnuStyle) {
60
35
        StringRef EntryLinkage =
61
35
            GDBIndexEntryLinkageString(E.Descriptor.Linkage);
62
35
        StringRef EntryKind = dwarf::GDBIndexEntryKindString(E.Descriptor.Kind);
63
35
        OS << format("%-8s", EntryLinkage.data()) << ' '
64
35
           << format("%-8s", EntryKind.data()) << ' ';
65
35
      }
66
552
      OS << '\"' << E.Name << "\"\n";
67
552
    }
68
272
  }
69
155
}