@@ -350,16 +350,13 @@ Status PlatformDarwin::GetSharedModule(
350350 old_modules, did_create_ptr);
351351
352352 const FileSpec &platform_file = module_spec.GetFileSpec ();
353- // Get module search paths from the target if available
354- ModuleSpec module_spec_copy (module_spec);
355- Target *target = module_spec_copy.GetTargetPtr ();
353+ // Get module search paths from the target if available.
354+ TargetSP target_sp = module_spec.GetTargetSP ();
356355 FileSpecList module_search_paths;
357- FileSpecList *module_search_paths_ptr = nullptr ;
358- if (target) {
359- module_search_paths = target->GetExecutableSearchPaths ();
360- module_search_paths_ptr = &module_search_paths;
356+ if (target_sp) {
357+ module_search_paths = target_sp->GetExecutableSearchPaths ();
361358 }
362- if (!module_sp && module_search_paths_ptr && platform_file) {
359+ if (!module_sp && !module_search_paths. IsEmpty () && platform_file) {
363360 // We can try to pull off part of the file path up to the bundle
364361 // directory level and try any module search paths...
365362 FileSpec bundle_directory;
@@ -382,10 +379,10 @@ Status PlatformDarwin::GetSharedModule(
382379 const size_t bundle_directory_len =
383380 bundle_directory.GetPath (bundle_dir, sizeof (bundle_dir));
384381 char new_path[PATH_MAX];
385- size_t num_module_search_paths = module_search_paths_ptr-> GetSize ();
382+ size_t num_module_search_paths = module_search_paths. GetSize ();
386383 for (size_t i = 0 ; i < num_module_search_paths; ++i) {
387384 const size_t search_path_len =
388- module_search_paths_ptr-> GetFileSpecAtIndex (i).GetPath (
385+ module_search_paths. GetFileSpecAtIndex (i).GetPath (
389386 new_path, sizeof (new_path));
390387 if (search_path_len < sizeof (new_path)) {
391388 snprintf (new_path + search_path_len,
@@ -1311,17 +1308,14 @@ lldb_private::Status PlatformDarwin::FindBundleBinaryInExecSearchPaths(
13111308 const ModuleSpec &module_spec, Process *process, ModuleSP &module_sp,
13121309 llvm::SmallVectorImpl<ModuleSP> *old_modules, bool *did_create_ptr) {
13131310 const FileSpec &platform_file = module_spec.GetFileSpec ();
1314- ModuleSpec module_spec_copy (module_spec);
1315- Target *target = module_spec_copy.GetTargetPtr ();
1311+ TargetSP target_sp = module_spec.GetTargetSP ();
13161312 FileSpecList module_search_paths;
1317- FileSpecList *module_search_paths_ptr = nullptr ;
1318- if (target) {
1319- module_search_paths = target->GetExecutableSearchPaths ();
1320- module_search_paths_ptr = &module_search_paths;
1313+ if (target_sp) {
1314+ module_search_paths = target_sp->GetExecutableSearchPaths ();
13211315 }
1322- // See if the file is present in any of the module_search_paths_ptr
1316+ // See if the file is present in any of the module_search_paths
13231317 // directories.
1324- if (!module_sp && module_search_paths_ptr && platform_file) {
1318+ if (!module_sp && !module_search_paths. IsEmpty () && platform_file) {
13251319 // create a vector of all the file / directory names in platform_file e.g.
13261320 // this might be
13271321 // /System/Library/PrivateFrameworks/UIFoundation.framework/UIFoundation
@@ -1335,21 +1329,21 @@ lldb_private::Status PlatformDarwin::FindBundleBinaryInExecSearchPaths(
13351329 std::reverse (path_parts.begin (), path_parts.end ());
13361330 const size_t path_parts_size = path_parts.size ();
13371331
1338- size_t num_module_search_paths = module_search_paths_ptr-> GetSize ();
1332+ size_t num_module_search_paths = module_search_paths. GetSize ();
13391333 for (size_t i = 0 ; i < num_module_search_paths; ++i) {
13401334 Log *log_verbose = GetLog (LLDBLog::Host);
13411335 LLDB_LOGF (
13421336 log_verbose,
13431337 " PlatformRemoteDarwinDevice::GetSharedModule searching for binary in "
13441338 " search-path %s" ,
1345- module_search_paths_ptr-> GetFileSpecAtIndex (i).GetPath ().c_str ());
1339+ module_search_paths. GetFileSpecAtIndex (i).GetPath ().c_str ());
13461340 // Create a new FileSpec with this module_search_paths_ptr plus just the
13471341 // filename ("UIFoundation"), then the parent dir plus filename
13481342 // ("UIFoundation.framework/UIFoundation") etc - up to four names (to
13491343 // handle "Foo.framework/Contents/MacOS/Foo")
13501344
13511345 for (size_t j = 0 ; j < 4 && j < path_parts_size - 1 ; ++j) {
1352- FileSpec path_to_try (module_search_paths_ptr-> GetFileSpecAtIndex (i));
1346+ FileSpec path_to_try (module_search_paths. GetFileSpecAtIndex (i));
13531347
13541348 // Add the components backwards. For
13551349 // .../PrivateFrameworks/UIFoundation.framework/UIFoundation path_parts
0 commit comments