[PATCH] D74308: [Debuginfo][NFC] Unify error reporting routines inside DebugInfoDWARF.

Alexey Lapshin via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 10 03:50:41 PST 2020


avl created this revision.
avl added reviewers: jhenderson, dblaikie, probinson, aprantl.
Herald added subscribers: llvm-commits, hiraditya.
Herald added a reviewer: JDevlieghere.
Herald added a project: LLVM.
avl added a project: debug-info.

Error reporting in DebugInfoDWARF library currently done in three ways :

1. Direct calls to WithColor::error()/WithColor::warning()
2. ErrorPolicy defaultErrorHandler(Error E);
3. void dumpWarning(Error Warning);

additionally, other locations could have more variations:

lld/ELF/SyntheticSection.cpp

  if (Error e = cu->tryExtractDIEsIfNeeded(false)) {
    error(toString(sec) + ": " + toString(std::move(e)));

DebugInfo/DWARF/DWARFUnit.cpp

  if (Error e = tryExtractDIEsIfNeeded(CUDieOnly))
    WithColor::error() << toString(std::move(e));

Thus error reporting could look inconsistent. To have a consistent error
messages it is necessary to have a possibility to redefine error
reporting functions. This patch creates two handlers and allows to
redefine them. It also patches all places inside DebugInfoDWARF 
to use these handlers.

The intention is always to use following handlers for error reporting
purposes inside DebugInfoDWARF:

DebugInfo/DWARF/DWARFContext.h

std::function<void(Error E)> RecoverableErrorHandler = [](Error E) {

  defaultErrorHandler(std::move(E));

};
std::function<void(Error E)> WarningHandler = defaultWarningHandler;


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D74308

Files:
  llvm/include/llvm/DebugInfo/DWARF/DWARFContext.h
  llvm/include/llvm/DebugInfo/DWARF/DWARFDebugAranges.h
  llvm/include/llvm/DebugInfo/DWARF/DWARFDebugLine.h
  llvm/include/llvm/DebugInfo/DWARF/DWARFDie.h
  llvm/lib/DWARFLinker/DWARFLinker.cpp
  llvm/lib/DebugInfo/DWARF/DWARFCompileUnit.cpp
  llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
  llvm/lib/DebugInfo/DWARF/DWARFDebugAranges.cpp
  llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp
  llvm/lib/DebugInfo/DWARF/DWARFDebugLoc.cpp
  llvm/lib/DebugInfo/DWARF/DWARFDie.cpp
  llvm/lib/DebugInfo/DWARF/DWARFTypeUnit.cpp
  llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp
  llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp
  llvm/tools/dsymutil/DwarfLinkerForBinary.cpp
  llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D74308.243503.patch
Type: text/x-patch
Size: 47319 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200210/bcf89cec/attachment.bin>


More information about the llvm-commits mailing list