Skip to content

Commit 2ccfae8

Browse files
Merge pull request #1147 from adrian-prantl/reentrant-stardust
[lldb/Platform] Synchronize access to SDK String Map. …
2 parents 6d50b5c + 45e89ad commit 2ccfae8

File tree

4 files changed

+9
-7
lines changed

4 files changed

+9
-7
lines changed

lldb/include/lldb/Target/Platform.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,7 @@ class Platform : public PluginInterface {
432432
return lldb_private::ConstString();
433433
}
434434

435-
virtual llvm::StringRef GetSDKPath(lldb_private::XcodeSDK sdk) {
435+
virtual std::string GetSDKPath(lldb_private::XcodeSDK sdk) {
436436
return {};
437437
}
438438

lldb/source/Host/common/Host.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -519,7 +519,7 @@ Status Host::RunShellCommand(const Args &args, const FileSpec &working_dir,
519519
}
520520
}
521521

522-
FileSpec output_file_spec(output_file_path.c_str());
522+
FileSpec output_file_spec(output_file_path.str());
523523
// Set up file descriptors.
524524
launch_info.AppendSuppressFileAction(STDIN_FILENO, true, false);
525525
if (output_file_spec)

lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1761,11 +1761,12 @@ PlatformDarwin::FindXcodeContentsDirectoryInPath(llvm::StringRef path) {
17611761
return {};
17621762
}
17631763

1764-
llvm::StringRef PlatformDarwin::GetSDKPath(XcodeSDK sdk) {
1764+
std::string PlatformDarwin::GetSDKPath(XcodeSDK sdk) {
1765+
std::lock_guard<std::mutex> guard(m_sdk_path_mutex);
17651766
std::string &path = m_sdk_path[sdk.GetString()];
1766-
if (path.empty())
1767-
path = HostInfo::GetXcodeSDK(sdk);
1768-
return path;
1767+
if (!path.empty())
1768+
return path;
1769+
return HostInfo::GetXcodeSDK(sdk);
17691770
}
17701771

17711772
FileSpec PlatformDarwin::GetXcodeContentsDirectory() {

lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ class PlatformDarwin : public PlatformPOSIX {
9090
llvm::Expected<lldb_private::StructuredData::DictionarySP>
9191
FetchExtendedCrashInformation(lldb_private::Process &process) override;
9292

93-
llvm::StringRef GetSDKPath(lldb_private::XcodeSDK sdk) override;
93+
std::string GetSDKPath(lldb_private::XcodeSDK sdk) override;
9494

9595
static lldb_private::FileSpec GetXcodeContentsDirectory();
9696
static lldb_private::FileSpec GetXcodeDeveloperDirectory();
@@ -172,6 +172,7 @@ class PlatformDarwin : public PlatformPOSIX {
172172

173173
std::string m_developer_directory;
174174
llvm::StringMap<std::string> m_sdk_path;
175+
std::mutex m_sdk_path_mutex;
175176

176177
private:
177178
DISALLOW_COPY_AND_ASSIGN(PlatformDarwin);

0 commit comments

Comments
 (0)