1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-23 11:13:28 +01:00
llvm-mirror/lib/DebugInfo/DWARF
James Henderson 47d98c2dc3 [DWARF] Rework debug line parsing to use llvm::Error and callbacks
Reviewed by: dblaikie, JDevlieghere, espindola

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

Summary:
The .debug_line parser previously reported errors by printing to stderr and
return false. This is not particularly helpful for clients of the library code,
as it prevents them from handling the errors in a manner based on the calling
context. This change switches to using llvm::Error and callbacks to indicate
what problems were detected during parsing, and has updated clients to handle
the errors in a location-specific manner. In general, this means that they
continue to do the same thing to external users. Below, I have outlined what
the known behaviour changes are, relating to this change.

There are two levels of "errors" in the new error mechanism, to broadly
distinguish between different fail states of the parser, since not every
failure will prevent parsing of the unit, or of subsequent unit. Malformed
table errors that prevent reading the remainder of the table (reported by
returning them) and other minor issues representing problems with parsing that
do not prevent attempting to continue reading the table (reported by calling a
specified callback funciton). The only example of this currently is when the
last sequence of a unit is unterminated. However, I think it would be good to
change the handling of unrecognised opcodes to report as minor issues as well,
rather than just printing to the stream if --verbose is used (this would be a
subsequent change however).

I have substantially extended the DwarfGenerator to be able to handle
custom-crafted .debug_line sections, allowing for comprehensive unit-testing
of the parser code. For now, I am just adding unit tests to cover the basic
error reporting, and positive cases, and do not currently intend to test every
part of the parser, although the framework should be sufficient to do so at a
later point.

Known behaviour changes:
  - The dump function in DWARFContext now does not attempt to read subsequent
  tables when searching for a specific offset, if the unit length field of a
  table before the specified offset is a reserved value.
  - getOrParseLineTable now returns a useful Error if an invalid offset is
  encountered, rather than simply a nullptr.
  - The parse functions no longer use `WithColor::warning` directly to report
  errors, allowing LLD to call its own warning function.
  - The existing parse error messages have been updated to not specifically
  include "warning" in their message, allowing consumers to determine what
  severity the problem is.
  - If the line table version field appears to have a value less than 2, an
  informative error is returned, instead of just false.
  - If the line table unit length field uses a reserved value, an informative
  error is returned, instead of just false.
  - Dumping of .debug_line.dwo sections is now implemented the same as regular
  .debug_line sections.
  - Verbose dumping of .debug_line[.dwo] sections now prints the prologue, if
  there is a prologue error, just like non-verbose dumping.

As a helper for the generator code, I have re-added emitInt64 to the
AsmPrinter code. This previously existed, but was removed way back in r100296,
presumably because it was dead at the time.

This change also requires a change to LLD, which will be committed separately.

llvm-svn: 331971
2018-05-10 10:51:33 +00:00
..
CMakeLists.txt
DWARFAbbreviationDeclaration.cpp [dwarf] Unify unknown dwarf enum formatting code 2018-03-21 11:46:37 +00:00
DWARFAcceleratorTable.cpp Revert "DWARFVerifier: Check "completeness" of .debug_names section" 2018-05-09 12:26:19 +00:00
DWARFAddressRange.cpp
DWARFCompileUnit.cpp
DWARFContext.cpp [DWARF] Rework debug line parsing to use llvm::Error and callbacks 2018-05-10 10:51:33 +00:00
DWARFDataExtractor.cpp
DWARFDebugAbbrev.cpp
DWARFDebugAranges.cpp [DebugInfo] Change std::sort to llvm::sort in response to r327219 2018-04-01 16:18:49 +00:00
DWARFDebugArangeSet.cpp
DWARFDebugFrame.cpp [DebugInfo] Accept S in augmentation strings in CIE. 2018-05-08 06:21:12 +00:00
DWARFDebugInfoEntry.cpp
DWARFDebugLine.cpp [DWARF] Rework debug line parsing to use llvm::Error and callbacks 2018-05-10 10:51:33 +00:00
DWARFDebugLoc.cpp [DebugInfo] Use WithColor to print errors/warnings 2018-04-14 22:07:23 +00:00
DWARFDebugMacro.cpp
DWARFDebugPubTable.cpp
DWARFDebugRangeList.cpp
DWARFDebugRnglists.cpp [DWARF v5][NFC]: Refactor DebugRnglists to prepare for the support of the DW_AT_ranges 2018-04-05 21:01:49 +00:00
DWARFDie.cpp [DebugInfo] Prevent infinite recursion for malformed DWARF 2018-04-30 17:02:41 +00:00
DWARFExpression.cpp
DWARFFormValue.cpp
DWARFGdbIndex.cpp
DWARFTypeUnit.cpp Handle abbr_offset with relocations. 2018-03-21 21:31:25 +00:00
DWARFUnit.cpp llvm-symbolizer: Handle function definitions nested within other functions 2018-05-01 18:08:45 +00:00
DWARFUnitIndex.cpp
DWARFVerifier.cpp Revert "DWARFVerifier: Check "completeness" of .debug_names section" 2018-05-09 12:26:19 +00:00
LLVMBuild.txt