summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorDavid Blaikie <dblaikie@gmail.com>2018-12-22 00:31:02 +0000
committerDavid Blaikie <dblaikie@gmail.com>2018-12-22 00:31:02 +0000
commit219c6bd388725e5b302a90b6dae75d4100285356 (patch)
treee1e75fc7a0a30edf3f29f6b6c8e0f0a30228988f /llvm/lib
parentc3bedd056467ef110eb30461fdf1286660504989 (diff)
downloadbcm5719-llvm-219c6bd388725e5b302a90b6dae75d4100285356.tar.gz
bcm5719-llvm-219c6bd388725e5b302a90b6dae75d4100285356.zip
libDebugInfo: Refactor error handling in range list parsing
Propagate the llvm::Error a little further up. This is NFC for llvm-dwarfdump in this change, but allows ld.lld to emit more precise error messages about which object and archive the erroneous DWARF is in. llvm-svn: 349978
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/DebugInfo/DWARF/DWARFDebugAranges.cpp11
-rw-r--r--llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp19
2 files changed, 15 insertions, 15 deletions
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFDebugAranges.cpp b/llvm/lib/DebugInfo/DWARF/DWARFDebugAranges.cpp
index c26db9ab96e..e8c5dec821b 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFDebugAranges.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFDebugAranges.cpp
@@ -12,6 +12,7 @@
#include "llvm/DebugInfo/DWARF/DWARFContext.h"
#include "llvm/DebugInfo/DWARF/DWARFDebugArangeSet.h"
#include "llvm/Support/DataExtractor.h"
+#include "llvm/Support/WithColor.h"
#include <algorithm>
#include <cassert>
#include <cstdint>
@@ -53,10 +54,12 @@ void DWARFDebugAranges::generate(DWARFContext *CTX) {
for (const auto &CU : CTX->compile_units()) {
uint32_t CUOffset = CU->getOffset();
if (ParsedCUOffsets.insert(CUOffset).second) {
- DWARFAddressRangesVector CURanges;
- CU->collectAddressRanges(CURanges);
- for (const auto &R : CURanges)
- appendRange(CUOffset, R.LowPC, R.HighPC);
+ Expected<DWARFAddressRangesVector> CURanges = CU->collectAddressRanges();
+ if (!CURanges)
+ WithColor::error() << toString(CURanges.takeError()) << '\n';
+ else
+ for (const auto &R : *CURanges)
+ appendRange(CUOffset, R.LowPC, R.HighPC);
}
}
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp b/llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp
index 569512cb8f0..80234665bde 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp
@@ -566,21 +566,18 @@ DWARFUnit::findRnglistFromIndex(uint32_t Index) {
"missing or invalid range list table");
}
-void DWARFUnit::collectAddressRanges(DWARFAddressRangesVector &CURanges) {
+Expected<DWARFAddressRangesVector> DWARFUnit::collectAddressRanges() {
DWARFDie UnitDie = getUnitDIE();
if (!UnitDie)
- return;
+ return createStringError(errc::invalid_argument, "No unit DIE");
+
// First, check if unit DIE describes address ranges for the whole unit.
auto CUDIERangesOrError = UnitDie.getAddressRanges();
- if (CUDIERangesOrError) {
- if (!CUDIERangesOrError.get().empty()) {
- CURanges.insert(CURanges.end(), CUDIERangesOrError.get().begin(),
- CUDIERangesOrError.get().end());
- return;
- }
- } else
- WithColor::error() << "decoding address ranges: "
- << toString(CUDIERangesOrError.takeError()) << '\n';
+ if (!CUDIERangesOrError)
+ return createStringError(errc::invalid_argument,
+ "decoding address ranges: %s",
+ toString(CUDIERangesOrError.takeError()).c_str());
+ return *CUDIERangesOrError;
}
void DWARFUnit::updateAddressDieMap(DWARFDie Die) {
OpenPOWER on IntegriCloud