LLVM  3.7.0
DWARFDebugInfoEntry.h
Go to the documentation of this file.
1 //===-- DWARFDebugInfoEntry.h -----------------------------------*- C++ -*-===//
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 #ifndef LLVM_LIB_DEBUGINFO_DWARFDEBUGINFOENTRY_H
11 #define LLVM_LIB_DEBUGINFO_DWARFDEBUGINFOENTRY_H
12 
13 #include "llvm/ADT/SmallVector.h"
17 #include "llvm/Support/DataTypes.h"
18 
19 namespace llvm {
20 
21 class DWARFDebugAranges;
22 class DWARFCompileUnit;
23 class DWARFUnit;
24 class DWARFContext;
25 class DWARFFormValue;
26 struct DWARFDebugInfoEntryInlinedChain;
27 
28 /// DWARFDebugInfoEntryMinimal - A DIE with only the minimum required data.
30  /// Offset within the .debug_info of the start of this entry.
31  uint32_t Offset;
32 
33  /// How many to add to "this" to get the sibling.
34  uint32_t SiblingIdx;
35 
36  const DWARFAbbreviationDeclaration *AbbrevDecl;
37 public:
39  : Offset(0), SiblingIdx(0), AbbrevDecl(nullptr) {}
40 
41  void dump(raw_ostream &OS, DWARFUnit *u, unsigned recurseDepth,
42  unsigned indent = 0) const;
43  void dumpAttribute(raw_ostream &OS, DWARFUnit *u, uint32_t *offset_ptr,
44  uint16_t attr, uint16_t form, unsigned indent = 0) const;
45 
46  /// Extracts a debug info entry, which is a child of a given unit,
47  /// starting at a given offset. If DIE can't be extracted, returns false and
48  /// doesn't change OffsetPtr.
49  bool extractFast(const DWARFUnit *U, uint32_t *OffsetPtr);
50 
51  uint32_t getTag() const { return AbbrevDecl ? AbbrevDecl->getTag() : 0; }
52  bool isNULL() const { return AbbrevDecl == nullptr; }
53 
54  /// Returns true if DIE represents a subprogram (not inlined).
55  bool isSubprogramDIE() const;
56  /// Returns true if DIE represents a subprogram or an inlined
57  /// subroutine.
58  bool isSubroutineDIE() const;
59 
60  uint32_t getOffset() const { return Offset; }
61  bool hasChildren() const { return !isNULL() && AbbrevDecl->hasChildren(); }
62 
63  // We know we are kept in a vector of contiguous entries, so we know
64  // our sibling will be some index after "this".
66  return SiblingIdx > 0 ? this + SiblingIdx : nullptr;
67  }
68 
69  // We know we are kept in a vector of contiguous entries, so we know
70  // we don't need to store our child pointer, if we have a child it will
71  // be the next entry in the list...
73  return hasChildren() ? this + 1 : nullptr;
74  }
75 
76  void setSibling(const DWARFDebugInfoEntryMinimal *Sibling) {
77  if (Sibling) {
78  // We know we are kept in a vector of contiguous entries, so we know
79  // our sibling will be some index after "this".
80  SiblingIdx = Sibling - this;
81  } else
82  SiblingIdx = 0;
83  }
84 
86  return AbbrevDecl;
87  }
88 
89  bool getAttributeValue(const DWARFUnit *U, const uint16_t Attr,
90  DWARFFormValue &FormValue) const;
91 
92  const char *getAttributeValueAsString(const DWARFUnit *U, const uint16_t Attr,
93  const char *FailValue) const;
94 
95  uint64_t getAttributeValueAsAddress(const DWARFUnit *U, const uint16_t Attr,
96  uint64_t FailValue) const;
97 
99  const uint16_t Attr,
100  uint64_t FailValue) const;
101 
102  uint64_t getAttributeValueAsReference(const DWARFUnit *U, const uint16_t Attr,
103  uint64_t FailValue) const;
104 
106  const uint16_t Attr,
107  uint64_t FailValue) const;
108 
109  uint64_t getRangesBaseAttribute(const DWARFUnit *U, uint64_t FailValue) const;
110 
111  /// Retrieves DW_AT_low_pc and DW_AT_high_pc from CU.
112  /// Returns true if both attributes are present.
113  bool getLowAndHighPC(const DWARFUnit *U, uint64_t &LowPC,
114  uint64_t &HighPC) const;
115 
117 
120 
122  const uint64_t Address) const;
123 
124  /// If a DIE represents a subprogram (or inlined subroutine),
125  /// returns its mangled name (or short name, if mangled is missing).
126  /// This name may be fetched from specification or abstract origin
127  /// for this subprogram. Returns null if no name is found.
128  const char *getSubroutineName(const DWARFUnit *U, DINameKind Kind) const;
129 
130  /// Return the DIE name resolving DW_AT_sepcification or
131  /// DW_AT_abstract_origin references if necessary.
132  /// Returns null if no name is found.
133  const char *getName(const DWARFUnit *U, DINameKind Kind) const;
134 
135  /// Retrieves values of DW_AT_call_file, DW_AT_call_line and
136  /// DW_AT_call_column from DIE (or zeroes if they are missing).
137  void getCallerFrame(const DWARFUnit *U, uint32_t &CallFile,
138  uint32_t &CallLine, uint32_t &CallColumn) const;
139 
140  /// Get inlined chain for a given address, rooted at the current DIE.
141  /// Returns empty chain if address is not contained in address range
142  /// of current DIE.
144  getInlinedChainForAddress(const DWARFUnit *U, const uint64_t Address) const;
145 };
146 
147 /// DWARFDebugInfoEntryInlinedChain - represents a chain of inlined_subroutine
148 /// DIEs, (possibly ending with subprogram DIE), all of which are contained
149 /// in some concrete inlined instance tree. Address range for each DIE
150 /// (except the last DIE) in this chain is contained in address
151 /// range for next DIE in the chain.
155  const DWARFUnit *U;
156 };
157 
158 }
159 
160 #endif
DWARFAddressRangesVector getAddressRanges(const DWARFUnit *U) const
const char * getSubroutineName(const DWARFUnit *U, DINameKind Kind) const
If a DIE represents a subprogram (or inlined subroutine), returns its mangled name (or short name...
uint64_t getAttributeValueAsAddress(const DWARFUnit *U, const uint16_t Attr, uint64_t FailValue) const
std::vector< std::pair< uint64_t, uint64_t > > DWARFAddressRangesVector
DWARFAddressRangesVector - represents a set of absolute address ranges.
const char * getName(const DWARFUnit *U, DINameKind Kind) const
Return the DIE name resolving DW_AT_sepcification or DW_AT_abstract_origin references if necessary...
DWARFDebugInfoEntryInlinedChain getInlinedChainForAddress(const DWARFUnit *U, const uint64_t Address) const
Get inlined chain for a given address, rooted at the current DIE.
const DWARFDebugInfoEntryMinimal * getFirstChild() const
uint64_t getRangesBaseAttribute(const DWARFUnit *U, uint64_t FailValue) const
DINameKind
A DINameKind is passed to name search methods to specify a preference regarding the type of name reso...
Definition: DIContext.h:70
const char * getAttributeValueAsString(const DWARFUnit *U, const uint16_t Attr, const char *FailValue) const
void collectChildrenAddressRanges(const DWARFUnit *U, DWARFAddressRangesVector &Ranges) const
bool addressRangeContainsAddress(const DWARFUnit *U, const uint64_t Address) const
SmallVector< DWARFDebugInfoEntryMinimal, 4 > DIEs
uint64_t getAttributeValueAsReference(const DWARFUnit *U, const uint16_t Attr, uint64_t FailValue) const
const DWARFAbbreviationDeclaration * getAbbreviationDeclarationPtr() const
DWARFDebugInfoEntryMinimal - A DIE with only the minimum required data.
void dump(raw_ostream &OS, DWARFUnit *u, unsigned recurseDepth, unsigned indent=0) const
const DWARFDebugInfoEntryMinimal * getSibling() const
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
Definition: SmallVector.h:861
uint64_t getAttributeValueAsUnsignedConstant(const DWARFUnit *U, const uint16_t Attr, uint64_t FailValue) const
uint64_t getAttributeValueAsSectionOffset(const DWARFUnit *U, const uint16_t Attr, uint64_t FailValue) const
void getCallerFrame(const DWARFUnit *U, uint32_t &CallFile, uint32_t &CallLine, uint32_t &CallColumn) const
Retrieves values of DW_AT_call_file, DW_AT_call_line and DW_AT_call_column from DIE (or zeroes if the...
SI Fix SGPR Live Ranges
void setSibling(const DWARFDebugInfoEntryMinimal *Sibling)
bool isSubroutineDIE() const
Returns true if DIE represents a subprogram or an inlined subroutine.
void dumpAttribute(raw_ostream &OS, DWARFUnit *u, uint32_t *offset_ptr, uint16_t attr, uint16_t form, unsigned indent=0) const
bool getLowAndHighPC(const DWARFUnit *U, uint64_t &LowPC, uint64_t &HighPC) const
Retrieves DW_AT_low_pc and DW_AT_high_pc from CU.
const ARM::ArchExtKind Kind
bool isSubprogramDIE() const
Returns true if DIE represents a subprogram (not inlined).
This class implements an extremely fast bulk output stream that can only output to a stream...
Definition: raw_ostream.h:38
bool getAttributeValue(const DWARFUnit *U, const uint16_t Attr, DWARFFormValue &FormValue) const
bool extractFast(const DWARFUnit *U, uint32_t *OffsetPtr)
Extracts a debug info entry, which is a child of a given unit, starting at a given offset...
DWARFDebugInfoEntryInlinedChain - represents a chain of inlined_subroutine DIEs, (possibly ending wit...