Skip to content

Commit 2d6495d

Browse files
authored
Merge pull request #2755 from JDevlieghere/objective-c-runtime
Cherrypick Objective-C Runtime Changes
2 parents 58a2cac + 72cef5f commit 2d6495d

File tree

5 files changed

+418
-161
lines changed

5 files changed

+418
-161
lines changed

lldb/include/lldb/Target/DynamicLoader.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,14 @@ class DynamicLoader : public PluginInterface {
251251
return false;
252252
}
253253

254+
/// Return whether the dynamic loader is fully initialized and it's safe to
255+
/// call its APIs.
256+
///
257+
/// On some systems (e.g. Darwin based systems), lldb will get notified by
258+
/// the dynamic loader before it itself finished initializing and it's not
259+
/// safe to call certain APIs or SPIs.
260+
virtual bool IsFullyInitialized() { return true; }
261+
254262
protected:
255263
// Utility methods for derived classes
256264

@@ -294,7 +302,7 @@ class DynamicLoader : public PluginInterface {
294302
// Read a pointer from memory at the given addr. Return LLDB_INVALID_ADDRESS
295303
// if the read fails.
296304
lldb::addr_t ReadPointer(lldb::addr_t addr);
297-
305+
298306
// Calls into the Process protected method LoadOperatingSystemPlugin:
299307
void LoadOperatingSystemPlugin(bool flush);
300308

lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1119,6 +1119,12 @@ bool DynamicLoaderMacOSXDYLD::GetSharedCacheInformation(
11191119
return false;
11201120
}
11211121

1122+
bool DynamicLoaderMacOSXDYLD::IsFullyInitialized() {
1123+
if (ReadAllImageInfosStructure())
1124+
return m_dyld_all_image_infos.libSystemInitialized;
1125+
return false;
1126+
}
1127+
11221128
void DynamicLoaderMacOSXDYLD::Initialize() {
11231129
PluginManager::RegisterPlugin(GetPluginNameStatic(),
11241130
GetPluginDescriptionStatic(), CreateInstance);

lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ class DynamicLoaderMacOSXDYLD : public lldb_private::DynamicLoaderDarwin {
6868

6969
uint32_t GetPluginVersion() override;
7070

71+
bool IsFullyInitialized() override;
72+
7173
protected:
7274
void PutToLog(lldb_private::Log *log) const;
7375

0 commit comments

Comments
 (0)