1 //===-- DynamicLoaderMacOS.cpp --------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #include "lldb/Breakpoint/StoppointCallbackContext.h"
10 #include "lldb/Core/Debugger.h"
11 #include "lldb/Core/Module.h"
12 #include "lldb/Core/PluginManager.h"
13 #include "lldb/Core/Section.h"
14 #include "lldb/Symbol/ObjectFile.h"
15 #include "lldb/Symbol/SymbolVendor.h"
16 #include "lldb/Target/ABI.h"
17 #include "lldb/Target/SectionLoadList.h"
18 #include "lldb/Target/StackFrame.h"
19 #include "lldb/Target/Target.h"
20 #include "lldb/Target/Thread.h"
21 #include "lldb/Utility/LLDBLog.h"
22 #include "lldb/Utility/Log.h"
23 #include "lldb/Utility/State.h"
24 
25 #include "DynamicLoaderDarwin.h"
26 #include "DynamicLoaderMacOS.h"
27 
28 #include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
29 
30 using namespace lldb;
31 using namespace lldb_private;
32 
33 // Create an instance of this class. This function is filled into the plugin
34 // info class that gets handed out by the plugin factory and allows the lldb to
35 // instantiate an instance of this class.
CreateInstance(Process * process,bool force)36 DynamicLoader *DynamicLoaderMacOS::CreateInstance(Process *process,
37                                                   bool force) {
38   bool create = force;
39   if (!create) {
40     create = true;
41     Module *exe_module = process->GetTarget().GetExecutableModulePointer();
42     if (exe_module) {
43       ObjectFile *object_file = exe_module->GetObjectFile();
44       if (object_file) {
45         create = (object_file->GetStrata() == ObjectFile::eStrataUser);
46       }
47     }
48 
49     if (create) {
50       const llvm::Triple &triple_ref =
51           process->GetTarget().GetArchitecture().GetTriple();
52       switch (triple_ref.getOS()) {
53       case llvm::Triple::Darwin:
54       case llvm::Triple::MacOSX:
55       case llvm::Triple::IOS:
56       case llvm::Triple::TvOS:
57       case llvm::Triple::WatchOS:
58       // NEED_BRIDGEOS_TRIPLE case llvm::Triple::BridgeOS:
59         create = triple_ref.getVendor() == llvm::Triple::Apple;
60         break;
61       default:
62         create = false;
63         break;
64       }
65     }
66   }
67 
68   if (!UseDYLDSPI(process)) {
69     create = false;
70   }
71 
72   if (create)
73     return new DynamicLoaderMacOS(process);
74   return nullptr;
75 }
76 
77 // Constructor
DynamicLoaderMacOS(Process * process)78 DynamicLoaderMacOS::DynamicLoaderMacOS(Process *process)
79     : DynamicLoaderDarwin(process), m_image_infos_stop_id(UINT32_MAX),
80       m_break_id(LLDB_INVALID_BREAK_ID),
81       m_dyld_handover_break_id(LLDB_INVALID_BREAK_ID), m_mutex(),
82       m_maybe_image_infos_address(LLDB_INVALID_ADDRESS) {}
83 
84 // Destructor
~DynamicLoaderMacOS()85 DynamicLoaderMacOS::~DynamicLoaderMacOS() {
86   if (LLDB_BREAK_ID_IS_VALID(m_break_id))
87     m_process->GetTarget().RemoveBreakpointByID(m_break_id);
88   if (LLDB_BREAK_ID_IS_VALID(m_dyld_handover_break_id))
89     m_process->GetTarget().RemoveBreakpointByID(m_dyld_handover_break_id);
90 }
91 
ProcessDidExec()92 bool DynamicLoaderMacOS::ProcessDidExec() {
93   std::lock_guard<std::recursive_mutex> baseclass_guard(GetMutex());
94   bool did_exec = false;
95   if (m_process) {
96     // If we are stopped after an exec, we will have only one thread...
97     if (m_process->GetThreadList().GetSize() == 1) {
98       // Maybe we still have an image infos address around?  If so see
99       // if that has changed, and if so we have exec'ed.
100       if (m_maybe_image_infos_address != LLDB_INVALID_ADDRESS) {
101         lldb::addr_t image_infos_address = m_process->GetImageInfoAddress();
102         if (image_infos_address != m_maybe_image_infos_address) {
103           // We don't really have to reset this here, since we are going to
104           // call DoInitialImageFetch right away to handle the exec.  But in
105           // case anybody looks at it in the meantime, it can't hurt.
106           m_maybe_image_infos_address = image_infos_address;
107           did_exec = true;
108         }
109       }
110 
111       if (!did_exec) {
112         // See if we are stopped at '_dyld_start'
113         ThreadSP thread_sp(m_process->GetThreadList().GetThreadAtIndex(0));
114         if (thread_sp) {
115           lldb::StackFrameSP frame_sp(thread_sp->GetStackFrameAtIndex(0));
116           if (frame_sp) {
117             const Symbol *symbol =
118                 frame_sp->GetSymbolContext(eSymbolContextSymbol).symbol;
119             if (symbol) {
120               if (symbol->GetName() == "_dyld_start")
121                 did_exec = true;
122             }
123           }
124         }
125       }
126     }
127   }
128 
129   if (did_exec) {
130     m_libpthread_module_wp.reset();
131     m_pthread_getspecific_addr.Clear();
132   }
133   return did_exec;
134 }
135 
136 // Clear out the state of this class.
DoClear()137 void DynamicLoaderMacOS::DoClear() {
138   std::lock_guard<std::recursive_mutex> guard(m_mutex);
139 
140   if (LLDB_BREAK_ID_IS_VALID(m_break_id))
141     m_process->GetTarget().RemoveBreakpointByID(m_break_id);
142   if (LLDB_BREAK_ID_IS_VALID(m_dyld_handover_break_id))
143     m_process->GetTarget().RemoveBreakpointByID(m_dyld_handover_break_id);
144 
145   m_break_id = LLDB_INVALID_BREAK_ID;
146   m_dyld_handover_break_id = LLDB_INVALID_BREAK_ID;
147 }
148 
149 // Check if we have found DYLD yet
DidSetNotificationBreakpoint()150 bool DynamicLoaderMacOS::DidSetNotificationBreakpoint() {
151   return LLDB_BREAK_ID_IS_VALID(m_break_id);
152 }
153 
ClearNotificationBreakpoint()154 void DynamicLoaderMacOS::ClearNotificationBreakpoint() {
155   if (LLDB_BREAK_ID_IS_VALID(m_break_id)) {
156     m_process->GetTarget().RemoveBreakpointByID(m_break_id);
157     m_break_id = LLDB_INVALID_BREAK_ID;
158   }
159 }
160 
161 // Try and figure out where dyld is by first asking the Process if it knows
162 // (which currently calls down in the lldb::Process to get the DYLD info
163 // (available on SnowLeopard only). If that fails, then check in the default
164 // addresses.
DoInitialImageFetch()165 void DynamicLoaderMacOS::DoInitialImageFetch() {
166   Log *log = GetLog(LLDBLog::DynamicLoader);
167 
168   // Remove any binaries we pre-loaded in the Target before
169   // launching/attaching. If the same binaries are present in the process,
170   // we'll get them from the shared module cache, we won't need to re-load them
171   // from disk.
172   UnloadAllImages();
173 
174   StructuredData::ObjectSP all_image_info_json_sp(
175       m_process->GetLoadedDynamicLibrariesInfos());
176   ImageInfo::collection image_infos;
177   if (all_image_info_json_sp.get() &&
178       all_image_info_json_sp->GetAsDictionary() &&
179       all_image_info_json_sp->GetAsDictionary()->HasKey("images") &&
180       all_image_info_json_sp->GetAsDictionary()
181           ->GetValueForKey("images")
182           ->GetAsArray()) {
183     if (JSONImageInformationIntoImageInfo(all_image_info_json_sp,
184                                           image_infos)) {
185       LLDB_LOGF(log, "Initial module fetch:  Adding %" PRId64 " modules.\n",
186                 (uint64_t)image_infos.size());
187 
188       UpdateSpecialBinariesFromNewImageInfos(image_infos);
189       AddModulesUsingImageInfos(image_infos);
190     }
191   }
192 
193   m_dyld_image_infos_stop_id = m_process->GetStopID();
194   m_maybe_image_infos_address = m_process->GetImageInfoAddress();
195 }
196 
NeedToDoInitialImageFetch()197 bool DynamicLoaderMacOS::NeedToDoInitialImageFetch() { return true; }
198 
199 // Static callback function that gets called when our DYLD notification
200 // breakpoint gets hit. We update all of our image infos and then let our super
201 // class DynamicLoader class decide if we should stop or not (based on global
202 // preference).
NotifyBreakpointHit(void * baton,StoppointCallbackContext * context,lldb::user_id_t break_id,lldb::user_id_t break_loc_id)203 bool DynamicLoaderMacOS::NotifyBreakpointHit(void *baton,
204                                              StoppointCallbackContext *context,
205                                              lldb::user_id_t break_id,
206                                              lldb::user_id_t break_loc_id) {
207   // Let the event know that the images have changed
208   // DYLD passes three arguments to the notification breakpoint.
209   // Arg1: enum dyld_notify_mode mode - 0 = adding, 1 = removing, 2 = remove
210   // all Arg2: unsigned long icount        - Number of shared libraries
211   // added/removed Arg3: uint64_t mach_headers[]     - Array of load addresses
212   // of binaries added/removed
213 
214   DynamicLoaderMacOS *dyld_instance = (DynamicLoaderMacOS *)baton;
215 
216   ExecutionContext exe_ctx(context->exe_ctx_ref);
217   Process *process = exe_ctx.GetProcessPtr();
218 
219   // This is a sanity check just in case this dyld_instance is an old dyld
220   // plugin's breakpoint still lying around.
221   if (process != dyld_instance->m_process)
222     return false;
223 
224   if (dyld_instance->m_image_infos_stop_id != UINT32_MAX &&
225       process->GetStopID() < dyld_instance->m_image_infos_stop_id) {
226     return false;
227   }
228 
229   const lldb::ABISP &abi = process->GetABI();
230   if (abi) {
231     // Build up the value array to store the three arguments given above, then
232     // get the values from the ABI:
233 
234     TypeSystemClang *clang_ast_context =
235         ScratchTypeSystemClang::GetForTarget(process->GetTarget());
236     if (!clang_ast_context)
237       return false;
238 
239     ValueList argument_values;
240 
241     Value mode_value;    // enum dyld_notify_mode { dyld_notify_adding=0,
242                          // dyld_notify_removing=1, dyld_notify_remove_all=2 };
243     Value count_value;   // unsigned long count
244     Value headers_value; // uint64_t machHeaders[] (aka void*)
245 
246     CompilerType clang_void_ptr_type =
247         clang_ast_context->GetBasicType(eBasicTypeVoid).GetPointerType();
248     CompilerType clang_uint32_type =
249         clang_ast_context->GetBuiltinTypeForEncodingAndBitSize(
250             lldb::eEncodingUint, 32);
251     CompilerType clang_uint64_type =
252         clang_ast_context->GetBuiltinTypeForEncodingAndBitSize(
253             lldb::eEncodingUint, 32);
254 
255     mode_value.SetValueType(Value::ValueType::Scalar);
256     mode_value.SetCompilerType(clang_uint32_type);
257 
258     if (process->GetTarget().GetArchitecture().GetAddressByteSize() == 4) {
259       count_value.SetValueType(Value::ValueType::Scalar);
260       count_value.SetCompilerType(clang_uint32_type);
261     } else {
262       count_value.SetValueType(Value::ValueType::Scalar);
263       count_value.SetCompilerType(clang_uint64_type);
264     }
265 
266     headers_value.SetValueType(Value::ValueType::Scalar);
267     headers_value.SetCompilerType(clang_void_ptr_type);
268 
269     argument_values.PushValue(mode_value);
270     argument_values.PushValue(count_value);
271     argument_values.PushValue(headers_value);
272 
273     if (abi->GetArgumentValues(exe_ctx.GetThreadRef(), argument_values)) {
274       uint32_t dyld_mode =
275           argument_values.GetValueAtIndex(0)->GetScalar().UInt(-1);
276       if (dyld_mode != static_cast<uint32_t>(-1)) {
277         // Okay the mode was right, now get the number of elements, and the
278         // array of new elements...
279         uint32_t image_infos_count =
280             argument_values.GetValueAtIndex(1)->GetScalar().UInt(-1);
281         if (image_infos_count != static_cast<uint32_t>(-1)) {
282           addr_t header_array =
283               argument_values.GetValueAtIndex(2)->GetScalar().ULongLong(-1);
284           if (header_array != static_cast<uint64_t>(-1)) {
285             std::vector<addr_t> image_load_addresses;
286             for (uint64_t i = 0; i < image_infos_count; i++) {
287               Status error;
288               addr_t addr = process->ReadUnsignedIntegerFromMemory(
289                   header_array + (8 * i), 8, LLDB_INVALID_ADDRESS, error);
290               if (addr != LLDB_INVALID_ADDRESS) {
291                 image_load_addresses.push_back(addr);
292               }
293             }
294             if (dyld_mode == 0) {
295               // dyld_notify_adding
296               if (process->GetTarget().GetImages().GetSize() == 0) {
297                 // When all images have been removed, we're doing the
298                 // dyld handover from a launch-dyld to a shared-cache-dyld,
299                 // and we've just hit our one-shot address breakpoint in
300                 // the sc-dyld.  Note that the image addresses passed to
301                 // this function are inferior sizeof(void*) not uint64_t's
302                 // like our normal notification, so don't even look at
303                 // image_load_addresses.
304 
305                 dyld_instance->ClearDYLDHandoverBreakpoint();
306 
307                 dyld_instance->DoInitialImageFetch();
308                 dyld_instance->SetNotificationBreakpoint();
309               } else {
310                 dyld_instance->AddBinaries(image_load_addresses);
311               }
312             } else if (dyld_mode == 1) {
313               // dyld_notify_removing
314               dyld_instance->UnloadImages(image_load_addresses);
315             } else if (dyld_mode == 2) {
316               // dyld_notify_remove_all
317               dyld_instance->UnloadAllImages();
318             } else if (dyld_mode == 3 && image_infos_count == 1) {
319               // dyld_image_dyld_moved
320 
321               dyld_instance->ClearNotificationBreakpoint();
322               dyld_instance->UnloadAllImages();
323               dyld_instance->ClearDYLDModule();
324               process->GetTarget().GetImages().Clear();
325               process->GetTarget().GetSectionLoadList().Clear();
326 
327               addr_t all_image_infos = process->GetImageInfoAddress();
328               int addr_size =
329                   process->GetTarget().GetArchitecture().GetAddressByteSize();
330               addr_t notification_location = all_image_infos + 4 + // version
331                                              4 +        // infoArrayCount
332                                              addr_size; // infoArray
333               Status error;
334               addr_t notification_addr =
335                   process->ReadPointerFromMemory(notification_location, error);
336               if (ABISP abi_sp = process->GetABI())
337                 notification_addr = abi_sp->FixCodeAddress(notification_addr);
338 
339               dyld_instance->SetDYLDHandoverBreakpoint(notification_addr);
340             }
341           }
342         }
343       }
344     }
345   } else {
346     Target &target = process->GetTarget();
347     Debugger::ReportWarning(
348         "no ABI plugin located for triple " +
349             target.GetArchitecture().GetTriple().getTriple() +
350             ": shared libraries will not be registered",
351         target.GetDebugger().GetID());
352   }
353 
354   // Return true to stop the target, false to just let the target run
355   return dyld_instance->GetStopWhenImagesChange();
356 }
357 
AddBinaries(const std::vector<lldb::addr_t> & load_addresses)358 void DynamicLoaderMacOS::AddBinaries(
359     const std::vector<lldb::addr_t> &load_addresses) {
360   Log *log = GetLog(LLDBLog::DynamicLoader);
361   ImageInfo::collection image_infos;
362 
363   LLDB_LOGF(log, "Adding %" PRId64 " modules.",
364             (uint64_t)load_addresses.size());
365   StructuredData::ObjectSP binaries_info_sp =
366       m_process->GetLoadedDynamicLibrariesInfos(load_addresses);
367   if (binaries_info_sp.get() && binaries_info_sp->GetAsDictionary() &&
368       binaries_info_sp->GetAsDictionary()->HasKey("images") &&
369       binaries_info_sp->GetAsDictionary()
370           ->GetValueForKey("images")
371           ->GetAsArray() &&
372       binaries_info_sp->GetAsDictionary()
373               ->GetValueForKey("images")
374               ->GetAsArray()
375               ->GetSize() == load_addresses.size()) {
376     if (JSONImageInformationIntoImageInfo(binaries_info_sp, image_infos)) {
377       UpdateSpecialBinariesFromNewImageInfos(image_infos);
378       AddModulesUsingImageInfos(image_infos);
379     }
380     m_dyld_image_infos_stop_id = m_process->GetStopID();
381   }
382 }
383 
384 // Dump the _dyld_all_image_infos members and all current image infos that we
385 // have parsed to the file handle provided.
PutToLog(Log * log) const386 void DynamicLoaderMacOS::PutToLog(Log *log) const {
387   if (log == nullptr)
388     return;
389 }
390 
SetNotificationBreakpoint()391 bool DynamicLoaderMacOS::SetNotificationBreakpoint() {
392   if (m_break_id == LLDB_INVALID_BREAK_ID) {
393     ModuleSP dyld_sp(GetDYLDModule());
394     if (dyld_sp) {
395       bool internal = true;
396       bool hardware = false;
397       LazyBool skip_prologue = eLazyBoolNo;
398       FileSpecList *source_files = nullptr;
399       FileSpecList dyld_filelist;
400       dyld_filelist.Append(dyld_sp->GetFileSpec());
401 
402       Breakpoint *breakpoint =
403           m_process->GetTarget()
404               .CreateBreakpoint(&dyld_filelist, source_files,
405                                 "_dyld_debugger_notification",
406                                 eFunctionNameTypeFull, eLanguageTypeC, 0,
407                                 skip_prologue, internal, hardware)
408               .get();
409       breakpoint->SetCallback(DynamicLoaderMacOS::NotifyBreakpointHit, this,
410                               true);
411       breakpoint->SetBreakpointKind("shared-library-event");
412       m_break_id = breakpoint->GetID();
413     }
414   }
415   return m_break_id != LLDB_INVALID_BREAK_ID;
416 }
417 
SetDYLDHandoverBreakpoint(addr_t notification_address)418 bool DynamicLoaderMacOS::SetDYLDHandoverBreakpoint(
419     addr_t notification_address) {
420   if (m_dyld_handover_break_id == LLDB_INVALID_BREAK_ID) {
421     BreakpointSP dyld_handover_bp = m_process->GetTarget().CreateBreakpoint(
422         notification_address, true, false);
423     dyld_handover_bp->SetCallback(DynamicLoaderMacOS::NotifyBreakpointHit, this,
424                                   true);
425     dyld_handover_bp->SetOneShot(true);
426     m_dyld_handover_break_id = dyld_handover_bp->GetID();
427     return true;
428   }
429   return false;
430 }
431 
ClearDYLDHandoverBreakpoint()432 void DynamicLoaderMacOS::ClearDYLDHandoverBreakpoint() {
433   if (LLDB_BREAK_ID_IS_VALID(m_dyld_handover_break_id))
434     m_process->GetTarget().RemoveBreakpointByID(m_dyld_handover_break_id);
435   m_dyld_handover_break_id = LLDB_INVALID_BREAK_ID;
436 }
437 
438 addr_t
GetDyldLockVariableAddressFromModule(Module * module)439 DynamicLoaderMacOS::GetDyldLockVariableAddressFromModule(Module *module) {
440   SymbolContext sc;
441   Target &target = m_process->GetTarget();
442   if (Symtab *symtab = module->GetSymtab()) {
443     std::vector<uint32_t> match_indexes;
444     ConstString g_symbol_name("_dyld_global_lock_held");
445     uint32_t num_matches = 0;
446     num_matches =
447         symtab->AppendSymbolIndexesWithName(g_symbol_name, match_indexes);
448     if (num_matches == 1) {
449       Symbol *symbol = symtab->SymbolAtIndex(match_indexes[0]);
450       if (symbol &&
451           (symbol->ValueIsAddress() || symbol->GetAddressRef().IsValid())) {
452         return symbol->GetAddressRef().GetOpcodeLoadAddress(&target);
453       }
454     }
455   }
456   return LLDB_INVALID_ADDRESS;
457 }
458 
459 //  Look for this symbol:
460 //
461 //  int __attribute__((visibility("hidden")))           _dyld_global_lock_held =
462 //  0;
463 //
464 //  in libdyld.dylib.
CanLoadImage()465 Status DynamicLoaderMacOS::CanLoadImage() {
466   Status error;
467   addr_t symbol_address = LLDB_INVALID_ADDRESS;
468   ConstString g_libdyld_name("libdyld.dylib");
469   Target &target = m_process->GetTarget();
470   const ModuleList &target_modules = target.GetImages();
471   std::lock_guard<std::recursive_mutex> guard(target_modules.GetMutex());
472 
473   // Find any modules named "libdyld.dylib" and look for the symbol there first
474   for (ModuleSP module_sp : target.GetImages().ModulesNoLocking()) {
475     if (module_sp) {
476       if (module_sp->GetFileSpec().GetFilename() == g_libdyld_name) {
477         symbol_address = GetDyldLockVariableAddressFromModule(module_sp.get());
478         if (symbol_address != LLDB_INVALID_ADDRESS)
479           break;
480       }
481     }
482   }
483 
484   // Search through all modules looking for the symbol in them
485   if (symbol_address == LLDB_INVALID_ADDRESS) {
486     for (ModuleSP module_sp : target.GetImages().Modules()) {
487       if (module_sp) {
488         addr_t symbol_address =
489             GetDyldLockVariableAddressFromModule(module_sp.get());
490         if (symbol_address != LLDB_INVALID_ADDRESS)
491           break;
492       }
493     }
494   }
495 
496   // Default assumption is that it is OK to load images. Only say that we
497   // cannot load images if we find the symbol in libdyld and it indicates that
498   // we cannot.
499 
500   if (symbol_address != LLDB_INVALID_ADDRESS) {
501     {
502       int lock_held =
503           m_process->ReadUnsignedIntegerFromMemory(symbol_address, 4, 0, error);
504       if (lock_held != 0) {
505         error.SetErrorString("dyld lock held - unsafe to load images.");
506       }
507     }
508   } else {
509     // If we were unable to find _dyld_global_lock_held in any modules, or it
510     // is not loaded into memory yet, we may be at process startup (sitting  at
511     // _dyld_start) - so we should not allow dlopen calls. But if we found more
512     // than one module then we are clearly past _dyld_start so in that case
513     // we'll default to "it's safe".
514     if (target.GetImages().GetSize() <= 1)
515       error.SetErrorString("could not find the dyld library or "
516                            "the dyld lock symbol");
517   }
518   return error;
519 }
520 
GetSharedCacheInformation(lldb::addr_t & base_address,UUID & uuid,LazyBool & using_shared_cache,LazyBool & private_shared_cache)521 bool DynamicLoaderMacOS::GetSharedCacheInformation(
522     lldb::addr_t &base_address, UUID &uuid, LazyBool &using_shared_cache,
523     LazyBool &private_shared_cache) {
524   base_address = LLDB_INVALID_ADDRESS;
525   uuid.Clear();
526   using_shared_cache = eLazyBoolCalculate;
527   private_shared_cache = eLazyBoolCalculate;
528 
529   if (m_process) {
530     StructuredData::ObjectSP info = m_process->GetSharedCacheInfo();
531     StructuredData::Dictionary *info_dict = nullptr;
532     if (info.get() && info->GetAsDictionary()) {
533       info_dict = info->GetAsDictionary();
534     }
535 
536     // {"shared_cache_base_address":140735683125248,"shared_cache_uuid
537     // ":"DDB8D70C-
538     // C9A2-3561-B2C8-BE48A4F33F96","no_shared_cache":false,"shared_cache_private_cache":false}
539 
540     if (info_dict && info_dict->HasKey("shared_cache_uuid") &&
541         info_dict->HasKey("no_shared_cache") &&
542         info_dict->HasKey("shared_cache_base_address")) {
543       base_address = info_dict->GetValueForKey("shared_cache_base_address")
544                          ->GetIntegerValue(LLDB_INVALID_ADDRESS);
545       std::string uuid_str = std::string(
546           info_dict->GetValueForKey("shared_cache_uuid")->GetStringValue());
547       if (!uuid_str.empty())
548         uuid.SetFromStringRef(uuid_str);
549       if (!info_dict->GetValueForKey("no_shared_cache")->GetBooleanValue())
550         using_shared_cache = eLazyBoolYes;
551       else
552         using_shared_cache = eLazyBoolNo;
553       if (info_dict->GetValueForKey("shared_cache_private_cache")
554               ->GetBooleanValue())
555         private_shared_cache = eLazyBoolYes;
556       else
557         private_shared_cache = eLazyBoolNo;
558 
559       return true;
560     }
561   }
562   return false;
563 }
564 
Initialize()565 void DynamicLoaderMacOS::Initialize() {
566   PluginManager::RegisterPlugin(GetPluginNameStatic(),
567                                 GetPluginDescriptionStatic(), CreateInstance);
568 }
569 
Terminate()570 void DynamicLoaderMacOS::Terminate() {
571   PluginManager::UnregisterPlugin(CreateInstance);
572 }
573 
GetPluginDescriptionStatic()574 llvm::StringRef DynamicLoaderMacOS::GetPluginDescriptionStatic() {
575   return "Dynamic loader plug-in that watches for shared library loads/unloads "
576          "in MacOSX user processes.";
577 }
578