1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-23 19:23:23 +01:00

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
This commit is contained in:
David Blaikie 2018-12-22 00:31:02 +00:00
parent 67d921b9f5
commit 0239fd2efd
3 changed files with 16 additions and 16 deletions

View File

@ -410,7 +410,7 @@ public:
return None;
}
void collectAddressRanges(DWARFAddressRangesVector &CURanges);
Expected<DWARFAddressRangesVector> collectAddressRanges();
/// Returns subprogram DIE with address range encompassing the provided
/// address. The pointer is alive as long as parsed compile unit DIEs are not

View File

@ -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);
}
}

View File

@ -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) {