aboutsummaryrefslogtreecommitdiff
path: root/lib/DebugInfo/DWARF/DWARFDie.cpp
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2019-10-23 17:51:42 +0000
committerDimitry Andric <dim@FreeBSD.org>2019-10-23 17:51:42 +0000
commit1d5ae1026e831016fc29fd927877c86af904481f (patch)
tree2cdfd12620fcfa5d9e4a0389f85368e8e36f63f9 /lib/DebugInfo/DWARF/DWARFDie.cpp
parente6d1592492a3a379186bfb02bd0f4eda0669c0d5 (diff)
Notes
Diffstat (limited to 'lib/DebugInfo/DWARF/DWARFDie.cpp')
-rw-r--r--lib/DebugInfo/DWARF/DWARFDie.cpp54
1 files changed, 27 insertions, 27 deletions
diff --git a/lib/DebugInfo/DWARF/DWARFDie.cpp b/lib/DebugInfo/DWARF/DWARFDie.cpp
index d638dc4239f4..cec194e8b6b3 100644
--- a/lib/DebugInfo/DWARF/DWARFDie.cpp
+++ b/lib/DebugInfo/DWARF/DWARFDie.cpp
@@ -21,6 +21,7 @@
#include "llvm/Object/ObjectFile.h"
#include "llvm/Support/DataExtractor.h"
#include "llvm/Support/Format.h"
+#include "llvm/Support/FormatAdapters.h"
#include "llvm/Support/FormatVariadic.h"
#include "llvm/Support/MathExtras.h"
#include "llvm/Support/WithColor.h"
@@ -91,21 +92,29 @@ static void dumpLocation(raw_ostream &OS, DWARFFormValue &FormValue,
}
FormValue.dump(OS, DumpOpts);
+ const auto &DumpLL = [&](auto ExpectedLL) {
+ if (ExpectedLL) {
+ uint64_t BaseAddr = 0;
+ if (Optional<object::SectionedAddress> BA = U->getBaseAddress())
+ BaseAddr = BA->Address;
+ auto LLDumpOpts = DumpOpts;
+ LLDumpOpts.Verbose = false;
+ ExpectedLL->dump(OS, BaseAddr, Ctx.isLittleEndian(), Obj.getAddressSize(),
+ MRI, U, LLDumpOpts, Indent);
+ } else {
+ OS << '\n';
+ OS.indent(Indent);
+ OS << formatv("error extracting location list: {0}",
+ fmt_consume(ExpectedLL.takeError()));
+ }
+ };
if (FormValue.isFormClass(DWARFFormValue::FC_SectionOffset)) {
- uint32_t Offset = *FormValue.getAsSectionOffset();
+ uint64_t Offset = *FormValue.getAsSectionOffset();
if (!U->isDWOUnit() && !U->getLocSection()->Data.empty()) {
DWARFDebugLoc DebugLoc;
DWARFDataExtractor Data(Obj, *U->getLocSection(), Ctx.isLittleEndian(),
Obj.getAddressSize());
- auto LL = DebugLoc.parseOneLocationList(Data, &Offset);
- if (LL) {
- uint64_t BaseAddr = 0;
- if (Optional<object::SectionedAddress> BA = U->getBaseAddress())
- BaseAddr = BA->Address;
- LL->dump(OS, Ctx.isLittleEndian(), Obj.getAddressSize(), MRI, U,
- BaseAddr, Indent);
- } else
- OS << "error extracting location list.";
+ DumpLL(DebugLoc.parseOneLocationList(Data, &Offset));
return;
}
@@ -121,18 +130,8 @@ static void dumpLocation(raw_ostream &OS, DWARFFormValue &FormValue,
// Modern locations list (.debug_loclists) are used starting from v5.
// Ideally we should take the version from the .debug_loclists section
// header, but using CU's version for simplicity.
- auto LL = DWARFDebugLoclists::parseOneLocationList(
- Data, &Offset, UseLocLists ? U->getVersion() : 4);
-
- uint64_t BaseAddr = 0;
- if (Optional<object::SectionedAddress> BA = U->getBaseAddress())
- BaseAddr = BA->Address;
-
- if (LL)
- LL->dump(OS, BaseAddr, Ctx.isLittleEndian(), Obj.getAddressSize(), MRI,
- U, Indent);
- else
- OS << "error extracting location list.";
+ DumpLL(DWARFDebugLoclists::parseOneLocationList(
+ Data, &Offset, UseLocLists ? U->getVersion() : 4));
}
}
}
@@ -264,7 +263,7 @@ static void dumpTypeName(raw_ostream &OS, const DWARFDie &D) {
}
static void dumpAttribute(raw_ostream &OS, const DWARFDie &Die,
- uint32_t *OffsetPtr, dwarf::Attribute Attr,
+ uint64_t *OffsetPtr, dwarf::Attribute Attr,
dwarf::Form Form, unsigned Indent,
DIDumpOptions DumpOpts) {
if (!Die.isValid())
@@ -568,8 +567,8 @@ void DWARFDie::dump(raw_ostream &OS, unsigned Indent,
if (!isValid())
return;
DWARFDataExtractor debug_info_data = U->getDebugInfoExtractor();
- const uint32_t Offset = getOffset();
- uint32_t offset = Offset;
+ const uint64_t Offset = getOffset();
+ uint64_t offset = Offset;
if (DumpOpts.ShowParents) {
DIDumpOptions ParentDumpOpts = DumpOpts;
ParentDumpOpts.ShowParents = false;
@@ -581,7 +580,7 @@ void DWARFDie::dump(raw_ostream &OS, unsigned Indent,
uint32_t abbrCode = debug_info_data.getULEB128(&offset);
if (DumpOpts.ShowAddresses)
WithColor(OS, HighlightColor::Address).get()
- << format("\n0x%8.8x: ", Offset);
+ << format("\n0x%8.8" PRIx64 ": ", Offset);
if (abbrCode) {
auto AbbrevDecl = getAbbreviationDeclarationPtr();
@@ -685,7 +684,7 @@ void DWARFDie::attribute_iterator::updateForIndex(
AttrValue.Attr = AbbrDecl.getAttrByIndex(Index);
// Add the previous byte size of any previous attribute value.
AttrValue.Offset += AttrValue.ByteSize;
- uint32_t ParseOffset = AttrValue.Offset;
+ uint64_t ParseOffset = AttrValue.Offset;
auto U = Die.getDwarfUnit();
assert(U && "Die must have valid DWARF unit");
AttrValue.Value = DWARFFormValue::createFromUnit(
@@ -733,6 +732,7 @@ bool DWARFAttribute::mayHaveLocationDescription(dwarf::Attribute Attr) {
case DW_AT_call_data_value:
// Extensions.
case DW_AT_GNU_call_site_value:
+ case DW_AT_GNU_call_site_target:
return true;
default:
return false;