forked from OSchip/llvm-project
[clangd] Log feature configuration (linux+asan+grpc) of the clangd build
Included in logs, --version, remote index queries, and LSP serverInfo. Differential Revision: https://reviews.llvm.org/D100553
This commit is contained in:
parent
bb41f85691
commit
0c96a92d86
|
@ -64,6 +64,7 @@ add_clang_library(clangDaemon
|
|||
DumpAST.cpp
|
||||
ExpectedTypes.cpp
|
||||
FeatureModule.cpp
|
||||
Features.cpp
|
||||
FindSymbols.cpp
|
||||
FindTarget.cpp
|
||||
FileDistance.cpp
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
#include "Diagnostics.h"
|
||||
#include "DraftStore.h"
|
||||
#include "DumpAST.h"
|
||||
#include "Features.h"
|
||||
#include "GlobalCompilationDatabase.h"
|
||||
#include "LSPBinder.h"
|
||||
#include "Protocol.h"
|
||||
|
@ -24,7 +25,6 @@
|
|||
#include "support/MemoryTree.h"
|
||||
#include "support/Trace.h"
|
||||
#include "clang/AST/ASTContext.h"
|
||||
#include "clang/Basic/Version.h"
|
||||
#include "clang/Tooling/Core/Replacement.h"
|
||||
#include "llvm/ADT/ArrayRef.h"
|
||||
#include "llvm/ADT/Optional.h"
|
||||
|
@ -620,7 +620,8 @@ void ClangdLSPServer::onInitialize(const InitializeParams &Params,
|
|||
llvm::json::Object Result{
|
||||
{{"serverInfo",
|
||||
llvm::json::Object{{"name", "clangd"},
|
||||
{"version", getClangToolFullVersion("clangd")}}},
|
||||
{"version", llvm::formatv("{0} {1}", versionString(),
|
||||
featureString())}}},
|
||||
{"capabilities", std::move(ServerCaps)}}};
|
||||
if (Opts.Encoding)
|
||||
Result["offsetEncoding"] = *Opts.Encoding;
|
||||
|
|
|
@ -11,7 +11,6 @@
|
|||
|
||||
#include "ClangdServer.h"
|
||||
#include "DraftStore.h"
|
||||
#include "Features.inc"
|
||||
#include "FindSymbols.h"
|
||||
#include "GlobalCompilationDatabase.h"
|
||||
#include "LSPBinder.h"
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
#include "ConfigFragment.h"
|
||||
#include "ConfigProvider.h"
|
||||
#include "Diagnostics.h"
|
||||
#include "Features.inc"
|
||||
#include "Features.h"
|
||||
#include "TidyProvider.h"
|
||||
#include "support/Logger.h"
|
||||
#include "support/Path.h"
|
||||
|
|
|
@ -0,0 +1,55 @@
|
|||
//===--- Features.cpp - Compile-time configuration ------------------------===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "Features.h"
|
||||
#include "clang/Basic/Version.h"
|
||||
#include "llvm/Support/Compiler.h"
|
||||
|
||||
namespace clang {
|
||||
namespace clangd {
|
||||
|
||||
std::string versionString() { return clang::getClangToolFullVersion("clangd"); }
|
||||
|
||||
std::string featureString() {
|
||||
return
|
||||
#if defined(_WIN32)
|
||||
"windows"
|
||||
#elif defined(__APPLE__)
|
||||
"mac"
|
||||
#elif defined(__linux__)
|
||||
"linux"
|
||||
#elif defined(LLVM_ON_UNIX)
|
||||
"unix"
|
||||
#else
|
||||
"unknown"
|
||||
#endif
|
||||
|
||||
#ifndef NDEBUG
|
||||
"+debug"
|
||||
#endif
|
||||
#if LLVM_ADDRESS_SANITIZER_BUILD
|
||||
"+asan"
|
||||
#endif
|
||||
#if LLVM_THREAD_SANITIZER_BUILD
|
||||
"+tsan"
|
||||
#endif
|
||||
#if LLVM_MEMORY_SANITIZER_BUILD
|
||||
"+msan"
|
||||
#endif
|
||||
|
||||
#if CLANGD_ENABLE_REMOTE
|
||||
"+grpc"
|
||||
#endif
|
||||
#if CLANGD_BUILD_XPC
|
||||
"+xpc"
|
||||
#endif
|
||||
;
|
||||
}
|
||||
|
||||
} // namespace clangd
|
||||
} // namespace clang
|
|
@ -0,0 +1,29 @@
|
|||
//===--- Features.h - Compile-time configuration ------------------*-C++-*-===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_FEATURES_H
|
||||
#define LLVM_CLANG_TOOLS_EXTRA_CLANGD_FEATURES_H
|
||||
#include <string>
|
||||
|
||||
// Export constants like CLANGD_BUILD_XPC
|
||||
#include "Features.inc"
|
||||
|
||||
namespace clang {
|
||||
namespace clangd {
|
||||
|
||||
// Returns a version string for clangd, e.g. "clangd 10.0.0"
|
||||
std::string versionString();
|
||||
|
||||
// Returns a string describing the compile-time configuration.
|
||||
// e.g. mac+debug+asan+grpc
|
||||
std::string featureString();
|
||||
|
||||
} // namespace clangd
|
||||
} // namespace clang
|
||||
|
||||
#endif
|
|
@ -1,3 +1,4 @@
|
|||
// IWYU pragma: private, include "Features.h"
|
||||
#define CLANGD_BUILD_XPC @CLANGD_BUILD_XPC@
|
||||
#define CLANGD_ENABLE_REMOTE @CLANGD_ENABLE_REMOTE@
|
||||
#define ENABLE_GRPC_REFLECTION @ENABLE_GRPC_REFLECTION@
|
||||
|
|
|
@ -9,12 +9,12 @@
|
|||
#include <grpc++/grpc++.h>
|
||||
|
||||
#include "Client.h"
|
||||
#include "Features.h"
|
||||
#include "Service.grpc.pb.h"
|
||||
#include "index/Index.h"
|
||||
#include "marshalling/Marshalling.h"
|
||||
#include "support/Logger.h"
|
||||
#include "support/Trace.h"
|
||||
#include "clang/Basic/Version.h"
|
||||
#include "llvm/ADT/SmallString.h"
|
||||
#include "llvm/ADT/StringRef.h"
|
||||
#include "llvm/Support/Error.h"
|
||||
|
@ -72,7 +72,8 @@ class IndexClient : public clangd::SymbolIndex {
|
|||
const auto RPCRequest = ProtobufMarshaller->toProtobuf(Request);
|
||||
SPAN_ATTACH(Tracer, "Request", RPCRequest.DebugString());
|
||||
grpc::ClientContext Context;
|
||||
Context.AddMetadata("version", clang::getClangToolFullVersion("clangd"));
|
||||
Context.AddMetadata("version", versionString());
|
||||
Context.AddMetadata("features", featureString());
|
||||
std::chrono::system_clock::time_point StartTime =
|
||||
std::chrono::system_clock::now();
|
||||
auto Deadline = StartTime + DeadlineWaitingTime;
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "Features.inc"
|
||||
#include "Features.h"
|
||||
#include "Index.pb.h"
|
||||
#include "MonitoringService.grpc.pb.h"
|
||||
#include "MonitoringService.pb.h"
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
#include "CodeComplete.h"
|
||||
#include "Config.h"
|
||||
#include "ConfigProvider.h"
|
||||
#include "Features.inc"
|
||||
#include "Features.h"
|
||||
#include "PathMapping.h"
|
||||
#include "Protocol.h"
|
||||
#include "TidyProvider.h"
|
||||
|
@ -26,7 +26,6 @@
|
|||
#include "support/Shutdown.h"
|
||||
#include "support/ThreadsafeFS.h"
|
||||
#include "support/Trace.h"
|
||||
#include "clang/Basic/Version.h"
|
||||
#include "clang/Format/Format.h"
|
||||
#include "llvm/ADT/Optional.h"
|
||||
#include "llvm/ADT/SmallString.h"
|
||||
|
@ -679,7 +678,8 @@ int main(int argc, char *argv[]) {
|
|||
llvm::sys::PrintStackTraceOnErrorSignal(argv[0]);
|
||||
llvm::sys::SetInterruptFunction(&requestShutdown);
|
||||
llvm::cl::SetVersionPrinter([](llvm::raw_ostream &OS) {
|
||||
OS << clang::getClangToolFullVersion("clangd") << "\n";
|
||||
OS << versionString() << "\n"
|
||||
<< "Features: " << featureString() << "\n";
|
||||
});
|
||||
const char *FlagsEnvVar = "CLANGD_FLAGS";
|
||||
const char *Overview =
|
||||
|
@ -784,7 +784,8 @@ clangd accepts flags on the commandline, and in the CLANGD_FLAGS environment var
|
|||
StreamLogger Logger(llvm::errs(), LogLevel);
|
||||
LoggingSession LoggingSession(Logger);
|
||||
// Write some initial logs before we start doing any real work.
|
||||
log("{0}", clang::getClangToolFullVersion("clangd"));
|
||||
log("{0}", versionString());
|
||||
log("Features: {0}", featureString());
|
||||
log("PID: {0}", llvm::sys::Process::getProcessId());
|
||||
{
|
||||
SmallString<128> CWD;
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
#include "Config.h"
|
||||
#include "ConfigFragment.h"
|
||||
#include "ConfigTesting.h"
|
||||
#include "Features.inc"
|
||||
#include "Features.h"
|
||||
#include "TestFS.h"
|
||||
#include "clang/Basic/DiagnosticSema.h"
|
||||
#include "llvm/ADT/None.h"
|
||||
|
|
Loading…
Reference in New Issue