diff --git a/clang-tools-extra/clangd/tool/ClangdMain.cpp b/clang-tools-extra/clangd/tool/ClangdMain.cpp --- a/clang-tools-extra/clangd/tool/ClangdMain.cpp +++ b/clang-tools-extra/clangd/tool/ClangdMain.cpp @@ -423,6 +423,20 @@ llvm::errs().SetBuffered(); StreamLogger Logger(llvm::errs(), LogLevel); LoggingSession LoggingSession(Logger); + // Write some initial logs before we start doing any real work. + log("{0}", clang::getClangToolFullVersion("clangd")); + { + SmallString<128> CWD; + if (auto Err = llvm::sys::fs::current_path(CWD)) + log("Working directory unknown: {0}", Err.message()); + else + log("Working directory: {0}", CWD); + } + { + std::string LoggableArgs; + for (int I = 0; I < argc; ++I) + log("argv[{0}]: {1}", I, argv[I]); + } // If --compile-commands-dir arg was invoked, check value and override default // path. @@ -501,12 +515,14 @@ std::unique_ptr TransportLayer; if (getenv("CLANGD_AS_XPC_SERVICE")) { #if CLANGD_BUILD_XPC + log("Starting LSP over XPC service"); TransportLayer = newXPCTransport(); #else llvm::errs() << "This clangd binary wasn't built with XPC support.\n"; return (int)ErrorResultCode::CantRunAsXPCService; #endif } else { + log("Starting LSP over stdin/stdout"); TransportLayer = newJSONTransport( stdin, llvm::outs(), InputMirrorStream ? InputMirrorStream.getPointer() : nullptr,