Fix a problem with the new dyld interface code -- when a new process
starts up, we need to clear the target's image list and only add
the binaries into the target that are actually present in this
process run.

<rdar://problem/29857613> 

llvm-svn: 292454
diff --git a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOS.cpp b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOS.cpp
index 7b027de..0f8b190 100644
--- a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOS.cpp
+++ b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOS.cpp
@@ -151,6 +151,11 @@
 void DynamicLoaderMacOS::DoInitialImageFetch() {
   Log *log(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_DYNAMIC_LOADER));
 
+  // Remove any binaries we pre-loaded in the Target before launching/attaching.
+  // If the same binaries are present in the process, we'll get them from the
+  // shared module cache, we won't need to re-load them from disk.
+  UnloadAllImages();
+
   StructuredData::ObjectSP all_image_info_json_sp(
       m_process->GetLoadedDynamicLibrariesInfos());
   ImageInfo::collection image_infos;