[all-commits] [llvm/llvm-project] f94344: [Debuginfo][NFC] Unify error reporting routines in...

avl-llvm via All-commits all-commits at lists.llvm.org
Thu Feb 27 07:38:26 PST 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: f943443e65115c83648f1185adedb3d333f8619f
      https://github.com/llvm/llvm-project/commit/f943443e65115c83648f1185adedb3d333f8619f
  Author: Alexey Lapshin <a.v.lapshin at mail.ru>
  Date:   2020-02-27 (Thu, 27 Feb 2020)

  Changed paths:
    M llvm/include/llvm/DebugInfo/DWARF/DWARFContext.h
    M llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
    M llvm/lib/DebugInfo/Symbolize/Symbolize.cpp
    M llvm/unittests/DebugInfo/DWARF/DWARFDebugInfoTest.cpp

  Log Message:
  -----------
  [Debuginfo][NFC] Unify error reporting routines inside DebugInfoDWARF.

Summary:
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 = WithColor::defaultErrorHandler;
std::function<void(Error E)> WarningHandler = WithColor::defaultWarningHandler;

This is last patch from series of patches: D74481, D74635, D75118.

Reviewers: jhenderson, dblaikie, probinson, aprantl, JDevlieghere

Reviewed By: jhenderson

Subscribers: grimar, hiraditya, llvm-commits

Tags: #llvm, #debug-info

Differential Revision: https://reviews.llvm.org/D74308




More information about the All-commits mailing list