Add more error checking to llvm-objdump and MachODump

Rafael EspĂ­ndola via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 14 14:37:47 PST 2015


On 14 December 2015 at 17:28, Pete Cooper <peter_cooper at apple.com> wrote:
> Hi Rafael
>
> This is the start of error handling when we encounter errors in __eh_frame parsing.
>
> I add a bool return to printMachOEHFrameSection which returns true if we printed an error.  This is then propagated all the way up the call stack to main().
>
> I think returning a bool makes more sense that report_fatal_error as upon getting an error, we want to continue to dump other sections, and even other eh_frame entries.  I do check this error and ensure we return 1 from main though.

Please just use fatal errors.

This is program code, not library code. Having an error function that
prints the message and exits with 1 makes the code far simpler to
read. In particular it is easy to see that we always exit instead of
reading potential garbage when forgetting to check the return.

It is extremely uncommon to see broken .o files. Every single time I
have seen one is because I broke something in MC. In which case a
fatal error is also very helpful. It provides a convenient place to
put a breakpoint and see the entire context (stack) that found the
problem. With a fancy error handling you have to step down to see what
decided to return an error.

Cheers,
Rafael


More information about the llvm-commits mailing list