This is an archive of the discontinued LLVM Phabricator instance.

[LLDB] Find debugserver in Command Line Tools as well
ClosedPublic

Authored by aadsm on Jul 23 2019, 4:06 PM.

Details

Summary

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.

Diff Detail

Repository
rL LLVM

Event Timeline

aadsm created this revision.Jul 23 2019, 4:06 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 23 2019, 4:06 PM

LGTM. There was another problem I was discussing with someone the other week (I can't remember exactly the details) where we'd need to retrieve the Xcode install path so this would have been needed there too.

JDevlieghere accepted this revision.Jul 24 2019, 3:28 PM
This revision is now accepted and ready to land.Jul 24 2019, 3:28 PM
clayborg accepted this revision.Jul 24 2019, 3:33 PM

Find with me as long as we default to using the installed Xcode, and then check for the command line tools if that fails. Many people keep Xcode up to date, but might not always update the installed command line tools.

aadsm added a comment.Jul 25 2019, 1:48 PM

@clayborg, yes, I made sure of that, we always first check the Xcode path.

This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptJul 25 2019, 1:54 PM