2012-08-23 00:52:51 +00:00
|
|
|
//===-- DWARFDebugInfoEntry.cpp -------------------------------------------===//
|
2011-09-13 19:42:23 +00:00
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "DWARFDebugInfoEntry.h"
|
|
|
|
#include "DWARFCompileUnit.h"
|
|
|
|
#include "DWARFContext.h"
|
|
|
|
#include "DWARFDebugAbbrev.h"
|
2013-04-17 08:29:02 +00:00
|
|
|
#include "llvm/DebugInfo/DWARFFormValue.h"
|
2013-01-07 19:32:41 +00:00
|
|
|
#include "llvm/Support/Debug.h"
|
2011-09-13 19:42:23 +00:00
|
|
|
#include "llvm/Support/Dwarf.h"
|
|
|
|
#include "llvm/Support/Format.h"
|
|
|
|
#include "llvm/Support/raw_ostream.h"
|
|
|
|
using namespace llvm;
|
|
|
|
using namespace dwarf;
|
2014-05-15 21:24:32 +00:00
|
|
|
typedef DILineInfoSpecifier::FunctionNameKind FunctionNameKind;
|
2011-09-13 19:42:23 +00:00
|
|
|
|
2013-09-23 22:44:40 +00:00
|
|
|
void DWARFDebugInfoEntryMinimal::dump(raw_ostream &OS, const DWARFUnit *u,
|
2011-09-13 19:42:23 +00:00
|
|
|
unsigned recurseDepth,
|
|
|
|
unsigned indent) const {
|
2013-09-23 22:44:40 +00:00
|
|
|
DataExtractor debug_info_data = u->getDebugInfoExtractor();
|
2011-09-13 19:42:23 +00:00
|
|
|
uint32_t offset = Offset;
|
|
|
|
|
|
|
|
if (debug_info_data.isValidOffset(offset)) {
|
2011-11-05 15:35:00 +00:00
|
|
|
uint32_t abbrCode = debug_info_data.getULEB128(&offset);
|
2011-09-13 19:42:23 +00:00
|
|
|
|
2011-09-14 17:54:56 +00:00
|
|
|
OS << format("\n0x%8.8x: ", Offset);
|
2011-09-13 19:42:23 +00:00
|
|
|
if (abbrCode) {
|
|
|
|
if (AbbrevDecl) {
|
2011-09-15 05:43:00 +00:00
|
|
|
const char *tagString = TagString(getTag());
|
|
|
|
if (tagString)
|
|
|
|
OS.indent(indent) << tagString;
|
|
|
|
else
|
|
|
|
OS.indent(indent) << format("DW_TAG_Unknown_%x", getTag());
|
|
|
|
OS << format(" [%u] %c\n", abbrCode,
|
|
|
|
AbbrevDecl->hasChildren() ? '*' : ' ');
|
2011-09-13 19:42:23 +00:00
|
|
|
|
2013-01-07 03:27:58 +00:00
|
|
|
// Dump all data in the DIE for the attributes.
|
2014-03-13 07:52:54 +00:00
|
|
|
for (const auto &AttrSpec : AbbrevDecl->attributes()) {
|
|
|
|
dumpAttribute(OS, u, &offset, AttrSpec.Attr, AttrSpec.Form, indent);
|
2011-09-13 19:42:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
const DWARFDebugInfoEntryMinimal *child = getFirstChild();
|
|
|
|
if (recurseDepth > 0 && child) {
|
|
|
|
while (child) {
|
2013-09-23 22:44:40 +00:00
|
|
|
child->dump(OS, u, recurseDepth-1, indent+2);
|
2011-09-13 19:42:23 +00:00
|
|
|
child = child->getSibling();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
OS << "Abbreviation code not found in 'debug_abbrev' class for code: "
|
|
|
|
<< abbrCode << '\n';
|
|
|
|
}
|
|
|
|
} else {
|
2011-09-14 17:54:56 +00:00
|
|
|
OS.indent(indent) << "NULL\n";
|
2011-09-13 19:42:23 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void DWARFDebugInfoEntryMinimal::dumpAttribute(raw_ostream &OS,
|
2013-09-23 22:44:40 +00:00
|
|
|
const DWARFUnit *u,
|
|
|
|
uint32_t *offset_ptr,
|
|
|
|
uint16_t attr, uint16_t form,
|
2011-09-13 19:42:23 +00:00
|
|
|
unsigned indent) const {
|
2013-08-19 03:36:23 +00:00
|
|
|
OS << " ";
|
2011-09-15 05:43:00 +00:00
|
|
|
OS.indent(indent+2);
|
|
|
|
const char *attrString = AttributeString(attr);
|
|
|
|
if (attrString)
|
|
|
|
OS << attrString;
|
|
|
|
else
|
|
|
|
OS << format("DW_AT_Unknown_%x", attr);
|
|
|
|
const char *formString = FormEncodingString(form);
|
|
|
|
if (formString)
|
|
|
|
OS << " [" << formString << ']';
|
|
|
|
else
|
|
|
|
OS << format(" [DW_FORM_Unknown_%x]", form);
|
2011-09-13 19:42:23 +00:00
|
|
|
|
|
|
|
DWARFFormValue formValue(form);
|
|
|
|
|
2013-09-23 22:44:40 +00:00
|
|
|
if (!formValue.extractValue(u->getDebugInfoExtractor(), offset_ptr, u))
|
2011-09-13 19:42:23 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
OS << "\t(";
|
2013-09-23 22:44:40 +00:00
|
|
|
formValue.dump(OS, u);
|
2011-09-13 19:42:23 +00:00
|
|
|
OS << ")\n";
|
|
|
|
}
|
|
|
|
|
2013-09-23 22:44:40 +00:00
|
|
|
bool DWARFDebugInfoEntryMinimal::extractFast(const DWARFUnit *U,
|
2013-04-08 14:37:16 +00:00
|
|
|
uint32_t *OffsetPtr) {
|
|
|
|
Offset = *OffsetPtr;
|
2013-09-23 22:44:40 +00:00
|
|
|
DataExtractor DebugInfoData = U->getDebugInfoExtractor();
|
2013-10-28 23:58:58 +00:00
|
|
|
uint32_t UEndOffset = U->getNextUnitOffset();
|
|
|
|
if (Offset >= UEndOffset || !DebugInfoData.isValidOffset(Offset))
|
|
|
|
return false;
|
2013-04-08 14:37:16 +00:00
|
|
|
uint64_t AbbrCode = DebugInfoData.getULEB128(OffsetPtr);
|
|
|
|
if (0 == AbbrCode) {
|
|
|
|
// NULL debug tag entry.
|
2014-04-15 06:32:26 +00:00
|
|
|
AbbrevDecl = nullptr;
|
2013-04-08 14:37:16 +00:00
|
|
|
return true;
|
|
|
|
}
|
2013-09-23 22:44:40 +00:00
|
|
|
AbbrevDecl = U->getAbbreviations()->getAbbreviationDeclaration(AbbrCode);
|
2014-04-15 06:32:26 +00:00
|
|
|
if (nullptr == AbbrevDecl) {
|
2013-10-28 23:58:58 +00:00
|
|
|
// Restore the original offset.
|
|
|
|
*OffsetPtr = Offset;
|
|
|
|
return false;
|
|
|
|
}
|
2013-10-28 23:41:49 +00:00
|
|
|
ArrayRef<uint8_t> FixedFormSizes = DWARFFormValue::getFixedFormSizes(
|
|
|
|
U->getAddressByteSize(), U->getVersion());
|
|
|
|
assert(FixedFormSizes.size() > 0);
|
2013-04-08 14:37:16 +00:00
|
|
|
|
|
|
|
// Skip all data in the .debug_info for the attributes
|
2014-03-13 07:52:54 +00:00
|
|
|
for (const auto &AttrSpec : AbbrevDecl->attributes()) {
|
|
|
|
uint16_t Form = AttrSpec.Form;
|
2013-04-08 14:37:16 +00:00
|
|
|
|
|
|
|
uint8_t FixedFormSize =
|
2013-10-28 23:41:49 +00:00
|
|
|
(Form < FixedFormSizes.size()) ? FixedFormSizes[Form] : 0;
|
2013-04-08 14:37:16 +00:00
|
|
|
if (FixedFormSize)
|
|
|
|
*OffsetPtr += FixedFormSize;
|
2013-10-28 23:41:49 +00:00
|
|
|
else if (!DWARFFormValue::skipValue(Form, DebugInfoData, OffsetPtr, U)) {
|
2013-04-08 14:37:16 +00:00
|
|
|
// Restore the original offset.
|
|
|
|
*OffsetPtr = Offset;
|
|
|
|
return false;
|
|
|
|
}
|
2011-09-13 19:42:23 +00:00
|
|
|
}
|
2013-04-08 14:37:16 +00:00
|
|
|
return true;
|
2011-09-13 19:42:23 +00:00
|
|
|
}
|
|
|
|
|
2012-09-04 08:12:33 +00:00
|
|
|
bool DWARFDebugInfoEntryMinimal::isSubprogramDIE() const {
|
|
|
|
return getTag() == DW_TAG_subprogram;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool DWARFDebugInfoEntryMinimal::isSubroutineDIE() const {
|
|
|
|
uint32_t Tag = getTag();
|
|
|
|
return Tag == DW_TAG_subprogram ||
|
|
|
|
Tag == DW_TAG_inlined_subroutine;
|
|
|
|
}
|
|
|
|
|
2013-10-17 13:28:16 +00:00
|
|
|
bool DWARFDebugInfoEntryMinimal::getAttributeValue(
|
|
|
|
const DWARFUnit *U, const uint16_t Attr, DWARFFormValue &FormValue) const {
|
|
|
|
if (!AbbrevDecl)
|
|
|
|
return false;
|
2011-09-13 19:42:23 +00:00
|
|
|
|
2013-10-17 13:28:16 +00:00
|
|
|
uint32_t AttrIdx = AbbrevDecl->findAttributeIndex(Attr);
|
|
|
|
if (AttrIdx == -1U)
|
|
|
|
return false;
|
2011-09-13 19:42:23 +00:00
|
|
|
|
2013-10-17 13:28:16 +00:00
|
|
|
DataExtractor DebugInfoData = U->getDebugInfoExtractor();
|
|
|
|
uint32_t DebugInfoOffset = getOffset();
|
2011-09-13 19:42:23 +00:00
|
|
|
|
2013-10-17 13:28:16 +00:00
|
|
|
// Skip the abbreviation code so we are at the data for the attributes
|
|
|
|
DebugInfoData.getULEB128(&DebugInfoOffset);
|
2011-09-13 19:42:23 +00:00
|
|
|
|
2013-10-17 13:28:16 +00:00
|
|
|
// Skip preceding attribute values.
|
|
|
|
for (uint32_t i = 0; i < AttrIdx; ++i) {
|
|
|
|
DWARFFormValue::skipValue(AbbrevDecl->getFormByIndex(i),
|
|
|
|
DebugInfoData, &DebugInfoOffset, U);
|
2011-09-13 19:42:23 +00:00
|
|
|
}
|
|
|
|
|
2013-10-17 13:28:16 +00:00
|
|
|
FormValue = DWARFFormValue(AbbrevDecl->getFormByIndex(AttrIdx));
|
|
|
|
return FormValue.extractValue(DebugInfoData, &DebugInfoOffset, U);
|
2011-09-13 19:42:23 +00:00
|
|
|
}
|
|
|
|
|
2013-08-27 09:20:22 +00:00
|
|
|
const char *DWARFDebugInfoEntryMinimal::getAttributeValueAsString(
|
2013-09-23 22:44:40 +00:00
|
|
|
const DWARFUnit *U, const uint16_t Attr, const char *FailValue) const {
|
2013-08-27 09:20:22 +00:00
|
|
|
DWARFFormValue FormValue;
|
2013-10-28 23:01:48 +00:00
|
|
|
if (!getAttributeValue(U, Attr, FormValue))
|
|
|
|
return FailValue;
|
|
|
|
Optional<const char *> Result = FormValue.getAsCString(U);
|
|
|
|
return Result.hasValue() ? Result.getValue() : FailValue;
|
2011-09-13 19:42:23 +00:00
|
|
|
}
|
|
|
|
|
2013-08-27 09:20:22 +00:00
|
|
|
uint64_t DWARFDebugInfoEntryMinimal::getAttributeValueAsAddress(
|
2013-09-23 22:44:40 +00:00
|
|
|
const DWARFUnit *U, const uint16_t Attr, uint64_t FailValue) const {
|
2013-08-27 09:20:22 +00:00
|
|
|
DWARFFormValue FormValue;
|
2013-10-28 23:01:48 +00:00
|
|
|
if (!getAttributeValue(U, Attr, FormValue))
|
|
|
|
return FailValue;
|
|
|
|
Optional<uint64_t> Result = FormValue.getAsAddress(U);
|
|
|
|
return Result.hasValue() ? Result.getValue() : FailValue;
|
2013-08-27 09:20:22 +00:00
|
|
|
}
|
|
|
|
|
2013-10-28 23:01:48 +00:00
|
|
|
uint64_t DWARFDebugInfoEntryMinimal::getAttributeValueAsUnsignedConstant(
|
2013-09-23 22:44:40 +00:00
|
|
|
const DWARFUnit *U, const uint16_t Attr, uint64_t FailValue) const {
|
2013-08-27 09:20:22 +00:00
|
|
|
DWARFFormValue FormValue;
|
2013-10-28 23:01:48 +00:00
|
|
|
if (!getAttributeValue(U, Attr, FormValue))
|
|
|
|
return FailValue;
|
|
|
|
Optional<uint64_t> Result = FormValue.getAsUnsignedConstant();
|
|
|
|
return Result.hasValue() ? Result.getValue() : FailValue;
|
2011-09-13 19:42:23 +00:00
|
|
|
}
|
|
|
|
|
2013-09-23 22:44:40 +00:00
|
|
|
uint64_t DWARFDebugInfoEntryMinimal::getAttributeValueAsReference(
|
2013-10-17 13:28:16 +00:00
|
|
|
const DWARFUnit *U, const uint16_t Attr, uint64_t FailValue) const {
|
|
|
|
DWARFFormValue FormValue;
|
2013-10-28 23:01:48 +00:00
|
|
|
if (!getAttributeValue(U, Attr, FormValue))
|
|
|
|
return FailValue;
|
|
|
|
Optional<uint64_t> Result = FormValue.getAsReference(U);
|
|
|
|
return Result.hasValue() ? Result.getValue() : FailValue;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint64_t DWARFDebugInfoEntryMinimal::getAttributeValueAsSectionOffset(
|
|
|
|
const DWARFUnit *U, const uint16_t Attr, uint64_t FailValue) const {
|
|
|
|
DWARFFormValue FormValue;
|
|
|
|
if (!getAttributeValue(U, Attr, FormValue))
|
|
|
|
return FailValue;
|
|
|
|
Optional<uint64_t> Result = FormValue.getAsSectionOffset();
|
|
|
|
return Result.hasValue() ? Result.getValue() : FailValue;
|
2011-09-13 19:42:23 +00:00
|
|
|
}
|
2011-09-14 20:52:27 +00:00
|
|
|
|
2014-06-13 22:31:03 +00:00
|
|
|
uint64_t
|
|
|
|
DWARFDebugInfoEntryMinimal::getRangesBaseAttribute(const DWARFUnit *U,
|
|
|
|
uint64_t FailValue) const {
|
|
|
|
uint64_t Result =
|
|
|
|
getAttributeValueAsSectionOffset(U, DW_AT_ranges_base, -1ULL);
|
|
|
|
if (Result != -1ULL)
|
|
|
|
return Result;
|
|
|
|
return getAttributeValueAsSectionOffset(U, DW_AT_GNU_ranges_base, FailValue);
|
|
|
|
}
|
|
|
|
|
2013-09-23 22:44:40 +00:00
|
|
|
bool DWARFDebugInfoEntryMinimal::getLowAndHighPC(const DWARFUnit *U,
|
2012-10-30 21:36:43 +00:00
|
|
|
uint64_t &LowPC,
|
|
|
|
uint64_t &HighPC) const {
|
2013-09-23 22:44:40 +00:00
|
|
|
LowPC = getAttributeValueAsAddress(U, DW_AT_low_pc, -1ULL);
|
2013-10-28 23:15:15 +00:00
|
|
|
if (LowPC == -1ULL)
|
|
|
|
return false;
|
|
|
|
HighPC = getAttributeValueAsAddress(U, DW_AT_high_pc, -1ULL);
|
|
|
|
if (HighPC == -1ULL) {
|
|
|
|
// Since DWARF4, DW_AT_high_pc may also be of class constant, in which case
|
|
|
|
// it represents function size.
|
|
|
|
HighPC = getAttributeValueAsUnsignedConstant(U, DW_AT_high_pc, -1ULL);
|
|
|
|
if (HighPC != -1ULL)
|
|
|
|
HighPC += LowPC;
|
|
|
|
}
|
2012-09-04 08:12:33 +00:00
|
|
|
return (HighPC != -1ULL);
|
|
|
|
}
|
|
|
|
|
2014-04-18 17:25:46 +00:00
|
|
|
DWARFAddressRangesVector
|
|
|
|
DWARFDebugInfoEntryMinimal::getAddressRanges(const DWARFUnit *U) const {
|
2012-09-04 08:12:33 +00:00
|
|
|
if (isNULL())
|
2014-04-18 19:01:53 +00:00
|
|
|
return DWARFAddressRangesVector();
|
2014-04-18 17:25:46 +00:00
|
|
|
// Single range specified by low/high PC.
|
2012-09-04 08:12:33 +00:00
|
|
|
uint64_t LowPC, HighPC;
|
2014-04-18 17:25:46 +00:00
|
|
|
if (getLowAndHighPC(U, LowPC, HighPC)) {
|
2014-04-18 19:01:53 +00:00
|
|
|
return DWARFAddressRangesVector(1, std::make_pair(LowPC, HighPC));
|
2014-04-18 17:25:46 +00:00
|
|
|
}
|
|
|
|
// Multiple ranges from .debug_ranges section.
|
2013-10-28 23:01:48 +00:00
|
|
|
uint32_t RangesOffset =
|
|
|
|
getAttributeValueAsSectionOffset(U, DW_AT_ranges, -1U);
|
2012-09-04 08:12:33 +00:00
|
|
|
if (RangesOffset != -1U) {
|
|
|
|
DWARFDebugRangeList RangeList;
|
2013-09-23 22:44:40 +00:00
|
|
|
if (U->extractRangeList(RangesOffset, RangeList))
|
2014-04-18 17:25:46 +00:00
|
|
|
return RangeList.getAbsoluteRanges(U->getBaseAddress());
|
|
|
|
}
|
2014-04-18 19:01:53 +00:00
|
|
|
return DWARFAddressRangesVector();
|
2014-04-18 17:25:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void DWARFDebugInfoEntryMinimal::collectChildrenAddressRanges(
|
|
|
|
const DWARFUnit *U, DWARFAddressRangesVector& Ranges) const {
|
|
|
|
if (isNULL())
|
|
|
|
return;
|
|
|
|
if (isSubprogramDIE()) {
|
|
|
|
const auto &DIERanges = getAddressRanges(U);
|
|
|
|
Ranges.insert(Ranges.end(), DIERanges.begin(), DIERanges.end());
|
|
|
|
}
|
|
|
|
|
|
|
|
const DWARFDebugInfoEntryMinimal *Child = getFirstChild();
|
|
|
|
while (Child) {
|
|
|
|
Child->collectChildrenAddressRanges(U, Ranges);
|
|
|
|
Child = Child->getSibling();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool DWARFDebugInfoEntryMinimal::addressRangeContainsAddress(
|
|
|
|
const DWARFUnit *U, const uint64_t Address) const {
|
|
|
|
for (const auto& R : getAddressRanges(U)) {
|
|
|
|
if (R.first <= Address && Address < R.second)
|
|
|
|
return true;
|
2012-07-02 05:54:45 +00:00
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2013-09-23 22:44:40 +00:00
|
|
|
const char *
|
2014-05-15 21:24:32 +00:00
|
|
|
DWARFDebugInfoEntryMinimal::getSubroutineName(const DWARFUnit *U,
|
|
|
|
FunctionNameKind Kind) const {
|
|
|
|
if (!isSubroutineDIE() || Kind == FunctionNameKind::None)
|
2014-04-15 06:32:26 +00:00
|
|
|
return nullptr;
|
2014-05-17 00:07:48 +00:00
|
|
|
// Try to get mangled name only if it was asked for.
|
|
|
|
if (Kind == FunctionNameKind::LinkageName) {
|
|
|
|
if (const char *name =
|
|
|
|
getAttributeValueAsString(U, DW_AT_MIPS_linkage_name, nullptr))
|
|
|
|
return name;
|
|
|
|
if (const char *name =
|
|
|
|
getAttributeValueAsString(U, DW_AT_linkage_name, nullptr))
|
|
|
|
return name;
|
|
|
|
}
|
2014-04-15 06:32:26 +00:00
|
|
|
if (const char *name = getAttributeValueAsString(U, DW_AT_name, nullptr))
|
2012-07-17 15:28:35 +00:00
|
|
|
return name;
|
|
|
|
// Try to get name from specification DIE.
|
|
|
|
uint32_t spec_ref =
|
2013-09-23 22:44:40 +00:00
|
|
|
getAttributeValueAsReference(U, DW_AT_specification, -1U);
|
2012-07-17 15:28:35 +00:00
|
|
|
if (spec_ref != -1U) {
|
|
|
|
DWARFDebugInfoEntryMinimal spec_die;
|
2013-10-28 23:58:58 +00:00
|
|
|
if (spec_die.extractFast(U, &spec_ref)) {
|
2014-05-15 21:24:32 +00:00
|
|
|
if (const char *name = spec_die.getSubroutineName(U, Kind))
|
2012-07-17 15:28:35 +00:00
|
|
|
return name;
|
2012-07-02 05:54:45 +00:00
|
|
|
}
|
|
|
|
}
|
2012-07-17 15:28:35 +00:00
|
|
|
// Try to get name from abstract origin DIE.
|
|
|
|
uint32_t abs_origin_ref =
|
2013-09-23 22:44:40 +00:00
|
|
|
getAttributeValueAsReference(U, DW_AT_abstract_origin, -1U);
|
2012-07-17 15:28:35 +00:00
|
|
|
if (abs_origin_ref != -1U) {
|
|
|
|
DWARFDebugInfoEntryMinimal abs_origin_die;
|
2013-10-28 23:58:58 +00:00
|
|
|
if (abs_origin_die.extractFast(U, &abs_origin_ref)) {
|
2014-05-15 21:24:32 +00:00
|
|
|
if (const char *name = abs_origin_die.getSubroutineName(U, Kind))
|
2012-07-17 15:28:35 +00:00
|
|
|
return name;
|
|
|
|
}
|
|
|
|
}
|
2014-04-15 06:32:26 +00:00
|
|
|
return nullptr;
|
2012-07-02 05:54:45 +00:00
|
|
|
}
|
2012-09-04 08:12:33 +00:00
|
|
|
|
2013-09-23 22:44:40 +00:00
|
|
|
void DWARFDebugInfoEntryMinimal::getCallerFrame(const DWARFUnit *U,
|
2012-10-30 21:36:43 +00:00
|
|
|
uint32_t &CallFile,
|
|
|
|
uint32_t &CallLine,
|
|
|
|
uint32_t &CallColumn) const {
|
2013-10-28 23:01:48 +00:00
|
|
|
CallFile = getAttributeValueAsUnsignedConstant(U, DW_AT_call_file, 0);
|
|
|
|
CallLine = getAttributeValueAsUnsignedConstant(U, DW_AT_call_line, 0);
|
|
|
|
CallColumn = getAttributeValueAsUnsignedConstant(U, DW_AT_call_column, 0);
|
2012-09-04 08:12:33 +00:00
|
|
|
}
|
|
|
|
|
2013-08-06 10:49:15 +00:00
|
|
|
DWARFDebugInfoEntryInlinedChain
|
2012-09-04 08:12:33 +00:00
|
|
|
DWARFDebugInfoEntryMinimal::getInlinedChainForAddress(
|
2013-09-23 22:44:40 +00:00
|
|
|
const DWARFUnit *U, const uint64_t Address) const {
|
2013-08-06 10:49:15 +00:00
|
|
|
DWARFDebugInfoEntryInlinedChain InlinedChain;
|
2013-09-23 22:44:40 +00:00
|
|
|
InlinedChain.U = U;
|
2012-09-04 08:12:33 +00:00
|
|
|
if (isNULL())
|
|
|
|
return InlinedChain;
|
|
|
|
for (const DWARFDebugInfoEntryMinimal *DIE = this; DIE; ) {
|
|
|
|
// Append current DIE to inlined chain only if it has correct tag
|
|
|
|
// (e.g. it is not a lexical block).
|
|
|
|
if (DIE->isSubroutineDIE()) {
|
2013-08-06 10:49:15 +00:00
|
|
|
InlinedChain.DIEs.push_back(*DIE);
|
2012-09-04 08:12:33 +00:00
|
|
|
}
|
|
|
|
// Try to get child which also contains provided address.
|
|
|
|
const DWARFDebugInfoEntryMinimal *Child = DIE->getFirstChild();
|
|
|
|
while (Child) {
|
2013-09-23 22:44:40 +00:00
|
|
|
if (Child->addressRangeContainsAddress(U, Address)) {
|
2012-09-04 08:12:33 +00:00
|
|
|
// Assume there is only one such child.
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
Child = Child->getSibling();
|
|
|
|
}
|
|
|
|
DIE = Child;
|
|
|
|
}
|
|
|
|
// Reverse the obtained chain to make the root of inlined chain last.
|
2013-08-06 10:49:15 +00:00
|
|
|
std::reverse(InlinedChain.DIEs.begin(), InlinedChain.DIEs.end());
|
2012-09-04 08:12:33 +00:00
|
|
|
return InlinedChain;
|
|
|
|
}
|