LLVM  6.0.0svn
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 
11 #include "llvm/ADT/StringRef.h"
14 #include "llvm/Support/Format.h"
16 #include <cstdint>
17 
18 using namespace llvm;
19 using namespace dwarf;
20 
22  bool GnuStyle)
23  : GnuStyle(GnuStyle) {
24  DataExtractor PubNames(Data, LittleEndian, 0);
25  uint32_t Offset = 0;
26  while (PubNames.isValidOffset(Offset)) {
27  Sets.push_back({});
28  Set &SetData = Sets.back();
29 
30  SetData.Length = PubNames.getU32(&Offset);
31  SetData.Version = PubNames.getU16(&Offset);
32  SetData.Offset = PubNames.getU32(&Offset);
33  SetData.Size = PubNames.getU32(&Offset);
34 
35  while (Offset < Data.size()) {
36  uint32_t DieRef = PubNames.getU32(&Offset);
37  if (DieRef == 0)
38  break;
39  uint8_t IndexEntryValue = GnuStyle ? PubNames.getU8(&Offset) : 0;
40  const char *Name = PubNames.getCStr(&Offset);
41  SetData.Entries.push_back(
42  {DieRef, PubIndexEntryDescriptor(IndexEntryValue), Name});
43  }
44  }
45 }
46 
48  for (const Set &S : Sets) {
49  OS << "length = " << format("0x%08x", S.Length);
50  OS << " version = " << format("0x%04x", S.Version);
51  OS << " unit_offset = " << format("0x%08x", S.Offset);
52  OS << " unit_size = " << format("0x%08x", S.Size) << '\n';
53  OS << (GnuStyle ? "Offset Linkage Kind Name\n"
54  : "Offset Name\n");
55 
56  for (const Entry &E : S.Entries) {
57  OS << format("0x%8.8x ", E.SecOffset);
58  if (GnuStyle) {
59  StringRef EntryLinkage =
62  OS << format("%-8s", EntryLinkage.data()) << ' '
63  << format("%-8s", EntryKind.data()) << ' ';
64  }
65  OS << '\"' << E.Name << "\"\n";
66  }
67  }
68 }
const char * Name
The name of the object as given by the DW_AT_name attribute of the referenced DIE.
Compute iterated dominance frontiers using a linear time algorithm.
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
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.
Describes an entry of the various gnu_pub* debug sections.
Definition: Dwarf.h:492
StringRef GDBIndexEntryKindString(GDBIndexEntryKind Kind)
Definition: Dwarf.cpp:506
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:529
GDBIndexEntryLinkage Linkage
Definition: Dwarf.h:494
DWARFDebugPubTable(StringRef Data, bool LittleEndian, bool GnuStyle)
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.
const char * getCStr(uint32_t *offset_ptr) const
Extract a C string from *offset_ptr.
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...
This class implements an extremely fast bulk output stream that can only output to a stream...
Definition: raw_ostream.h:44
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:49