This might be an edge case in regular use but if you're shipping an lldb version with no debugserver lldb will try to use the System one.
However, lldb only knows how to find the Xcode one and not the Command Line Tools one. This diff fixes that.
We try to find debugserver with PlatformDarwin::LocateExecutable("debugserver"), we call xcode-select -p to get the path and then assume this path is of Xcode.
The changes I did are:
- Change PlatformDarwin::LocateExecutable to also add the Command Line Tools directory to the list of paths to search for debugserver.
- Created a new function to find the Command Line Tools directory named GetCommandLineToolsLibraryPath.
- Refactored the code that calls xcode-select -p into its own function GetXcodeSelectPath(). There were 2 identical pieces of code for this so I reduced it to one and used this function everywhere instead.
- I also changed PlatformDarwin::GetSDKDirectoryForModules to use the SDKs directory that exists in the Command Line Tools installation.
I'm not sure how to create tests for this. PlatformDarwinTest is really limited and I couldn't find how to mock Filesystem::Instance() so I could create a virtual file system.