From 4389cb9cf1b9493ad44bbfd97fe5d54450061988 Mon Sep 17 00:00:00 2001 From: Sam McCall Date: Tue, 23 Jul 2019 14:30:28 +0000 Subject: [PATCH] [clangd] Log version, cwd, args, and transport on startup. NFC Reviewers: hokein Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D65146 llvm-svn: 366811 --- clang-tools-extra/clangd/tool/ClangdMain.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/clang-tools-extra/clangd/tool/ClangdMain.cpp b/clang-tools-extra/clangd/tool/ClangdMain.cpp index 60f1e42..7817332 100644 --- a/clang-tools-extra/clangd/tool/ClangdMain.cpp +++ b/clang-tools-extra/clangd/tool/ClangdMain.cpp @@ -423,6 +423,17 @@ int main(int argc, char *argv[]) { 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); + } + 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 +512,14 @@ int main(int argc, char *argv[]) { 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, -- 2.7.4