This is an archive of the discontinued LLVM Phabricator instance.

[lldb] Add IsSafeToCallAPI to DynamicLoader
ClosedPublic

Authored by JDevlieghere on Mar 24 2021, 7:37 PM.

Details

Summary

On Darwin based systems, lldb will get notified by dyld before it itself finished initializing, at which point it's not safe to call certain APIs or SPIs. Add a method to the DynamicLoader to query that.

Diff Detail

Event Timeline

JDevlieghere requested review of this revision.Mar 24 2021, 7:37 PM
JDevlieghere created this revision.
aprantl accepted this revision.Mar 25 2021, 3:23 PM
aprantl added inline comments.
lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp
1118

Out of curiosity: Is this an error when ReadAllImageInfosStructure() returns false? In that case a better API might be one that also bubbles up the error.

This revision is now accepted and ready to land.Mar 25 2021, 3:23 PM
JDevlieghere added inline comments.Mar 25 2021, 3:30 PM
lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp
1118

It can fail if m_dyld_all_image_infos_addr is not known or if we fail to read memory. I guess the latter could be considered an error and something we might want to surface, but probably not from this API. If we don't know the answer to whether it's safe to do so is still no.

aprantl added inline comments.Mar 25 2021, 3:39 PM
lldb/include/lldb/Target/DynamicLoader.h
260

*Perhaps* IsFullyInitialized() ?

This revision was landed with ongoing or failed builds.Mar 25 2021, 3:44 PM
This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptMar 25 2021, 3:44 PM