This is an archive of the discontinued LLVM Phabricator instance.

[lldb] Make LLDB resilient against failing dyld introspection APIs
ClosedPublic

Authored by JDevlieghere on Aug 3 2022, 1:19 PM.

Details

Summary

Make LLDB resilient against failing dyld introspection APIs: dyld_process_create_for_current_task, dyld_process_snapshot_create_for_process and dyld_process_snapshot_get_shared_cache can all fail and return a nullptr. Instead of having an assert, which doesn't really make sense as we have no control over whether these calls succeed or not, bail out gracefully and use the fallback logic.

rdar://98070414

Diff Detail

Event Timeline

JDevlieghere created this revision.Aug 3 2022, 1:19 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 3 2022, 1:19 PM
JDevlieghere requested review of this revision.Aug 3 2022, 1:19 PM

Nice.

lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
533

should this be auto *?

534
auto *dyld_process = dyld_process_create_for_current_task());
if (!dyld_process)
  return;

?

562

is this redundant?

JDevlieghere marked 3 inline comments as done.Aug 3 2022, 2:06 PM
JDevlieghere added inline comments.
lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
534

We don't want to return, we want to fall through to the logic below the #endif. I guess I could pull it out into a helper function?

562

No, if this succeeds we're done here.

JDevlieghere marked 2 inline comments as done.

Reduce indentation with early returns in a helper function

aprantl accepted this revision.Aug 3 2022, 3:32 PM

Thanks! Evidently I had trouble following the control flow in the earlier revision ;-)

This revision is now accepted and ready to land.Aug 3 2022, 3:32 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 3 2022, 3:48 PM