This is an archive of the discontinued LLVM Phabricator instance.

[lldb] Add an overload to SetModuleLoadAddress that takes an unsigned value
ClosedPublic

Authored by JDevlieghere on Apr 3 2023, 4:08 PM.

Details

Summary

Currently, SBTarget::SetModuleLoadAddress cannot accept the large slides needed to load images in high memory. This function should always have taken an unsigned as the slide as it immediately passes it to Target::SetSectionLoadAddress which takes an unsigned. This patch adds an overload and check that the slide is positive for the signed variant.

rdar://101355155

Diff Detail

Event Timeline

JDevlieghere created this revision.Apr 3 2023, 4:08 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 3 2023, 4:08 PM
JDevlieghere requested review of this revision.Apr 3 2023, 4:08 PM
jasonmolenda accepted this revision.Apr 6 2023, 8:14 AM

LGTM. We can detect this This is one of those cases where I'd like to mark SBTarget::SetModuleLoadAddress as deprecated. I like that you detect this situation in SBTarget::SetLoadAddress - we could cast to unsigned and do the right thing, or would the compiler get unhappy? - but when I've seen these kinds of mistakes in the past, python detects a too-large unsigned value being passed to a signed argument and throws an error before we even get to the SetModuleLoadAddress, so it doesn't help much I expect for Python SB API users.

This revision is now accepted and ready to land.Apr 6 2023, 8:14 AM

LGTM. We can detect this This is one of those cases where I'd like to mark SBTarget::SetModuleLoadAddress as deprecated. I like that you detect this situation in SBTarget::SetLoadAddress - we could cast to unsigned and do the right thing, or would the compiler get unhappy? - but when I've seen these kinds of mistakes in the past, python detects a too-large unsigned value being passed to a signed argument and throws an error before we even get to the SetModuleLoadAddress, so it doesn't help much I expect for Python SB API users.

Yeah, what you described is exactly what would happen before this patch, the function will "just work" from C++ but not from Python. I added the check to discourage C++ users from relying on the old function, but it does change the SB API's behavior.

Writing this made me realize we can solve this more elegantly. We can have both overloads and deprecate the one that takes an int64_t, mark it as deprecated and not expose it to SWIG.

Herald added a project: Restricted Project. · View Herald TranscriptApr 6 2023, 10:44 AM