@@ -41,12 +41,15 @@ PlatformAppleSimulator::PlatformAppleSimulator(
41
41
const char *class_name, const char *description, ConstString plugin_name,
42
42
llvm::Triple::OSType preferred_os,
43
43
llvm::SmallVector<llvm::StringRef, 4 > supported_triples,
44
- llvm::StringRef sdk, lldb_private::XcodeSDK::Type sdk_type,
44
+ std::string sdk_name_primary, std::string sdk_name_secondary,
45
+ lldb_private::XcodeSDK::Type sdk_type,
45
46
CoreSimulatorSupport::DeviceType::ProductFamilyID kind)
46
47
: PlatformDarwin(true ), m_class_name(class_name),
47
48
m_description(description), m_plugin_name(plugin_name), m_kind(kind),
48
49
m_os_type(preferred_os), m_supported_triples(supported_triples),
49
- m_sdk(sdk), m_sdk_type(sdk_type) {}
50
+ m_sdk_name_primary(std::move(sdk_name_primary)),
51
+ m_sdk_name_secondary(std::move(sdk_name_secondary)),
52
+ m_sdk_type(sdk_type) {}
50
53
51
54
// / Destructor.
52
55
// /
@@ -83,8 +86,9 @@ lldb_private::Status PlatformAppleSimulator::LaunchProcess(
83
86
84
87
void PlatformAppleSimulator::GetStatus (Stream &strm) {
85
88
Platform::GetStatus (strm);
86
- if (!m_sdk.empty ())
87
- strm << " SDK Path: \" " << m_sdk << " \"\n " ;
89
+ llvm::StringRef sdk = GetSDKFilepath ();
90
+ if (!sdk.empty ())
91
+ strm << " SDK Path: \" " << sdk << " \"\n " ;
88
92
else
89
93
strm << " SDK Path: error: unable to locate SDK\n " ;
90
94
@@ -295,13 +299,21 @@ static llvm::StringRef GetXcodeSDKDir(std::string preferred,
295
299
return sdk;
296
300
}
297
301
302
+ llvm::StringRef PlatformAppleSimulator::GetSDKFilepath () {
303
+ if (!m_have_searched_for_sdk) {
304
+ m_sdk = GetXcodeSDKDir (m_sdk_name_primary, m_sdk_name_secondary);
305
+ m_have_searched_for_sdk = true ;
306
+ }
307
+ return m_sdk;
308
+ }
309
+
298
310
PlatformSP PlatformAppleSimulator::CreateInstance (
299
311
const char *class_name, const char *description, ConstString plugin_name,
300
312
llvm::SmallVector<llvm::Triple::ArchType, 4 > supported_arch,
301
313
llvm::Triple::OSType preferred_os,
302
314
llvm::SmallVector<llvm::Triple::OSType, 4 > supported_os,
303
315
llvm::SmallVector<llvm::StringRef, 4 > supported_triples,
304
- std::string sdk_name_preferred , std::string sdk_name_secondary,
316
+ std::string sdk_name_primary , std::string sdk_name_secondary,
305
317
lldb_private::XcodeSDK::Type sdk_type,
306
318
CoreSimulatorSupport::DeviceType::ProductFamilyID kind, bool force,
307
319
const ArchSpec *arch) {
@@ -360,11 +372,9 @@ PlatformSP PlatformAppleSimulator::CreateInstance(
360
372
if (create) {
361
373
LLDB_LOGF (log, " %s::%s() creating platform" , class_name, __FUNCTION__);
362
374
363
- llvm::StringRef sdk =
364
- GetXcodeSDKDir (sdk_name_preferred, sdk_name_secondary);
365
375
return PlatformSP (new PlatformAppleSimulator (
366
376
class_name, description, plugin_name, preferred_os, supported_triples,
367
- sdk , sdk_type, kind));
377
+ sdk_name_primary, sdk_name_secondary , sdk_type, kind));
368
378
}
369
379
370
380
LLDB_LOGF (log, " %s::%s() aborting creation of platform" , class_name,
@@ -456,9 +466,10 @@ Status PlatformAppleSimulator::GetSymbolFile(const FileSpec &platform_file,
456
466
if (platform_file.GetPath (platform_file_path, sizeof (platform_file_path))) {
457
467
char resolved_path[PATH_MAX];
458
468
459
- if (!m_sdk.empty ()) {
469
+ llvm::StringRef sdk = GetSDKFilepath ();
470
+ if (!sdk.empty ()) {
460
471
::snprintf (resolved_path, sizeof (resolved_path), "%s/%s",
461
- m_sdk .str().c_str(), platform_file_path);
472
+ sdk .str().c_str(), platform_file_path);
462
473
463
474
// First try in the SDK and see if the file is in there
464
475
local_file.SetFile (resolved_path, FileSpec::Style::native);
0 commit comments