summaryrefslogtreecommitdiffstats
path: root/llvm/lib/DebugInfo
diff options
context:
space:
mode:
authorGeorge Rimar <grimar@accesssoftek.com>2017-06-28 08:21:19 +0000
committerGeorge Rimar <grimar@accesssoftek.com>2017-06-28 08:21:19 +0000
commit1af3cb2912bad7454db673721e22e3ef64850e6c (patch)
treeff62340e0a5ff6caa90197fe8ebb7b960098d2ce /llvm/lib/DebugInfo
parent99e376956d6fd12641f8515fb019e9220a2e477f (diff)
downloadbcm5719-llvm-1af3cb2912bad7454db673721e22e3ef64850e6c.tar.gz
bcm5719-llvm-1af3cb2912bad7454db673721e22e3ef64850e6c.zip
Recommit "[ELF] - Add ability for DWARFContextInMemory to exit early when any error happen."
With fix in include folder character case: #include "llvm/Codegen/AsmPrinter.h" -> #include "llvm/CodeGen/AsmPrinter.h" Original commit message: Change introduces error reporting policy for DWARFContextInMemory. New callback provided by client is able to handle error on it's side and return Halt or Continue. That allows to either keep current behavior when parser prints all errors but continues parsing object or implement something very different, like stop parsing on a first error and report an error in a client style. Differential revision: https://reviews.llvm.org/D34328 llvm-svn: 306517
Diffstat (limited to 'llvm/lib/DebugInfo')
-rw-r--r--llvm/lib/DebugInfo/DWARF/DWARFContext.cpp30
1 files changed, 21 insertions, 9 deletions
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp b/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
index 38147946175..fdd191e0cbf 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
@@ -870,13 +870,13 @@ static Expected<SymInfo> getSymbolInfo(const object::ObjectFile &Obj,
Expected<uint64_t> SymAddrOrErr = Sym->getAddress();
if (!SymAddrOrErr)
- return createError("error: failed to compute symbol address: ",
+ return createError("failed to compute symbol address: ",
SymAddrOrErr.takeError());
// Also remember what section this symbol is in for later
auto SectOrErr = Sym->getSection();
if (!SectOrErr)
- return createError("error: failed to get symbol section: ",
+ return createError("failed to get symbol section: ",
SectOrErr.takeError());
RSec = *SectOrErr;
@@ -937,8 +937,14 @@ Error DWARFContextInMemory::maybeDecompress(const SectionRef &Sec,
return Error::success();
}
-DWARFContextInMemory::DWARFContextInMemory(const object::ObjectFile &Obj,
- const LoadedObjectInfo *L)
+ErrorPolicy DWARFContextInMemory::defaultErrorHandler(Error E) {
+ errs() << "error: " + toString(std::move(E)) << '\n';
+ return ErrorPolicy::Continue;
+}
+
+DWARFContextInMemory::DWARFContextInMemory(
+ const object::ObjectFile &Obj, const LoadedObjectInfo *L,
+ function_ref<ErrorPolicy(Error)> HandleError)
: FileName(Obj.getFileName()), IsLittleEndian(Obj.isLittleEndian()),
AddressSize(Obj.getBytesInAddress()) {
for (const SectionRef &Section : Obj.sections()) {
@@ -961,9 +967,10 @@ DWARFContextInMemory::DWARFContextInMemory(const object::ObjectFile &Obj,
Section.getContents(data);
if (auto Err = maybeDecompress(Section, name, data)) {
- errs() << "error: failed to decompress '" + name + "', " +
- toString(std::move(Err))
- << '\n';
+ ErrorPolicy EP = HandleError(
+ createError("failed to decompress '" + name + "', ", std::move(Err)));
+ if (EP == ErrorPolicy::Halt)
+ return;
continue;
}
@@ -1055,7 +1062,8 @@ DWARFContextInMemory::DWARFContextInMemory(const object::ObjectFile &Obj,
Expected<SymInfo> SymInfoOrErr = getSymbolInfo(Obj, Reloc, L, AddrCache);
if (!SymInfoOrErr) {
- errs() << toString(SymInfoOrErr.takeError()) << '\n';
+ if (HandleError(SymInfoOrErr.takeError()) == ErrorPolicy::Halt)
+ return;
continue;
}
@@ -1064,7 +1072,11 @@ DWARFContextInMemory::DWARFContextInMemory(const object::ObjectFile &Obj,
if (V.error()) {
SmallString<32> Name;
Reloc.getTypeName(Name);
- errs() << "error: failed to compute relocation: " << Name << "\n";
+ ErrorPolicy EP = HandleError(
+ createError("failed to compute relocation: " + name + ", ",
+ errorCodeToError(object_error::parse_failed)));
+ if (EP == ErrorPolicy::Halt)
+ return;
continue;
}
RelocAddrEntry Rel = {SymInfoOrErr->SectionIndex, Val};
OpenPOWER on IntegriCloud