This is an archive of the discontinued LLVM Phabricator instance.

[DWARFYAML][debug_ranges] Make the "Offset" field optional.
ClosedPublic

Authored by Higuoxing on Jun 4 2020, 9:03 PM.

Details

Summary

Before this patch, we have to calculate the offset for the current range list entry. This patch helps make the "Offset" field optional.

Diff Detail

Event Timeline

Higuoxing created this revision.Jun 4 2020, 9:03 PM
Higuoxing updated this revision to Diff 268662.Jun 4 2020, 9:33 PM

Add assert(*DebugRanges.Offset >= CurrOffset).

Harbormaster completed remote builds in B59193: Diff 268666.

You should also have a test case either in this test or D81217 that shows what happens when you use an offset that is either higher than where you are already, or lower.

llvm/lib/ObjectYAML/DWARFEmitter.cpp
145–147

I don't think this wants to be an assert - it should be an error, right? If you specify a lower offset than the current position (e.g. 0 for the second set), you want an error since you can't place it there.

Higuoxing marked an inline comment as done.Jun 5 2020, 1:22 AM
Higuoxing added inline comments.
llvm/lib/ObjectYAML/DWARFEmitter.cpp
145–147

Yes, I think it should be an error as well. Currently, DWARFYAML doesn't support error handling. If we change one void EmitXXXSection() to Error EmitXXXSection(), we should change them all. Can I do it in a follow-up patch?

jhenderson added inline comments.Jun 5 2020, 2:39 AM
llvm/lib/ObjectYAML/DWARFEmitter.cpp
145–147

Oh, I missed that there's an assertion in this area already. Yes, leaving it to a follow-up is fine, but please add a FIXME note in this patch.

Higuoxing planned changes to this revision.Jun 7 2020, 1:41 AM

I will wait until DWARFYAML supports error handling.

Higuoxing updated this revision to Diff 269531.Jun 9 2020, 6:52 AM
Higuoxing marked an inline comment as done.

Add one test case when we try to assign an offset that is greater than the number of bytes written already.

jhenderson added inline comments.Jun 9 2020, 7:37 AM
llvm/lib/ObjectYAML/DWARFEmitter.cpp
144–146

Can ZeroFillBytes cope with a size of zero? If so, this can be simplified to simply:

if (DebugRanges.Offset)
  ZeroFillBytes(OS, *DebugRanges.Offset - CurrOffset);
Higuoxing updated this revision to Diff 269726.Jun 9 2020, 8:39 PM
Higuoxing marked an inline comment as done.
  • Address comment.
  • Add one more testcase when we try to assign an offset that is equal to the number of bytes written.
jhenderson accepted this revision.Jun 10 2020, 2:34 AM

LGTM, thanks!

This revision is now accepted and ready to land.Jun 10 2020, 2:34 AM
This revision was automatically updated to reflect the committed changes.