Index: lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm =================================================================== --- lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm +++ lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm @@ -381,7 +381,7 @@ args.AppendArgument("--sdk"); args.AppendArgument(sdk); - Log *log = GetLog(LLDBLog::Host); + Log *log = GetLog(LLDBLog::Host | LLDBLog::Types); if (log) { std::string cmdstr; args.GetCommandString(cmdstr); @@ -393,11 +393,21 @@ std::string output_str; lldb_private::Status error = Host::RunShellCommand(args, FileSpec(), &status, &signo, &output_str, - std::chrono::seconds(15)); + std::chrono::seconds(30)); - // Check that xcrun return something useful. - if (status != 0 || output_str.empty()) + // Check that xcrun returned something useful. + if (error.Fail()) { + LLDB_LOG(log, "xcrun failed to execute: %s", error.AsCString()); + return {}; + } + if (status != 0) { + LLDB_LOG(log, "xcrun returned exit code %d", status); return {}; + } + if (output_str.empty()) { + LLDB_LOG(log, "xcrun returned no results"); + return {}; + } // Convert to a StringRef so we can manipulate the string without modifying // the underlying data. Index: lldb/unittests/Host/HostTest.cpp =================================================================== --- lldb/unittests/Host/HostTest.cpp +++ lldb/unittests/Host/HostTest.cpp @@ -25,3 +25,16 @@ ASSERT_EQ("Host::GetEnvironment", Host::GetEnvironment().lookup("LLDB_TEST_ENVIRONMENT_VAR")); } + +#if defined(LLVM_ON_UNIX) +TEST(Host, RunShellCommand) { + std::string shell = "SHELL=" + getenv("SHELL"); + putenv(const_cast("SHELL=/bin/LLDB_TEST_this-file-does-not-exist")); + int status; + std::string out; + Status error = + Host::RunShellCommand("/usr/bin/true", FileSpec(), &status, &signo, &out); + ASSERT_TRUE(error.Fail()); + putenv(shell); +} +#endif