LLVM  8.0.1
DWARFDebugPubTable.cpp
Go to the documentation of this file.
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 
12 #include "llvm/ADT/StringRef.h"
15 #include "llvm/Support/Format.h"
17 #include <cstdint>
18 
19 using namespace llvm;
20 using namespace dwarf;
21 
23  const DWARFSection &Sec,
24  bool LittleEndian, bool GnuStyle)
25  : GnuStyle(GnuStyle) {
26  DWARFDataExtractor PubNames(Obj, Sec, LittleEndian, 0);
27  uint32_t Offset = 0;
28  while (PubNames.isValidOffset(Offset)) {
29  Sets.push_back({});
30  Set &SetData = Sets.back();
31 
32  SetData.Length = PubNames.getU32(&Offset);
33  SetData.Version = PubNames.getU16(&Offset);
34  SetData.Offset = PubNames.getRelocatedValue(4, &Offset);
35  SetData.Size = PubNames.getU32(&Offset);
36 
37  while (Offset < Sec.Data.size()) {
38  uint32_t DieRef = PubNames.getU32(&Offset);
39  if (DieRef == 0)
40  break;
41  uint8_t IndexEntryValue = GnuStyle ? PubNames.getU8(&Offset) : 0;
42  StringRef Name = PubNames.getCStrRef(&Offset);
43  SetData.Entries.push_back(
44  {DieRef, PubIndexEntryDescriptor(IndexEntryValue), Name});
45  }
46  }
47 }
48 
50  for (const Set &S : Sets) {
51  OS << "length = " << format("0x%08x", S.Length);
52  OS << " version = " << format("0x%04x", S.Version);
53  OS << " unit_offset = " << format("0x%08x", S.Offset);
54  OS << " unit_size = " << format("0x%08x", S.Size) << '\n';
55  OS << (GnuStyle ? "Offset Linkage Kind Name\n"
56  : "Offset Name\n");
57 
58  for (const Entry &E : S.Entries) {
59  OS << format("0x%8.8x ", E.SecOffset);
60  if (GnuStyle) {
61  StringRef EntryLinkage =
64  OS << format("%-8s", EntryLinkage.data()) << ' '
65  << format("%-8s", EntryKind.data()) << ' ';
66  }
67  OS << '\"' << E.Name << "\"\n";
68  }
69  }
70 }
This class represents lattice values for constants.
Definition: AllocatorList.h:24
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE size_t size() const
size - Get the string size.
Definition: StringRef.h:138
format_object< Ts... > format(const char *Fmt, const Ts &... Vals)
These are helper functions used to produce formatted output.
Definition: Format.h:124
uint16_t getU16(uint32_t *offset_ptr) const
Extract a uint16_t value from *offset_ptr.
void dump(raw_ostream &OS) const
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE const char * data() const
data - Get a pointer to the start of the string (which may not be null terminated).
Definition: StringRef.h:128
amdgpu Simplify well known AMD library false Value Value const Twine & Name
uint32_t getU32(uint32_t *offset_ptr) const
Extract a uint32_t value from *offset_ptr.
Each table consists of sets of variable length entries.
DWARFDebugPubTable(const DWARFObject &Obj, const DWARFSection &Sec, bool LittleEndian, bool GnuStyle)
Describes an entry of the various gnu_pub* debug sections.
Definition: Dwarf.h:561
StringRef GDBIndexEntryKindString(GDBIndexEntryKind Kind)
Definition: Dwarf.cpp:540
uint32_t Size
The size in bytes of the contents of the .debug_info section generated to represent that compilation ...
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
uint8_t getU8(uint32_t *offset_ptr) const
Extract a uint8_t value from *offset_ptr.
uint32_t Length
The total length of the entries for that set, not including the length field itself.
StringRef GDBIndexEntryLinkageString(GDBIndexEntryLinkage Linkage)
Definition: Dwarf.cpp:563
GDBIndexEntryLinkage Linkage
Definition: Dwarf.h:563
uint64_t getRelocatedValue(uint32_t Size, uint32_t *Off, uint64_t *SectionIndex=nullptr) const
Extracts a value and applies a relocation to the result if one exists for the given offset...
A DataExtractor (typically for an in-memory copy of an object-file section) plus a relocation map for...
uint32_t Offset
The offset from the beginning of the .debug_info section of the compilation unit header referenced by...
uint32_t SecOffset
Section offset from the beginning of the compilation unit.
This file contains constants used for implementing Dwarf debug support.
dwarf::PubIndexEntryDescriptor Descriptor
An entry of the various gnu_pub* debug sections.
bool isValidOffset(uint32_t offset) const
Test the validity of offset.
uint16_t Version
This number is specific to the name lookup table and is independent of the DWARF version number...
StringRef getCStrRef(uint32_t *OffsetPtr) const
Extract a C string from *OffsetPtr.
This class implements an extremely fast bulk output stream that can only output to a stream...
Definition: raw_ostream.h:46
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:49
StringRef Name
The name of the object as given by the DW_AT_name attribute of the referenced DIE.