llvm-project/llvm/lib/DebugInfo/DWARF
Kevin Enderby 3fcdf6ae2a Thread Expected<...> up from createMachOObjectFile() to allow llvm-objdump to produce a real error message
Produce the first specific error message for a malformed Mach-O file describing
the problem instead of the generic message for object_error::parse_failed of
"Invalid data was encountered while parsing the file”.  Many more good error
messages will follow after this first one.

This is built on Lang Hames’ great work of adding the ’Error' class for
structured error handling and threading Error through MachOObjectFile
construction.  And making createMachOObjectFile return Expected<...> .

So to to get the error to the llvm-obdump tool, I changed the stack of
these methods to also return Expected<...> :

  object::ObjectFile::createObjectFile()
  object::SymbolicFile::createSymbolicFile()
  object::createBinary()

Then finally in ParseInputMachO() in MachODump.cpp the error can
be reported and the specific error message can be printed in llvm-objdump
and can be seen in the existing test case for the existing malformed binary
but with the updated error message.

Converting these interfaces to Expected<> from ErrorOr<> does involve
touching a number of places. To contain the changes for now use of
errorToErrorCode() and errorOrToExpected() are used where the callers
are yet to be converted.

Also there some were bugs in the existing code that did not deal with the
old ErrorOr<> return values.  So now with Expected<> since they must be
checked and the error handled, I added a TODO and a comment:
“// TODO: Actually report errors helpfully” and a call something like
consumeError(ObjOrErr.takeError()) so the buggy code will not crash
since needed to deal with the Error.

Note there is one fix also needed to lld/COFF/InputFiles.cpp that goes along
with this that I will commit right after this.  So expect lld not to built
after this commit and before the next one.

llvm-svn: 265606
2016-04-06 22:14:09 +00:00
..
CMakeLists.txt dwarfdump: Added macro support to llvm-dwarfdump tool. 2015-11-12 09:38:54 +00:00
DWARFAbbreviationDeclaration.cpp
DWARFAcceleratorTable.cpp Revert r240137 (Fixed/added namespace ending comments using clang-tidy. NFC) 2015-06-23 09:49:53 +00:00
DWARFCompileUnit.cpp [DWARF parser] Make DWARF parser more robust against missing compile/type units. 2015-05-19 21:54:32 +00:00
DWARFContext.cpp Re-submit r256008 "Improve DWARFDebugFrame::parse to also handle __eh_frame." 2016-01-26 15:09:42 +00:00
DWARFDebugAbbrev.cpp
DWARFDebugArangeSet.cpp
DWARFDebugAranges.cpp
DWARFDebugFrame.cpp [DebugInfo] Dump CIE augmentation data as a list of hex bytes 2016-03-01 18:38:05 +00:00
DWARFDebugInfoEntry.cpp Fix indentation 2015-11-17 00:41:02 +00:00
DWARFDebugLine.cpp [DWARF] Fix a bug in line info handling 2015-05-31 23:37:04 +00:00
DWARFDebugLoc.cpp Replace std::copy with a back inserter with vector append where feasible 2015-02-28 10:11:12 +00:00
DWARFDebugMacro.cpp Fix several accidental DOS line endings in source files 2016-01-03 17:22:03 +00:00
DWARFDebugRangeList.cpp
DWARFFormValue.cpp [llvm-dwp] Retrieve the DWOID from the CU for the cu_index entry 2015-12-04 17:20:04 +00:00
DWARFTypeUnit.cpp [DWARF parser] Make DWARF parser more robust against missing compile/type units. 2015-05-19 21:54:32 +00:00
DWARFUnit.cpp Thread Expected<...> up from createMachOObjectFile() to allow llvm-objdump to produce a real error message 2016-04-06 22:14:09 +00:00
DWARFUnitIndex.cpp dwarfdump: Correctly indentify the indicies for DWP records 2015-12-03 18:41:59 +00:00
LLVMBuild.txt
SyntaxHighlighting.cpp dwarfdump: Added macro support to llvm-dwarfdump tool. 2015-11-12 09:38:54 +00:00
SyntaxHighlighting.h dwarfdump: Added macro support to llvm-dwarfdump tool. 2015-11-12 09:38:54 +00:00
module.modulemap