1 //===-- PlatformRemoteiOS.cpp -----------------------------------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 
10 #include "PlatformRemoteiOS.h"
11 
12 // C Includes
13 // C++ Includes
14 // Other libraries and framework includes
15 // Project includes
16 #include "lldb/Breakpoint/BreakpointLocation.h"
17 #include "lldb/Core/ArchSpec.h"
18 #include "lldb/Core/Error.h"
19 #include "lldb/Core/Module.h"
20 #include "lldb/Core/ModuleList.h"
21 #include "lldb/Core/ModuleSpec.h"
22 #include "lldb/Core/PluginManager.h"
23 #include "lldb/Core/StreamString.h"
24 #include "lldb/Host/FileSpec.h"
25 #include "lldb/Host/Host.h"
26 #include "lldb/Target/Process.h"
27 #include "lldb/Target/Target.h"
28 
29 using namespace lldb;
30 using namespace lldb_private;
31 
32 PlatformRemoteiOS::SDKDirectoryInfo::SDKDirectoryInfo (const lldb_private::FileSpec &sdk_dir) :
33     directory(sdk_dir),
34     build(),
35     version_major(0),
36     version_minor(0),
37     version_update(0),
38     user_cached(false)
39 {
40     const char *dirname_cstr = sdk_dir.GetFilename().GetCString();
41     const char *pos = Args::StringToVersion (dirname_cstr,
42                                              version_major,
43                                              version_minor,
44                                              version_update);
45 
46     if (pos && pos[0] == ' ' && pos[1] == '(')
47     {
48         const char *build_start = pos + 2;
49         const char *end_paren = strchr (build_start, ')');
50         if (end_paren && build_start < end_paren)
51             build.SetCStringWithLength(build_start, end_paren - build_start);
52     }
53 }
54 
55 //------------------------------------------------------------------
56 // Static Variables
57 //------------------------------------------------------------------
58 static uint32_t g_initialize_count = 0;
59 
60 //------------------------------------------------------------------
61 // Static Functions
62 //------------------------------------------------------------------
63 void
64 PlatformRemoteiOS::Initialize ()
65 {
66     if (g_initialize_count++ == 0)
67     {
68         PluginManager::RegisterPlugin (PlatformRemoteiOS::GetShortPluginNameStatic(),
69                                        PlatformRemoteiOS::GetDescriptionStatic(),
70                                        PlatformRemoteiOS::CreateInstance);
71     }
72 }
73 
74 void
75 PlatformRemoteiOS::Terminate ()
76 {
77     if (g_initialize_count > 0)
78     {
79         if (--g_initialize_count == 0)
80         {
81             PluginManager::UnregisterPlugin (PlatformRemoteiOS::CreateInstance);
82         }
83     }
84 }
85 
86 Platform*
87 PlatformRemoteiOS::CreateInstance (bool force, const ArchSpec *arch)
88 {
89     bool create = force;
90     if (create == false && arch && arch->IsValid())
91     {
92         switch (arch->GetMachine())
93         {
94         case llvm::Triple::arm:
95         case llvm::Triple::thumb:
96             {
97                 const llvm::Triple &triple = arch->GetTriple();
98                 llvm::Triple::VendorType vendor = triple.getVendor();
99                 switch (vendor)
100                 {
101                     case llvm::Triple::Apple:
102                         create = true;
103                         break;
104 
105                     case llvm::Triple::UnknownArch:
106                         create = !arch->TripleVendorWasSpecified();
107                         break;
108 
109                     default:
110                         break;
111                 }
112 
113                 if (create)
114                 {
115                     switch (triple.getOS())
116                     {
117                         case llvm::Triple::Darwin:  // Deprecated, but still support Darwin for historical reasons
118                         case llvm::Triple::IOS:     // This is the right triple value for iOS debugging
119                             break;
120 
121                         case llvm::Triple::UnknownOS:
122                             create = !arch->TripleOSWasSpecified();
123                             break;
124 
125                         default:
126                             create = false;
127                             break;
128                     }
129                 }
130             }
131             break;
132         default:
133             break;
134         }
135     }
136 
137     if (create)
138         return new PlatformRemoteiOS ();
139     return NULL;
140 }
141 
142 
143 const char *
144 PlatformRemoteiOS::GetPluginNameStatic ()
145 {
146     return "PlatformRemoteiOS";
147 }
148 
149 const char *
150 PlatformRemoteiOS::GetShortPluginNameStatic()
151 {
152     return "remote-ios";
153 }
154 
155 const char *
156 PlatformRemoteiOS::GetDescriptionStatic()
157 {
158     return "Remote iOS platform plug-in.";
159 }
160 
161 
162 //------------------------------------------------------------------
163 /// Default Constructor
164 //------------------------------------------------------------------
165 PlatformRemoteiOS::PlatformRemoteiOS () :
166     PlatformDarwin (false),    // This is a remote platform
167     m_sdk_directory_infos(),
168     m_device_support_directory(),
169     m_device_support_directory_for_os_version (),
170     m_build_update(),
171     m_last_module_sdk_idx(UINT32_MAX)
172 {
173 }
174 
175 //------------------------------------------------------------------
176 /// Destructor.
177 ///
178 /// The destructor is virtual since this class is designed to be
179 /// inherited from by the plug-in instance.
180 //------------------------------------------------------------------
181 PlatformRemoteiOS::~PlatformRemoteiOS()
182 {
183 }
184 
185 
186 void
187 PlatformRemoteiOS::GetStatus (Stream &strm)
188 {
189     Platform::GetStatus (strm);
190     const char *sdk_directory = GetDeviceSupportDirectoryForOSVersion();
191     if (sdk_directory)
192         strm.Printf ("  SDK Path: \"%s\"\n", sdk_directory);
193     else
194         strm.PutCString ("  SDK Path: error: unable to locate SDK\n");
195 
196     const uint32_t num_sdk_infos = m_sdk_directory_infos.size();
197     for (uint32_t i=0; i<num_sdk_infos; ++i)
198     {
199         const SDKDirectoryInfo &sdk_dir_info = m_sdk_directory_infos[i];
200         strm.Printf (" SDK Roots: [%2u] \"%s/%s\"\n",
201                      i,
202                      sdk_dir_info.directory.GetDirectory().GetCString(),
203                      sdk_dir_info.directory.GetFilename().GetCString());
204     }
205 }
206 
207 
208 Error
209 PlatformRemoteiOS::ResolveExecutable (const FileSpec &exe_file,
210                                       const ArchSpec &exe_arch,
211                                       lldb::ModuleSP &exe_module_sp,
212                                       const FileSpecList *module_search_paths_ptr)
213 {
214     Error error;
215     // Nothing special to do here, just use the actual file and architecture
216 
217     FileSpec resolved_exe_file (exe_file);
218 
219     // If we have "ls" as the exe_file, resolve the executable loation based on
220     // the current path variables
221     // TODO: resolve bare executables in the Platform SDK
222 //    if (!resolved_exe_file.Exists())
223 //        resolved_exe_file.ResolveExecutableLocation ();
224 
225     // Resolve any executable within a bundle on MacOSX
226     // TODO: verify that this handles shallow bundles, if not then implement one ourselves
227     Host::ResolveExecutableInBundle (resolved_exe_file);
228 
229     if (resolved_exe_file.Exists())
230     {
231         if (exe_arch.IsValid())
232         {
233             ModuleSpec module_spec (resolved_exe_file, exe_arch);
234             error = ModuleList::GetSharedModule (module_spec,
235                                                  exe_module_sp,
236                                                  NULL,
237                                                  NULL,
238                                                  NULL);
239 
240             if (exe_module_sp && exe_module_sp->GetObjectFile())
241                 return error;
242             exe_module_sp.reset();
243         }
244         // No valid architecture was specified or the exact ARM slice wasn't
245         // found so ask the platform for the architectures that we should be
246         // using (in the correct order) and see if we can find a match that way
247         StreamString arch_names;
248         ArchSpec platform_arch;
249         for (uint32_t idx = 0; GetSupportedArchitectureAtIndex (idx, platform_arch); ++idx)
250         {
251             ModuleSpec module_spec (resolved_exe_file, platform_arch);
252             error = ModuleList::GetSharedModule (module_spec,
253                                                  exe_module_sp,
254                                                  NULL,
255                                                  NULL,
256                                                  NULL);
257             // Did we find an executable using one of the
258             if (error.Success())
259             {
260                 if (exe_module_sp && exe_module_sp->GetObjectFile())
261                     break;
262                 else
263                     error.SetErrorToGenericError();
264             }
265 
266             if (idx > 0)
267                 arch_names.PutCString (", ");
268             arch_names.PutCString (platform_arch.GetArchitectureName());
269         }
270 
271         if (error.Fail() || !exe_module_sp)
272         {
273             error.SetErrorStringWithFormat ("'%s%s%s' doesn't contain any '%s' platform architectures: %s",
274                                             exe_file.GetDirectory().AsCString(""),
275                                             exe_file.GetDirectory() ? "/" : "",
276                                             exe_file.GetFilename().AsCString(""),
277                                             GetShortPluginName(),
278                                             arch_names.GetString().c_str());
279         }
280     }
281     else
282     {
283         error.SetErrorStringWithFormat ("'%s%s%s' does not exist",
284                                         exe_file.GetDirectory().AsCString(""),
285                                         exe_file.GetDirectory() ? "/" : "",
286                                         exe_file.GetFilename().AsCString(""));
287     }
288 
289     return error;
290 }
291 
292 FileSpec::EnumerateDirectoryResult
293 PlatformRemoteiOS::GetContainedFilesIntoVectorOfStringsCallback (void *baton,
294                                                                  FileSpec::FileType file_type,
295                                                                  const FileSpec &file_spec)
296 {
297     ((PlatformRemoteiOS::SDKDirectoryInfoCollection *)baton)->push_back(PlatformRemoteiOS::SDKDirectoryInfo(file_spec));
298     return FileSpec::eEnumerateDirectoryResultNext;
299 }
300 
301 bool
302 PlatformRemoteiOS::UpdateSDKDirectoryInfosInNeeded()
303 {
304     if (m_sdk_directory_infos.empty())
305     {
306         const char *device_support_dir = GetDeviceSupportDirectory();
307         if (device_support_dir)
308         {
309             const bool find_directories = true;
310             const bool find_files = false;
311             const bool find_other = false;
312             FileSpec::EnumerateDirectory (m_device_support_directory.c_str(),
313                                           find_directories,
314                                           find_files,
315                                           find_other,
316                                           GetContainedFilesIntoVectorOfStringsCallback,
317                                           &m_sdk_directory_infos);
318 
319             const uint32_t num_installed = m_sdk_directory_infos.size();
320             FileSpec local_sdk_cache("~/Library/Developer/Xcode/iOS DeviceSupport", true);
321             if (local_sdk_cache.Exists())
322             {
323                 char path[PATH_MAX];
324                 if (local_sdk_cache.GetPath(path, sizeof(path)))
325                 {
326                     FileSpec::EnumerateDirectory (path,
327                                                   find_directories,
328                                                   find_files,
329                                                   find_other,
330                                                   GetContainedFilesIntoVectorOfStringsCallback,
331                                                   &m_sdk_directory_infos);
332                     const uint32_t num_sdk_infos = m_sdk_directory_infos.size();
333                     // First try for an exact match of major, minor and update
334                     for (uint32_t i=num_installed; i<num_sdk_infos; ++i)
335                     {
336                         m_sdk_directory_infos[i].user_cached = true;
337                     }
338                 }
339             }
340         }
341     }
342     return !m_sdk_directory_infos.empty();
343 }
344 
345 const PlatformRemoteiOS::SDKDirectoryInfo *
346 PlatformRemoteiOS::GetSDKDirectoryForCurrentOSVersion ()
347 {
348     uint32_t i;
349     if (UpdateSDKDirectoryInfosInNeeded())
350     {
351         const uint32_t num_sdk_infos = m_sdk_directory_infos.size();
352 
353         // Check to see if the user specified a build string. If they did, then
354         // be sure to match it.
355         std::vector<bool> check_sdk_info(num_sdk_infos, true);
356         ConstString build(m_sdk_build);
357         if (build)
358         {
359             for (i=0; i<num_sdk_infos; ++i)
360                 check_sdk_info[i] = m_sdk_directory_infos[i].build == build;
361         }
362 
363         // If we are connected we can find the version of the OS the platform
364         // us running on and select the right SDK
365         uint32_t major, minor, update;
366         if (GetOSVersion(major, minor, update))
367         {
368             if (UpdateSDKDirectoryInfosInNeeded())
369             {
370                 // First try for an exact match of major, minor and update
371                 for (i=0; i<num_sdk_infos; ++i)
372                 {
373                     if (check_sdk_info[i])
374                     {
375                         if (m_sdk_directory_infos[i].version_major == major &&
376                             m_sdk_directory_infos[i].version_minor == minor &&
377                             m_sdk_directory_infos[i].version_update == update)
378                         {
379                             return &m_sdk_directory_infos[i];
380                         }
381                     }
382                 }
383                 // First try for an exact match of major and minor
384                 for (i=0; i<num_sdk_infos; ++i)
385                 {
386                     if (check_sdk_info[i])
387                     {
388                         if (m_sdk_directory_infos[i].version_major == major &&
389                             m_sdk_directory_infos[i].version_minor == minor)
390                         {
391                             return &m_sdk_directory_infos[i];
392                         }
393                     }
394                 }
395                 // Lastly try to match of major version only..
396                 for (i=0; i<num_sdk_infos; ++i)
397                 {
398                     if (check_sdk_info[i])
399                     {
400                         if (m_sdk_directory_infos[i].version_major == major)
401                         {
402                             return &m_sdk_directory_infos[i];
403                         }
404                     }
405                 }
406             }
407         }
408         else if (build)
409         {
410             // No version, just a build number, search for the first one that matches
411             for (i=0; i<num_sdk_infos; ++i)
412                 if (check_sdk_info[i])
413                     return &m_sdk_directory_infos[i];
414         }
415     }
416     return NULL;
417 }
418 
419 const PlatformRemoteiOS::SDKDirectoryInfo *
420 PlatformRemoteiOS::GetSDKDirectoryForLatestOSVersion ()
421 {
422     const PlatformRemoteiOS::SDKDirectoryInfo *result = NULL;
423     if (UpdateSDKDirectoryInfosInNeeded())
424     {
425         const uint32_t num_sdk_infos = m_sdk_directory_infos.size();
426         // First try for an exact match of major, minor and update
427         for (uint32_t i=0; i<num_sdk_infos; ++i)
428         {
429             const SDKDirectoryInfo &sdk_dir_info = m_sdk_directory_infos[i];
430             if (sdk_dir_info.version_major != UINT32_MAX)
431             {
432                 if (result == NULL || sdk_dir_info.version_major > result->version_major)
433                 {
434                     result = &sdk_dir_info;
435                 }
436                 else if (sdk_dir_info.version_major == result->version_major)
437                 {
438                     if (sdk_dir_info.version_minor > result->version_minor)
439                     {
440                         result = &sdk_dir_info;
441                     }
442                     else if (sdk_dir_info.version_minor == result->version_minor)
443                     {
444                         if (sdk_dir_info.version_update > result->version_update)
445                         {
446                             result = &sdk_dir_info;
447                         }
448                     }
449                 }
450             }
451         }
452     }
453     return result;
454 }
455 
456 
457 
458 const char *
459 PlatformRemoteiOS::GetDeviceSupportDirectory()
460 {
461     if (m_device_support_directory.empty())
462     {
463         const char *device_support_dir = GetDeveloperDirectory();
464         if (device_support_dir)
465         {
466             m_device_support_directory.assign (device_support_dir);
467             m_device_support_directory.append ("/Platforms/iPhoneOS.platform/DeviceSupport");
468         }
469         else
470         {
471             // Assign a single NULL character so we know we tried to find the device
472             // support directory and we don't keep trying to find it over and over.
473             m_device_support_directory.assign (1, '\0');
474         }
475     }
476     // We should have put a single NULL character into m_device_support_directory
477     // or it should have a valid path if the code gets here
478     assert (m_device_support_directory.empty() == false);
479     if (m_device_support_directory[0])
480         return m_device_support_directory.c_str();
481     return NULL;
482 }
483 
484 
485 const char *
486 PlatformRemoteiOS::GetDeviceSupportDirectoryForOSVersion()
487 {
488     if (m_sdk_sysroot)
489         return m_sdk_sysroot.GetCString();
490 
491     if (m_device_support_directory_for_os_version.empty())
492     {
493         const PlatformRemoteiOS::SDKDirectoryInfo *sdk_dir_info = GetSDKDirectoryForCurrentOSVersion ();
494         if (sdk_dir_info == NULL)
495             sdk_dir_info = GetSDKDirectoryForLatestOSVersion ();
496         if (sdk_dir_info)
497         {
498             char path[PATH_MAX];
499             if (sdk_dir_info->directory.GetPath(path, sizeof(path)))
500             {
501                 m_device_support_directory_for_os_version = path;
502                 return m_device_support_directory_for_os_version.c_str();
503             }
504         }
505         else
506         {
507             // Assign a single NULL character so we know we tried to find the device
508             // support directory and we don't keep trying to find it over and over.
509             m_device_support_directory_for_os_version.assign (1, '\0');
510         }
511     }
512     // We should have put a single NULL character into m_device_support_directory_for_os_version
513     // or it should have a valid path if the code gets here
514     assert (m_device_support_directory_for_os_version.empty() == false);
515     if (m_device_support_directory_for_os_version[0])
516         return m_device_support_directory_for_os_version.c_str();
517     return NULL;
518 }
519 
520 uint32_t
521 PlatformRemoteiOS::FindFileInAllSDKs (const char *platform_file_path,
522                                       FileSpecList &file_list)
523 {
524     if (platform_file_path && platform_file_path[0] && UpdateSDKDirectoryInfosInNeeded())
525     {
526         const uint32_t num_sdk_infos = m_sdk_directory_infos.size();
527         lldb_private::FileSpec local_file;
528         // First try for an exact match of major, minor and update
529         for (uint32_t sdk_idx=0; sdk_idx<num_sdk_infos; ++sdk_idx)
530         {
531             if (GetFileInSDK (platform_file_path,
532                               sdk_idx,
533                               local_file))
534             {
535                 file_list.Append(local_file);
536             }
537         }
538     }
539     return file_list.GetSize();
540 }
541 
542 bool
543 PlatformRemoteiOS::GetFileInSDK (const char *platform_file_path,
544                                  uint32_t sdk_idx,
545                                  lldb_private::FileSpec &local_file)
546 {
547     if (sdk_idx < m_sdk_directory_infos.size())
548     {
549         char sdkroot_path[PATH_MAX];
550         const SDKDirectoryInfo &sdk_dir_info = m_sdk_directory_infos[sdk_idx];
551         if (sdk_dir_info.directory.GetPath(sdkroot_path, sizeof(sdkroot_path)))
552         {
553             const bool symbols_dirs_only = true;
554 
555             return GetFileInSDKRoot (platform_file_path,
556                                      sdkroot_path,
557                                      symbols_dirs_only,
558                                      local_file);
559         }
560     }
561     return false;
562 }
563 
564 
565 bool
566 PlatformRemoteiOS::GetFileInSDKRoot (const char *platform_file_path,
567                                      const char *sdkroot_path,
568                                      bool symbols_dirs_only,
569                                      lldb_private::FileSpec &local_file)
570 {
571     if (sdkroot_path && sdkroot_path[0] && platform_file_path && platform_file_path[0])
572     {
573         char resolved_path[PATH_MAX];
574 
575         if (!symbols_dirs_only)
576         {
577             ::snprintf (resolved_path,
578                         sizeof(resolved_path),
579                         "%s/%s",
580                         sdkroot_path,
581                         platform_file_path);
582 
583             local_file.SetFile(resolved_path, true);
584             if (local_file.Exists())
585                 return true;
586         }
587 
588         ::snprintf (resolved_path,
589                     sizeof(resolved_path),
590                     "%s/Symbols.Internal/%s",
591                     sdkroot_path,
592                     platform_file_path);
593 
594         local_file.SetFile(resolved_path, true);
595         if (local_file.Exists())
596             return true;
597         ::snprintf (resolved_path,
598                     sizeof(resolved_path),
599                     "%s/Symbols/%s",
600                     sdkroot_path,
601                     platform_file_path);
602 
603         local_file.SetFile(resolved_path, true);
604         if (local_file.Exists())
605             return true;
606     }
607     return false;
608 }
609 
610 
611 Error
612 PlatformRemoteiOS::GetSymbolFile (const FileSpec &platform_file,
613                                   const UUID *uuid_ptr,
614                                   FileSpec &local_file)
615 {
616     Error error;
617     char platform_file_path[PATH_MAX];
618     if (platform_file.GetPath(platform_file_path, sizeof(platform_file_path)))
619     {
620         char resolved_path[PATH_MAX];
621 
622         const char * os_version_dir = GetDeviceSupportDirectoryForOSVersion();
623         if (os_version_dir)
624         {
625             ::snprintf (resolved_path,
626                         sizeof(resolved_path),
627                         "%s/%s",
628                         os_version_dir,
629                         platform_file_path);
630 
631             local_file.SetFile(resolved_path, true);
632             if (local_file.Exists())
633                 return error;
634 
635             ::snprintf (resolved_path,
636                         sizeof(resolved_path),
637                         "%s/Symbols.Internal/%s",
638                         os_version_dir,
639                         platform_file_path);
640 
641             local_file.SetFile(resolved_path, true);
642             if (local_file.Exists())
643                 return error;
644             ::snprintf (resolved_path,
645                         sizeof(resolved_path),
646                         "%s/Symbols/%s",
647                         os_version_dir,
648                         platform_file_path);
649 
650             local_file.SetFile(resolved_path, true);
651             if (local_file.Exists())
652                 return error;
653 
654         }
655         local_file = platform_file;
656         if (local_file.Exists())
657             return error;
658 
659         error.SetErrorStringWithFormat ("unable to locate a platform file for '%s' in platform '%s'",
660                                         platform_file_path,
661                                         GetPluginName());
662     }
663     else
664     {
665         error.SetErrorString ("invalid platform file argument");
666     }
667     return error;
668 }
669 
670 Error
671 PlatformRemoteiOS::GetSharedModule (const ModuleSpec &module_spec,
672                                     ModuleSP &module_sp,
673                                     const FileSpecList *module_search_paths_ptr,
674                                     ModuleSP *old_module_sp_ptr,
675                                     bool *did_create_ptr)
676 {
677     // For iOS, the SDK files are all cached locally on the host
678     // system. So first we ask for the file in the cached SDK,
679     // then we attempt to get a shared module for the right architecture
680     // with the right UUID.
681     const FileSpec &platform_file = module_spec.GetFileSpec();
682 
683     FileSpec local_file;
684     const UUID *module_uuid_ptr = module_spec.GetUUIDPtr();
685     Error error (GetSymbolFile (platform_file, module_uuid_ptr, local_file));
686     if (error.Success())
687     {
688         error = ResolveExecutable (local_file, module_spec.GetArchitecture(), module_sp, NULL);
689         if (module_sp && ((module_uuid_ptr == NULL) || (module_sp->GetUUID() == *module_uuid_ptr)))
690         {
691             //printf ("found in user specified SDK\n");
692             error.Clear();
693             return error;
694         }
695 
696         char platform_file_path[PATH_MAX];
697         if (platform_file.GetPath(platform_file_path, sizeof(platform_file_path)))
698         {
699             FileSpec local_file;
700             const uint32_t num_sdk_infos = m_sdk_directory_infos.size();
701             // Try the last SDK index if it is set as most files from an SDK
702             // will tend to be valid in that same SDK.
703             if (m_last_module_sdk_idx < num_sdk_infos)
704             {
705                 if (GetFileInSDK (platform_file_path, m_last_module_sdk_idx, local_file))
706                 {
707                     //printf ("sdk[%u] last: '%s/%s'\n", m_last_module_sdk_idx, local_file.GetDirectory().GetCString(), local_file.GetFilename().GetCString());
708                     module_sp.reset();
709                     error = ResolveExecutable (local_file,
710                                                module_spec.GetArchitecture(),
711                                                module_sp,
712                                                NULL);
713                     if (module_sp && ((module_uuid_ptr == NULL) || (module_sp->GetUUID() == *module_uuid_ptr)))
714                     {
715                         //printf ("sdk[%u] last found\n", m_last_module_sdk_idx);
716                         error.Clear();
717                         return error;
718                     }
719                 }
720             }
721 
722             // First try for an exact match of major, minor and update
723             for (uint32_t sdk_idx=0; sdk_idx<num_sdk_infos; ++sdk_idx)
724             {
725                 if (m_last_module_sdk_idx == sdk_idx)
726                 {
727                     // Skip the last module SDK index if we already searched
728                     // it above
729                     continue;
730                 }
731                 if (GetFileInSDK (platform_file_path, sdk_idx, local_file))
732                 {
733                     //printf ("sdk[%u]: '%s/%s'\n", sdk_idx, local_file.GetDirectory().GetCString(), local_file.GetFilename().GetCString());
734 
735                     error = ResolveExecutable (local_file,
736                                                module_spec.GetArchitecture(),
737                                                module_sp,
738                                                NULL);
739                     if (module_sp && ((module_uuid_ptr == NULL) || (module_sp->GetUUID() == *module_uuid_ptr)))
740                     {
741                         // Remember the index of the last SDK that we found a file
742                         // in in case the wrong SDK was selected.
743                         m_last_module_sdk_idx = sdk_idx;
744                         //printf ("sdk[%u]: found (setting last to %u)\n", sdk_idx, m_last_module_sdk_idx);
745                         error.Clear();
746                         return error;
747                     }
748                 }
749             }
750         }
751         // Not the module we are looking for... Nothing to see here...
752         module_sp.reset();
753     }
754 
755     const bool always_create = false;
756     error = ModuleList::GetSharedModule (module_spec,
757                                          module_sp,
758                                          module_search_paths_ptr,
759                                          old_module_sp_ptr,
760                                          did_create_ptr,
761                                          always_create);
762 
763     if (module_sp)
764         module_sp->SetPlatformFileSpec(platform_file);
765 
766     return error;
767 }
768 
769 
770 uint32_t
771 PlatformRemoteiOS::FindProcesses (const ProcessInstanceInfoMatch &match_info,
772                                   ProcessInstanceInfoList &process_infos)
773 {
774     // TODO: if connected, send a packet to get the remote process infos by name
775     process_infos.Clear();
776     return 0;
777 }
778 
779 bool
780 PlatformRemoteiOS::GetProcessInfo (lldb::pid_t pid, ProcessInstanceInfo &process_info)
781 {
782     // TODO: if connected, send a packet to get the remote process info
783     process_info.Clear();
784     return false;
785 }
786 
787 bool
788 PlatformRemoteiOS::GetSupportedArchitectureAtIndex (uint32_t idx, ArchSpec &arch)
789 {
790     return ARMGetSupportedArchitectureAtIndex (idx, arch);
791 }
792