This is an archive of the discontinued LLVM Phabricator instance.

[lldb] Add FixAnyAddress to ABI plugins
ClosedPublic

Authored by DavidSpickett on Apr 19 2022, 6:33 AM.

Details

Summary

FixAnyAddress is to be used when we don't know or don't care
whether we're fixing a code or data address.

By using FixAnyAddress over the others, you document that no
specific choice was made.

On all existing platforms apart from Arm Thumb, you could use
either FixCodeAddress or FixDataAddress and be fine. Up until
now I've chosen to use FixDataAddress but if I had
chosen to use FixCodeAddress that would have broken Arm Thumb.

Hence FixAnyAddress, to give you the "safest" option when you're
in generic code.

Uses of FixDataAddress in memory region code have been changed
to FixAnyAddress. The functionality is unchanged.

Diff Detail

Event Timeline

DavidSpickett created this revision.Apr 19 2022, 6:33 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 19 2022, 6:33 AM
DavidSpickett requested review of this revision.Apr 19 2022, 6:33 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 19 2022, 6:33 AM
DavidSpickett added a subscriber: JDevlieghere.

This comes from https://reviews.llvm.org/D118794 on the subject of whether it's ok to just pick one of fixcode/fixdata and assume it'll work.

Of all the uses of Fix, my own memory region changes are the only ones so far that fit FixAnyAddress. The rest look appropriate. I plan to use it in https://reviews.llvm.org/D118794 instead of FixDataAddress.

@JDevlieghere You did some work around this area in https://reviews.llvm.org/D100521 so can you tell me if this makes sense to add in general? There were some comments there:

This looks good. Jonas, what do you think about having FixDataAddress() methods in the ABI's. We're going to be quickly sprinkling FixCodeAddress calls throughout lldb at places where Linux/Darwin ABI need them, and it'd be nice if we have the FixDataAddress method available (even if they're identical right now) so someone doesn't need to audit all the calls in the future and adjust them as appropriate.

FixAnyAddress aims to do the same thing but for when we don't know what we have.

omjavaid accepted this revision.Apr 25 2022, 5:25 AM

Looks good to me.

This revision is now accepted and ready to land.Apr 25 2022, 5:25 AM
JDevlieghere accepted this revision.Apr 27 2022, 5:13 PM

Yes, this makes a lot of sense to me. Thanks for taking care of this. LGTM.

This revision was automatically updated to reflect the committed changes.