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;
|
|
|
|
|
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.
|
2011-09-13 19:42:23 +00:00
|
|
|
const uint32_t numAttributes = AbbrevDecl->getNumAttributes();
|
|
|
|
for (uint32_t i = 0; i != numAttributes; ++i) {
|
|
|
|
uint16_t attr = AbbrevDecl->getAttrByIndex(i);
|
|
|
|
uint16_t form = AbbrevDecl->getFormByIndex(i);
|
2013-09-23 22:44:40 +00:00
|
|
|
dumpAttribute(OS, u, &offset, attr, 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
|
|
|
const uint8_t *FixedFormSizes,
|
|
|
|
uint32_t *OffsetPtr) {
|
|
|
|
Offset = *OffsetPtr;
|
2013-09-23 22:44:40 +00:00
|
|
|
DataExtractor DebugInfoData = U->getDebugInfoExtractor();
|
2013-04-08 14:37:16 +00:00
|
|
|
uint64_t AbbrCode = DebugInfoData.getULEB128(OffsetPtr);
|
|
|
|
if (0 == AbbrCode) {
|
|
|
|
// NULL debug tag entry.
|
2011-09-13 19:42:23 +00:00
|
|
|
AbbrevDecl = NULL;
|
2013-04-08 14:37:16 +00:00
|
|
|
return true;
|
|
|
|
}
|
2013-09-23 22:44:40 +00:00
|
|
|
AbbrevDecl = U->getAbbreviations()->getAbbreviationDeclaration(AbbrCode);
|
2013-04-08 14:37:16 +00:00
|
|
|
assert(AbbrevDecl);
|
|
|
|
assert(FixedFormSizes); // For best performance this should be specified!
|
|
|
|
|
|
|
|
// Skip all data in the .debug_info for the attributes
|
|
|
|
for (uint32_t i = 0, n = AbbrevDecl->getNumAttributes(); i < n; ++i) {
|
|
|
|
uint16_t Form = AbbrevDecl->getFormByIndex(i);
|
|
|
|
|
|
|
|
// FIXME: Currently we're checking if this is less than the last
|
|
|
|
// entry in the fixed_form_sizes table, but this should be changed
|
|
|
|
// to use dynamic dispatch.
|
|
|
|
uint8_t FixedFormSize =
|
|
|
|
(Form < DW_FORM_ref_sig8) ? FixedFormSizes[Form] : 0;
|
|
|
|
if (FixedFormSize)
|
|
|
|
*OffsetPtr += FixedFormSize;
|
|
|
|
else if (!DWARFFormValue::skipValue(Form, DebugInfoData, OffsetPtr,
|
2013-09-23 22:44:40 +00:00
|
|
|
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
|
|
|
}
|
|
|
|
|
2013-09-23 22:44:40 +00:00
|
|
|
bool DWARFDebugInfoEntryMinimal::extract(const DWARFUnit *U,
|
|
|
|
uint32_t *OffsetPtr) {
|
|
|
|
DataExtractor DebugInfoData = U->getDebugInfoExtractor();
|
|
|
|
const uint32_t UEndOffset = U->getNextUnitOffset();
|
2013-04-08 14:37:16 +00:00
|
|
|
Offset = *OffsetPtr;
|
2013-09-23 22:44:40 +00:00
|
|
|
if ((Offset >= UEndOffset) || !DebugInfoData.isValidOffset(Offset))
|
2013-04-08 14:37:16 +00:00
|
|
|
return false;
|
|
|
|
uint64_t AbbrCode = DebugInfoData.getULEB128(OffsetPtr);
|
|
|
|
if (0 == AbbrCode) {
|
|
|
|
// NULL debug tag entry.
|
|
|
|
AbbrevDecl = NULL;
|
|
|
|
return true;
|
|
|
|
}
|
2013-09-23 22:44:40 +00:00
|
|
|
AbbrevDecl = U->getAbbreviations()->getAbbreviationDeclaration(AbbrCode);
|
2013-04-08 14:37:16 +00:00
|
|
|
if (0 == AbbrevDecl) {
|
|
|
|
// Restore the original offset.
|
|
|
|
*OffsetPtr = Offset;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
bool IsCompileUnitTag = (AbbrevDecl->getTag() == DW_TAG_compile_unit);
|
|
|
|
if (IsCompileUnitTag)
|
2013-09-23 22:44:40 +00:00
|
|
|
const_cast<DWARFUnit *>(U)->setBaseAddress(0);
|
2013-04-08 14:37:16 +00:00
|
|
|
|
|
|
|
// Skip all data in the .debug_info for the attributes
|
|
|
|
for (uint32_t i = 0, n = AbbrevDecl->getNumAttributes(); i < n; ++i) {
|
|
|
|
uint16_t Attr = AbbrevDecl->getAttrByIndex(i);
|
|
|
|
uint16_t Form = AbbrevDecl->getFormByIndex(i);
|
|
|
|
|
|
|
|
if (IsCompileUnitTag &&
|
|
|
|
((Attr == DW_AT_entry_pc) || (Attr == DW_AT_low_pc))) {
|
|
|
|
DWARFFormValue FormValue(Form);
|
2013-09-23 22:44:40 +00:00
|
|
|
if (FormValue.extractValue(DebugInfoData, OffsetPtr, U)) {
|
2013-10-28 23:01:48 +00:00
|
|
|
if (Attr == DW_AT_low_pc || Attr == DW_AT_entry_pc) {
|
|
|
|
Optional<uint64_t> BaseAddr = FormValue.getAsAddress(U);
|
|
|
|
if (BaseAddr.hasValue())
|
|
|
|
const_cast<DWARFUnit *>(U)->setBaseAddress(BaseAddr.getValue());
|
|
|
|
}
|
2011-09-13 19:42:23 +00:00
|
|
|
}
|
2013-09-23 22:44:40 +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
|
|
|
|
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 {
|
2012-09-04 08:12:33 +00:00
|
|
|
HighPC = -1ULL;
|
2013-09-23 22:44:40 +00:00
|
|
|
LowPC = getAttributeValueAsAddress(U, DW_AT_low_pc, -1ULL);
|
2013-10-17 13:28:16 +00:00
|
|
|
// FIXME: Check if HighPC is of class constant (it has different semantics).
|
2012-09-04 08:12:33 +00:00
|
|
|
if (LowPC != -1ULL)
|
2013-09-23 22:44:40 +00:00
|
|
|
HighPC = getAttributeValueAsAddress(U, DW_AT_high_pc, -1ULL);
|
2012-09-04 08:12:33 +00:00
|
|
|
return (HighPC != -1ULL);
|
|
|
|
}
|
|
|
|
|
2013-09-23 22:44:40 +00:00
|
|
|
void DWARFDebugInfoEntryMinimal::buildAddressRangeTable(
|
|
|
|
const DWARFUnit *U, DWARFDebugAranges *DebugAranges,
|
|
|
|
uint32_t UOffsetInAranges) const {
|
2011-09-14 20:52:27 +00:00
|
|
|
if (AbbrevDecl) {
|
2012-09-04 08:12:33 +00:00
|
|
|
if (isSubprogramDIE()) {
|
|
|
|
uint64_t LowPC, HighPC;
|
2013-09-23 22:44:40 +00:00
|
|
|
if (getLowAndHighPC(U, LowPC, HighPC))
|
|
|
|
DebugAranges->appendRange(UOffsetInAranges, LowPC, HighPC);
|
2012-09-04 08:12:33 +00:00
|
|
|
// FIXME: try to append ranges from .debug_ranges section.
|
2011-09-14 20:52:27 +00:00
|
|
|
}
|
|
|
|
|
2013-08-27 09:20:22 +00:00
|
|
|
const DWARFDebugInfoEntryMinimal *Child = getFirstChild();
|
|
|
|
while (Child) {
|
2013-09-23 22:44:40 +00:00
|
|
|
Child->buildAddressRangeTable(U, DebugAranges, UOffsetInAranges);
|
2013-08-27 09:20:22 +00:00
|
|
|
Child = Child->getSibling();
|
2011-09-14 20:52:27 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-07-02 05:54:45 +00:00
|
|
|
|
2013-09-23 22:44:40 +00:00
|
|
|
bool DWARFDebugInfoEntryMinimal::addressRangeContainsAddress(
|
|
|
|
const DWARFUnit *U, const uint64_t Address) const {
|
2012-09-04 08:12:33 +00:00
|
|
|
if (isNULL())
|
|
|
|
return false;
|
|
|
|
uint64_t LowPC, HighPC;
|
2013-09-23 22:44:40 +00:00
|
|
|
if (getLowAndHighPC(U, LowPC, HighPC))
|
2012-09-04 08:12:33 +00:00
|
|
|
return (LowPC <= Address && Address <= HighPC);
|
|
|
|
// Try to get address 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))
|
|
|
|
return RangeList.containsAddress(U->getBaseAddress(), Address);
|
2012-07-02 05:54:45 +00:00
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2013-09-23 22:44:40 +00:00
|
|
|
const char *
|
|
|
|
DWARFDebugInfoEntryMinimal::getSubroutineName(const DWARFUnit *U) const {
|
2012-09-04 08:12:33 +00:00
|
|
|
if (!isSubroutineDIE())
|
2012-07-02 05:54:45 +00:00
|
|
|
return 0;
|
2012-07-17 15:28:35 +00:00
|
|
|
// Try to get mangled name if possible.
|
|
|
|
if (const char *name =
|
2013-09-23 22:44:40 +00:00
|
|
|
getAttributeValueAsString(U, DW_AT_MIPS_linkage_name, 0))
|
2012-07-17 15:28:35 +00:00
|
|
|
return name;
|
2013-09-23 22:44:40 +00:00
|
|
|
if (const char *name = getAttributeValueAsString(U, DW_AT_linkage_name, 0))
|
2012-07-17 15:28:35 +00:00
|
|
|
return name;
|
2013-09-23 22:44:40 +00:00
|
|
|
if (const char *name = getAttributeValueAsString(U, DW_AT_name, 0))
|
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-09-23 22:44:40 +00:00
|
|
|
if (spec_die.extract(U, &spec_ref)) {
|
|
|
|
if (const char *name = spec_die.getSubroutineName(U))
|
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-09-23 22:44:40 +00:00
|
|
|
if (abs_origin_die.extract(U, &abs_origin_ref)) {
|
|
|
|
if (const char *name = abs_origin_die.getSubroutineName(U))
|
2012-07-17 15:28:35 +00:00
|
|
|
return name;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
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;
|
|
|
|
}
|