This aids debugging when working with possibly broken files,
instead of just flat out erroring out without telling what's wrong.
Not sure if it's relevant with tests for this?
Paths
| Differential D120679
[Object] [COFF] Improve error messages ClosedPublic Authored by mstorsjo on Feb 28 2022, 1:36 PM.
Details
Summary This aids debugging when working with possibly broken files, Not sure if it's relevant with tests for this?
Diff Detail
Event TimelineComment Actions lgtm If there are existing tests, it would be nice to check for additional context, but I don't think it makes sense to add coverage for every corner case here. This revision is now accepted and ready to land.Feb 28 2022, 3:29 PM Comment Actions Thanks for the improvement. Whilst I get what @rnk's saying about testing, I've learnt from past experience that if an error message is not tested, there's a non-trivial chance that the message is garbled in some way, e.g. due to incorrect format strings, or using wrong parameters. I'd personally prefer seeing a test for each case that has the additional new context (including, where possible, using the actual values passed in, rather than regexes), at least if there's already testing for the error path.
Comment Actions
While I agree that it would be ideal to have tests for every single case, that’s way out of scope for what I meant to spend effort on here. If that’s required, I’ll just drop this patch - that’s not what I set out to do. I’m not changing any error handling part, I’m just adding unique strings to all textless cases of object_error::parse_failed in the file, so that if such a message gets printed, it can be mapped back to the code unambiguously. And we happen to have one test that triggers one of the changed messages, so we actually do get the formatting tested. Some of the errors might even be impossible to trigger, if it’s just an internal consistency check that is guarded by an outer condition too. I’m not planning on investigating if it’s possible to trigger them all, and how to (many of them might require handcrafting broken binaries), I’m just adding messages.
Comment Actions
Just to be clear, I'm not suggesting adding new tests where they don't exist, only enhancing existing testing to be a little stricter (if there is such testing). If such testing doesn't exist, then what you've done is fine.
Comment Actions Added an 0x prefix to the RVAs, removed the else statement after a return, checking explicitly for the literal RVA and file name in the test. This revision was landed with ongoing or failed builds.Mar 2 2022, 12:45 AM Closed by commit rG6ec18aafec49: [Object] [COFF] Improve error messages (authored by mstorsjo). · Explain Why This revision was automatically updated to reflect the committed changes.
Revision Contents
Diff 412007 llvm/include/llvm/Object/COFF.h
llvm/lib/Object/COFFObjectFile.cpp
llvm/test/tools/llvm-readobj/COFF/tls-directory.test
|
Here and below, do you want the "0x" prefix?