2011-09-13 21:42:23 +02:00
|
|
|
//===-- DWARFDebugInfoEntry.h -----------------------------------*- C++ -*-===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2014-08-13 18:26:38 +02:00
|
|
|
#ifndef LLVM_LIB_DEBUGINFO_DWARFDEBUGINFOENTRY_H
|
|
|
|
#define LLVM_LIB_DEBUGINFO_DWARFDEBUGINFOENTRY_H
|
2011-09-13 21:42:23 +02:00
|
|
|
|
|
|
|
#include "DWARFAbbreviationDeclaration.h"
|
2014-04-18 19:25:46 +02:00
|
|
|
#include "DWARFDebugRangeList.h"
|
2012-09-04 10:12:33 +02:00
|
|
|
#include "llvm/ADT/SmallVector.h"
|
2014-05-15 23:24:32 +02:00
|
|
|
#include "llvm/DebugInfo/DIContext.h"
|
2011-09-13 21:42:23 +02:00
|
|
|
#include "llvm/Support/DataTypes.h"
|
|
|
|
|
|
|
|
namespace llvm {
|
|
|
|
|
2011-09-14 22:52:27 +02:00
|
|
|
class DWARFDebugAranges;
|
2011-09-13 21:42:23 +02:00
|
|
|
class DWARFCompileUnit;
|
2013-09-24 00:44:40 +02:00
|
|
|
class DWARFUnit;
|
2011-09-13 21:42:23 +02:00
|
|
|
class DWARFContext;
|
|
|
|
class DWARFFormValue;
|
2013-08-06 12:49:15 +02:00
|
|
|
struct DWARFDebugInfoEntryInlinedChain;
|
2011-09-13 21:42:23 +02:00
|
|
|
|
|
|
|
/// DWARFDebugInfoEntryMinimal - A DIE with only the minimum required data.
|
|
|
|
class DWARFDebugInfoEntryMinimal {
|
|
|
|
/// Offset within the .debug_info of the start of this entry.
|
2011-11-05 16:35:00 +01:00
|
|
|
uint32_t Offset;
|
2011-09-13 21:42:23 +02:00
|
|
|
|
|
|
|
/// How many to add to "this" to get the sibling.
|
|
|
|
uint32_t SiblingIdx;
|
|
|
|
|
|
|
|
const DWARFAbbreviationDeclaration *AbbrevDecl;
|
|
|
|
public:
|
2011-09-14 02:15:32 +02:00
|
|
|
DWARFDebugInfoEntryMinimal()
|
2014-04-29 19:12:42 +02:00
|
|
|
: Offset(0), SiblingIdx(0), AbbrevDecl(nullptr) {}
|
2011-09-14 02:15:32 +02:00
|
|
|
|
2013-09-24 00:44:40 +02:00
|
|
|
void dump(raw_ostream &OS, const DWARFUnit *u, unsigned recurseDepth,
|
|
|
|
unsigned indent = 0) const;
|
|
|
|
void dumpAttribute(raw_ostream &OS, const DWARFUnit *u, uint32_t *offset_ptr,
|
|
|
|
uint16_t attr, uint16_t form, unsigned indent = 0) const;
|
2011-09-13 21:42:23 +02:00
|
|
|
|
2013-10-29 00:41:49 +01:00
|
|
|
/// Extracts a debug info entry, which is a child of a given unit,
|
2013-04-08 16:37:16 +02:00
|
|
|
/// starting at a given offset. If DIE can't be extracted, returns false and
|
|
|
|
/// doesn't change OffsetPtr.
|
2013-10-29 00:41:49 +01:00
|
|
|
bool extractFast(const DWARFUnit *U, uint32_t *OffsetPtr);
|
2011-09-13 21:42:23 +02:00
|
|
|
|
|
|
|
uint32_t getTag() const { return AbbrevDecl ? AbbrevDecl->getTag() : 0; }
|
2014-04-28 06:05:08 +02:00
|
|
|
bool isNULL() const { return AbbrevDecl == nullptr; }
|
2012-09-04 10:12:33 +02:00
|
|
|
|
|
|
|
/// Returns true if DIE represents a subprogram (not inlined).
|
|
|
|
bool isSubprogramDIE() const;
|
|
|
|
/// Returns true if DIE represents a subprogram or an inlined
|
|
|
|
/// subroutine.
|
|
|
|
bool isSubroutineDIE() const;
|
|
|
|
|
2011-11-05 16:35:00 +01:00
|
|
|
uint32_t getOffset() const { return Offset; }
|
2011-09-13 21:42:23 +02:00
|
|
|
bool hasChildren() const { return !isNULL() && AbbrevDecl->hasChildren(); }
|
|
|
|
|
|
|
|
// We know we are kept in a vector of contiguous entries, so we know
|
|
|
|
// our sibling will be some index after "this".
|
|
|
|
const DWARFDebugInfoEntryMinimal *getSibling() const {
|
2014-04-28 06:05:08 +02:00
|
|
|
return SiblingIdx > 0 ? this + SiblingIdx : nullptr;
|
2011-09-13 21:42:23 +02:00
|
|
|
}
|
2014-04-29 19:12:42 +02:00
|
|
|
|
2011-09-13 21:42:23 +02:00
|
|
|
// We know we are kept in a vector of contiguous entries, so we know
|
|
|
|
// we don't need to store our child pointer, if we have a child it will
|
|
|
|
// be the next entry in the list...
|
|
|
|
const DWARFDebugInfoEntryMinimal *getFirstChild() const {
|
2014-04-28 06:05:08 +02:00
|
|
|
return hasChildren() ? this + 1 : nullptr;
|
2011-09-13 21:42:23 +02:00
|
|
|
}
|
|
|
|
|
2014-04-29 19:12:42 +02:00
|
|
|
void setSibling(const DWARFDebugInfoEntryMinimal *Sibling) {
|
|
|
|
if (Sibling) {
|
2011-09-13 21:42:23 +02:00
|
|
|
// We know we are kept in a vector of contiguous entries, so we know
|
|
|
|
// our sibling will be some index after "this".
|
2014-04-29 19:12:42 +02:00
|
|
|
SiblingIdx = Sibling - this;
|
2011-09-13 23:47:32 +02:00
|
|
|
} else
|
2011-09-13 21:42:23 +02:00
|
|
|
SiblingIdx = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
const DWARFAbbreviationDeclaration *getAbbreviationDeclarationPtr() const {
|
|
|
|
return AbbrevDecl;
|
|
|
|
}
|
|
|
|
|
2013-10-17 15:28:16 +02:00
|
|
|
bool getAttributeValue(const DWARFUnit *U, const uint16_t Attr,
|
|
|
|
DWARFFormValue &FormValue) const;
|
2011-09-13 21:42:23 +02:00
|
|
|
|
2013-10-17 15:28:16 +02:00
|
|
|
const char *getAttributeValueAsString(const DWARFUnit *U, const uint16_t Attr,
|
|
|
|
const char *FailValue) const;
|
2011-09-13 21:42:23 +02:00
|
|
|
|
2013-09-24 00:44:40 +02:00
|
|
|
uint64_t getAttributeValueAsAddress(const DWARFUnit *U, const uint16_t Attr,
|
2013-08-27 11:20:22 +02:00
|
|
|
uint64_t FailValue) const;
|
|
|
|
|
2013-10-29 00:01:48 +01:00
|
|
|
uint64_t getAttributeValueAsUnsignedConstant(const DWARFUnit *U,
|
|
|
|
const uint16_t Attr,
|
|
|
|
uint64_t FailValue) const;
|
2011-09-13 21:42:23 +02:00
|
|
|
|
2013-10-17 15:28:16 +02:00
|
|
|
uint64_t getAttributeValueAsReference(const DWARFUnit *U, const uint16_t Attr,
|
|
|
|
uint64_t FailValue) const;
|
2011-09-14 22:52:27 +02:00
|
|
|
|
2013-10-29 00:01:48 +01:00
|
|
|
uint64_t getAttributeValueAsSectionOffset(const DWARFUnit *U,
|
|
|
|
const uint16_t Attr,
|
|
|
|
uint64_t FailValue) const;
|
|
|
|
|
2014-06-14 00:31:03 +02:00
|
|
|
uint64_t getRangesBaseAttribute(const DWARFUnit *U, uint64_t FailValue) const;
|
|
|
|
|
2012-09-04 10:12:33 +02:00
|
|
|
/// Retrieves DW_AT_low_pc and DW_AT_high_pc from CU.
|
|
|
|
/// Returns true if both attributes are present.
|
2013-09-24 00:44:40 +02:00
|
|
|
bool getLowAndHighPC(const DWARFUnit *U, uint64_t &LowPC,
|
|
|
|
uint64_t &HighPC) const;
|
2012-09-04 10:12:33 +02:00
|
|
|
|
2014-04-18 19:25:46 +02:00
|
|
|
DWARFAddressRangesVector getAddressRanges(const DWARFUnit *U) const;
|
|
|
|
|
|
|
|
void collectChildrenAddressRanges(const DWARFUnit *U,
|
|
|
|
DWARFAddressRangesVector &Ranges) const;
|
2012-09-04 10:12:33 +02:00
|
|
|
|
2013-09-24 00:44:40 +02:00
|
|
|
bool addressRangeContainsAddress(const DWARFUnit *U,
|
2012-09-04 10:12:33 +02:00
|
|
|
const uint64_t Address) const;
|
|
|
|
|
|
|
|
/// If a DIE represents a subprogram (or inlined subroutine),
|
|
|
|
/// returns its mangled name (or short name, if mangled is missing).
|
|
|
|
/// This name may be fetched from specification or abstract origin
|
|
|
|
/// for this subprogram. Returns null if no name is found.
|
2014-05-15 23:24:32 +02:00
|
|
|
const char *
|
|
|
|
getSubroutineName(const DWARFUnit *U,
|
|
|
|
DILineInfoSpecifier::FunctionNameKind Kind) const;
|
2012-09-04 10:12:33 +02:00
|
|
|
|
|
|
|
/// Retrieves values of DW_AT_call_file, DW_AT_call_line and
|
|
|
|
/// DW_AT_call_column from DIE (or zeroes if they are missing).
|
2013-09-24 00:44:40 +02:00
|
|
|
void getCallerFrame(const DWARFUnit *U, uint32_t &CallFile,
|
2012-09-04 10:12:33 +02:00
|
|
|
uint32_t &CallLine, uint32_t &CallColumn) const;
|
|
|
|
|
|
|
|
/// Get inlined chain for a given address, rooted at the current DIE.
|
|
|
|
/// Returns empty chain if address is not contained in address range
|
|
|
|
/// of current DIE.
|
2013-08-06 12:49:15 +02:00
|
|
|
DWARFDebugInfoEntryInlinedChain
|
2013-09-24 00:44:40 +02:00
|
|
|
getInlinedChainForAddress(const DWARFUnit *U, const uint64_t Address) const;
|
2013-08-06 12:49:15 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
/// DWARFDebugInfoEntryInlinedChain - represents a chain of inlined_subroutine
|
|
|
|
/// DIEs, (possibly ending with subprogram DIE), all of which are contained
|
|
|
|
/// in some concrete inlined instance tree. Address range for each DIE
|
|
|
|
/// (except the last DIE) in this chain is contained in address
|
|
|
|
/// range for next DIE in the chain.
|
|
|
|
struct DWARFDebugInfoEntryInlinedChain {
|
2014-04-28 06:05:08 +02:00
|
|
|
DWARFDebugInfoEntryInlinedChain() : U(nullptr) {}
|
2013-08-06 12:49:15 +02:00
|
|
|
SmallVector<DWARFDebugInfoEntryMinimal, 4> DIEs;
|
2013-09-24 00:44:40 +02:00
|
|
|
const DWARFUnit *U;
|
2011-09-13 21:42:23 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|