This is an archive of the discontinued LLVM Phabricator instance.

[DWARF] Don't attempt to parse line tables at invalid offsets
ClosedPublic

Authored by jhenderson on Mar 7 2018, 4:06 AM.

Details

Summary

Whilst working on improvements to the error handling of the debug line parsing code, I noticed that if an invalid offset were to be specified in a call to getOrParseLineTable(), an entry in the LineTableMap would still be created, even if the offset was not within the section range. The immediate parsing attempt afterwards would fail (it would end up getting a version of 0), and thereafter, any subsequent calls to getOrParseLineTable or getLineTable would return the default-constructed, invalid line table. In reality, we shouldn't even attempt to parse this table, and we should always return a nullptr from these two functions for this situation.

I have tested this via a unit test, which required some new framework for unit testing debug line. My plan is to add quite a few more unit tests for the new error reporting mechanism that will follow shortly, hence the reason why the supporting code for the tests are written the way they are - I intend to extend the DwarfGenerator class to support generating debug line.

Diff Detail

Repository
rL LLVM

Event Timeline

jhenderson created this revision.Mar 7 2018, 4:06 AM
JDevlieghere accepted this revision.Mar 7 2018, 7:57 AM

Thanks! I was thinking a positive test would be nice but you already tackled that in the summary. LGTM!

This revision is now accepted and ready to land.Mar 7 2018, 7:57 AM
aprantl accepted this revision.Mar 7 2018, 8:18 AM
This revision was automatically updated to reflect the committed changes.