This is an archive of the discontinued LLVM Phabricator instance.

[DebugInfo][Support] Replace DWARFDataExtractor size function
ClosedPublic

Authored by jhenderson on Jan 7 2020, 8:19 AM.

Details

Summary

This patch adds a new size function to the base DataExtractor class, which removes the need for the DWARFDataExtractor size function.

It is unclear why DWARFDataExtractor's size function returned zero in some circumstances (i.e. when it is constructed without a section, and with a different data source instead), so that behaviour has changed. The old behaviour could cause an assertion in the debug line parser, as the size did not reflect the actual data available, and could be lower than the current offset being parsed.

Diff Detail

Event Timeline

jhenderson created this revision.Jan 7 2020, 8:19 AM
Herald added a project: Restricted Project. · View Herald TranscriptJan 7 2020, 8:19 AM

The old behaviour could cause an assertion in the debug line parser

Could you include a test case for this, demonstrating the assertion is no longer triggering?

jhenderson updated this revision to Diff 237000.Jan 9 2020, 2:54 AM
jhenderson edited the summary of this revision. (Show Details)

Added unit test case that would trigger the assertion mentioned in the description. I'm not entirely convinced that this test case is worthwhile, since with the change in how size() is calculated, it really is moot (e.g. I wouldn't have needed it if the size() function had always been the way I'm proposing).

Also, adding the unit test makes this patch now depend on D72154 (well, not strictly - I could implement without the dependency, but the two overlap in my branch).

Added unit test case that would trigger the assertion mentioned in the description. I'm not entirely convinced that this test case is worthwhile, since with the change in how size() is calculated, it really is moot (e.g. I wouldn't have needed it if the size() function had always been the way I'm proposing).

Ah, I was more expecting an end-to-end test (with llvm-dwarfdump or similar) when you said in the patch description "The old behaviour could cause an assertion in the debug line parser"

What were the circumstances where this assertion would fail? Was the failure reachable with llvm-dwarfdump, or only via a unit test/non-production API usage?

Also, adding the unit test makes this patch now depend on D72154 (well, not strictly - I could implement without the dependency, but the two overlap in my branch).

Added unit test case that would trigger the assertion mentioned in the description. I'm not entirely convinced that this test case is worthwhile, since with the change in how size() is calculated, it really is moot (e.g. I wouldn't have needed it if the size() function had always been the way I'm proposing).

Ah, I was more expecting an end-to-end test (with llvm-dwarfdump or similar) when you said in the patch description "The old behaviour could cause an assertion in the debug line parser"

What were the circumstances where this assertion would fail? Was the failure reachable with llvm-dwarfdump, or only via a unit test/non-production API usage?

Oh, sorry for misunderstanding. We have a local test for a local patch in LLD that makes some use of the debug information, but this patch doesn't create the data extractor with a section, which meant that it ran into this assertion. I checked, and I can't find any other usage of this function with a data extractor constructed without a section.

dblaikie accepted this revision.Jan 10 2020, 7:35 AM

Added unit test case that would trigger the assertion mentioned in the description. I'm not entirely convinced that this test case is worthwhile, since with the change in how size() is calculated, it really is moot (e.g. I wouldn't have needed it if the size() function had always been the way I'm proposing).

Ah, I was more expecting an end-to-end test (with llvm-dwarfdump or similar) when you said in the patch description "The old behaviour could cause an assertion in the debug line parser"

What were the circumstances where this assertion would fail? Was the failure reachable with llvm-dwarfdump, or only via a unit test/non-production API usage?

Oh, sorry for misunderstanding. We have a local test for a local patch in LLD that makes some use of the debug information, but this patch doesn't create the data extractor with a section, which meant that it ran into this assertion. I checked, and I can't find any other usage of this function with a data extractor constructed without a section.

Ah, thanks for the context! Yeah, go ahead and commit it without a test case - the new implementation is strictly simpler/more obvious & I don't think the unit test really adds value/is likely to catch any regressions here.

This revision is now accepted and ready to land.Jan 10 2020, 7:35 AM

Ah, thanks for the context! Yeah, go ahead and commit it without a test case - the new implementation is strictly simpler/more obvious & I don't think the unit test really adds value/is likely to catch any regressions here.

Thanks. I didn't see your comment when I was doing the rebase, but I'll make sure to remove the extra unit test before landing it on Monday.

This revision was automatically updated to reflect the committed changes.