summaryrefslogtreecommitdiffstats
path: root/llvm/lib/DebugInfo
diff options
context:
space:
mode:
authorVictor Leschuk <vleschuk@accesssoftek.com>2018-08-23 12:43:33 +0000
committerVictor Leschuk <vleschuk@accesssoftek.com>2018-08-23 12:43:33 +0000
commitcf1f714d3b1bcb623dbeed33dc8c469f3af0bdf2 (patch)
tree6ba226eb4e909e5728b5d833551bf898613e421b /llvm/lib/DebugInfo
parent516fcdac6dfcda1c374ef392bb3949c6bfc73734 (diff)
downloadbcm5719-llvm-cf1f714d3b1bcb623dbeed33dc8c469f3af0bdf2.tar.gz
bcm5719-llvm-cf1f714d3b1bcb623dbeed33dc8c469f3af0bdf2.zip
[DWARF] Unify warning callbacks. NFC.
Both DWARFDebugLine and DWARFDebugAddr used the same callback mechanism for handling recoverable errors. They both implemented similar warn() function to be used as such callbacks. In this revision we get rid of code duplication and move this warn() function to DWARFContext as DWARFContext::dumpWarning(). Reviewers: lhames, jhenderson, aprantl, probinson, dblaikie, JDevlieghere Reviewed By: jhenderson Differential Revision: https://reviews.llvm.org/D51033 llvm-svn: 340528
Diffstat (limited to 'llvm/lib/DebugInfo')
-rw-r--r--llvm/lib/DebugInfo/DWARF/DWARFContext.cpp28
-rw-r--r--llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp6
2 files changed, 14 insertions, 20 deletions
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp b/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
index 43b67a2ecf5..a5c31a56fad 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
@@ -248,19 +248,12 @@ static void dumpStringOffsetsSection(raw_ostream &OS, StringRef SectionName,
static void dumpAddrSection(raw_ostream &OS, DWARFDataExtractor &AddrData,
DIDumpOptions DumpOpts, uint16_t Version,
uint8_t AddrSize) {
- // TODO: Make this more general: add callback types to Error.h, create
- // implementation and make all DWARF classes use them.
- static auto WarnCallback = [](Error Warn) {
- handleAllErrors(std::move(Warn), [](ErrorInfoBase &Info) {
- WithColor::warning() << Info.message() << '\n';
- });
- };
uint32_t Offset = 0;
while (AddrData.isValidOffset(Offset)) {
DWARFDebugAddrTable AddrTable;
uint32_t TableOffset = Offset;
- if (Error Err = AddrTable.extract(AddrData, &Offset, Version,
- AddrSize, WarnCallback)) {
+ if (Error Err = AddrTable.extract(AddrData, &Offset, Version, AddrSize,
+ DWARFContext::dumpWarning)) {
WithColor::error() << toString(std::move(Err)) << '\n';
// Keep going after an error, if we can, assuming that the length field
// could be read. If it couldn't, stop reading the section.
@@ -404,14 +397,15 @@ void DWARFContext::dump(
DIDumpOptions DumpOpts) {
while (!Parser.done()) {
if (DumpOffset && Parser.getOffset() != *DumpOffset) {
- Parser.skip();
+ Parser.skip(dumpWarning);
continue;
}
OS << "debug_line[" << format("0x%8.8x", Parser.getOffset()) << "]\n";
if (DumpOpts.Verbose) {
- Parser.parseNext(DWARFDebugLine::warn, DWARFDebugLine::warn, &OS);
+ Parser.parseNext(dumpWarning, dumpWarning, &OS);
} else {
- DWARFDebugLine::LineTable LineTable = Parser.parseNext();
+ DWARFDebugLine::LineTable LineTable =
+ Parser.parseNext(dumpWarning, dumpWarning);
LineTable.dump(OS, DumpOpts);
}
}
@@ -799,9 +793,9 @@ const AppleAcceleratorTable &DWARFContext::getAppleObjC() {
const DWARFDebugLine::LineTable *
DWARFContext::getLineTableForUnit(DWARFUnit *U) {
Expected<const DWARFDebugLine::LineTable *> ExpectedLineTable =
- getLineTableForUnit(U, DWARFDebugLine::warn);
+ getLineTableForUnit(U, dumpWarning);
if (!ExpectedLineTable) {
- DWARFDebugLine::warn(ExpectedLineTable.takeError());
+ dumpWarning(ExpectedLineTable.takeError());
return nullptr;
}
return *ExpectedLineTable;
@@ -1617,3 +1611,9 @@ uint8_t DWARFContext::getCUAddrSize() {
}
return Addr;
}
+
+void DWARFContext::dumpWarning(Error Warning) {
+ handleAllErrors(std::move(Warning), [](ErrorInfoBase &Info) {
+ WithColor::warning() << Info.message() << '\n';
+ });
+}
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp b/llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp
index 3d16e740f9f..7b41490090a 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp
@@ -1112,9 +1112,3 @@ void DWARFDebugLine::SectionParser::moveToNextTable(uint32_t OldOffset,
Done = true;
}
}
-
-void DWARFDebugLine::warn(Error Err) {
- handleAllErrors(std::move(Err), [](ErrorInfoBase &Info) {
- WithColor::warning() << Info.message() << '\n';
- });
-}
OpenPOWER on IntegriCloud