Skip to content

[lldb/Platform] Synchronize access to SDK String Map. … #1147

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lldb/include/lldb/Target/Platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ class Platform : public PluginInterface {
return lldb_private::ConstString();
}

virtual llvm::StringRef GetSDKPath(lldb_private::XcodeSDK sdk) {
virtual std::string GetSDKPath(lldb_private::XcodeSDK sdk) {
return {};
}

Expand Down
2 changes: 1 addition & 1 deletion lldb/source/Host/common/Host.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,7 @@ Status Host::RunShellCommand(const Args &args, const FileSpec &working_dir,
}
}

FileSpec output_file_spec(output_file_path.c_str());
FileSpec output_file_spec(output_file_path.str());
// Set up file descriptors.
launch_info.AppendSuppressFileAction(STDIN_FILENO, true, false);
if (output_file_spec)
Expand Down
9 changes: 5 additions & 4 deletions lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1761,11 +1761,12 @@ PlatformDarwin::FindXcodeContentsDirectoryInPath(llvm::StringRef path) {
return {};
}

llvm::StringRef PlatformDarwin::GetSDKPath(XcodeSDK sdk) {
std::string PlatformDarwin::GetSDKPath(XcodeSDK sdk) {
std::lock_guard<std::mutex> guard(m_sdk_path_mutex);
std::string &path = m_sdk_path[sdk.GetString()];
if (path.empty())
path = HostInfo::GetXcodeSDK(sdk);
return path;
if (!path.empty())
return path;
return HostInfo::GetXcodeSDK(sdk);
}

FileSpec PlatformDarwin::GetXcodeContentsDirectory() {
Expand Down
3 changes: 2 additions & 1 deletion lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ class PlatformDarwin : public PlatformPOSIX {
llvm::Expected<lldb_private::StructuredData::DictionarySP>
FetchExtendedCrashInformation(lldb_private::Process &process) override;

llvm::StringRef GetSDKPath(lldb_private::XcodeSDK sdk) override;
std::string GetSDKPath(lldb_private::XcodeSDK sdk) override;

static lldb_private::FileSpec GetXcodeContentsDirectory();
static lldb_private::FileSpec GetXcodeDeveloperDirectory();
Expand Down Expand Up @@ -172,6 +172,7 @@ class PlatformDarwin : public PlatformPOSIX {

std::string m_developer_directory;
llvm::StringMap<std::string> m_sdk_path;
std::mutex m_sdk_path_mutex;

private:
DISALLOW_COPY_AND_ASSIGN(PlatformDarwin);
Expand Down