Index: lldb/include/lldb/Basic/Version.h =================================================================== --- /dev/null +++ lldb/include/lldb/Basic/Version.h @@ -0,0 +1,23 @@ +//===-- Version.h -----------------------------------------------*- 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 LLDB_BASIC_VERSION_H +#define LLDB_BASIC_VERSION_H + +#include + +namespace lldb_private { + +/// Retrieves a string representing the complete LLDB version, which includes +/// the lldb version number, as well as embedded compiler versions and the +/// vendor tag. +const char *GetVersion(); + +} // namespace lldb_private + +#endif // LLDB_BASIC_VERSION_H Index: lldb/include/lldb/Basic/Version.inc.in =================================================================== --- /dev/null +++ lldb/include/lldb/Basic/Version.inc.in @@ -0,0 +1,6 @@ +#define LLDB_VERSION @LLDB_VERSION@ +#define LLDB_VERSION_STRING "@LLDB_VERSION@" +#define LLDB_VERSION_MAJOR @LLDB_VERSION_MAJOR@ +#define LLDB_VERSION_MINOR @LLDB_VERSION_MINOR@ +#define LLDB_VERSION_PATCHLEVEL @LLDB_VERSION_PATCHLEVEL@ +#cmakedefine LLDB_FULL_VERSION_STRING "@LLDB_FULL_VERSION_STRING@" Index: lldb/include/lldb/lldb-private.h =================================================================== --- lldb/include/lldb/lldb-private.h +++ lldb/include/lldb/lldb-private.h @@ -17,12 +17,6 @@ #include "lldb/lldb-private-types.h" #include "lldb/lldb-public.h" -namespace lldb_private { - -const char *GetVersion(); - -} // namespace lldb_private - #endif // defined(__cplusplus) #endif // LLDB_LLDB_PRIVATE_H Index: lldb/source/API/CMakeLists.txt =================================================================== --- lldb/source/API/CMakeLists.txt +++ lldb/source/API/CMakeLists.txt @@ -94,7 +94,7 @@ ${lldb_lua_wrapper} LINK_LIBS - lldbBase + lldbBasic lldbBreakpoint lldbCore lldbDataFormatters Index: lldb/source/API/SBDebugger.cpp =================================================================== --- lldb/source/API/SBDebugger.cpp +++ lldb/source/API/SBDebugger.cpp @@ -11,8 +11,6 @@ #include "lldb/API/SBDebugger.h" -#include "lldb/lldb-private.h" - #include "lldb/API/SBBroadcaster.h" #include "lldb/API/SBCommandInterpreter.h" #include "lldb/API/SBCommandInterpreterRunOptions.h" @@ -36,6 +34,7 @@ #include "lldb/API/SBTypeSummary.h" #include "lldb/API/SBTypeSynthetic.h" +#include "lldb/Basic/Version.h" #include "lldb/Core/Debugger.h" #include "lldb/Core/PluginManager.h" #include "lldb/Core/Progress.h" Index: lldb/source/API/SBReproducer.cpp =================================================================== --- lldb/source/API/SBReproducer.cpp +++ lldb/source/API/SBReproducer.cpp @@ -22,8 +22,8 @@ #include "lldb/API/SBFileSpec.h" #include "lldb/API/SBHostOS.h" #include "lldb/API/SBReproducer.h" +#include "lldb/Basic/Version.h" #include "lldb/Host/FileSystem.h" -#include "lldb/lldb-private.h" using namespace lldb; using namespace lldb_private; Index: lldb/source/Basic/CMakeLists.txt =================================================================== --- /dev/null +++ lldb/source/Basic/CMakeLists.txt @@ -0,0 +1,42 @@ +if(LLDB_VERSION_STRING) + set(LLDB_FULL_VERSION_STRING LLDB_VERSION_STRING) +endif() + +# Configure the VCSVersion.inc file. +set(vcs_version_inc "${CMAKE_CURRENT_BINARY_DIR}/VCSVersion.inc") +set(generate_vcs_version_script "${LLVM_CMAKE_DIR}/GenerateVersionFromVCS.cmake") + +find_first_existing_vc_file("${LLDB_SOURCE_DIR}" lldb_vc) + +if(lldb_vc AND LLVM_APPEND_VC_REV) + set(lldb_source_dir ${LLDB_SOURCE_DIR}) +endif() + +add_custom_command(OUTPUT "${vcs_version_inc}" + DEPENDS "${lldb_vc}" "${generate_vcs_version_script}" + COMMAND ${CMAKE_COMMAND} "-DNAMES=LLDB" + "-DLLDB_SOURCE_DIR=${lldb_source_dir}" + "-DHEADER_FILE=${vcs_version_inc}" + -P "${generate_vcs_version_script}") + +set_source_files_properties("${vcs_version_inc}" + PROPERTIES GENERATED TRUE + HEADER_FILE_ONLY TRUE) + +# Configure the Version.inc file. +set(version_inc "${CMAKE_CURRENT_BINARY_DIR}/Version.inc") + +configure_file( + ${LLDB_SOURCE_DIR}/include/lldb/Basic/Version.inc.in + ${version_inc}) + +set_source_files_properties("${version_inc}" + PROPERTIES GENERATED TRUE + HEADER_FILE_ONLY TRUE) + +include_directories(${CMAKE_CURRENT_BINARY_DIR}) + +add_lldb_library(lldbBasic + Version.cpp + ${vcs_version_inc} + ${version_inc}) Index: lldb/source/Basic/Version.cpp =================================================================== --- lldb/source/Basic/Version.cpp +++ lldb/source/Basic/Version.cpp @@ -1,4 +1,4 @@ -//===-- lldb.cpp ----------------------------------------------------------===// +//===-- Version.cpp -------------------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -6,21 +6,14 @@ // //===----------------------------------------------------------------------===// +#include "lldb/Basic/Version.h" #include "VCSVersion.inc" -#include "lldb/lldb-private.h" +#include "Version.inc" #include "clang/Basic/Version.h" -using namespace lldb; -using namespace lldb_private; - -// LLDB_VERSION_STRING is set through a define so unlike the other defines -// expanded with CMake, it lacks the double quotes. -#define QUOTE(str) #str -#define EXPAND_AND_QUOTE(str) QUOTE(str) - static const char *GetLLDBVersion() { -#ifdef LLDB_VERSION_STRING - return EXPAND_AND_QUOTE(LLDB_VERSION_STRING); +#ifdef LLDB_FULL_VERSION_STRING + return LLDB_FULL_VERSION_STRING; #else return "lldb version " CLANG_VERSION_STRING; #endif @@ -30,7 +23,7 @@ #ifdef LLDB_REVISION return LLDB_REVISION; #else - return NULL; + return nullptr; #endif } @@ -38,12 +31,13 @@ #ifdef LLDB_REPOSITORY return LLDB_REPOSITORY; #else - return NULL; + return nullptr; #endif } const char *lldb_private::GetVersion() { static std::string g_version_str; + if (g_version_str.empty()) { const char *lldb_version = GetLLDBVersion(); const char *lldb_repo = GetLLDBRepository(); @@ -67,11 +61,13 @@ g_version_str += "\n clang revision "; g_version_str += clang_rev; } + std::string llvm_rev(clang::getLLVMRevision()); if (llvm_rev.length() > 0) { g_version_str += "\n llvm revision "; g_version_str += llvm_rev; } } + return g_version_str.c_str(); } Index: lldb/source/CMakeLists.txt =================================================================== --- lldb/source/CMakeLists.txt +++ lldb/source/CMakeLists.txt @@ -1,42 +1,6 @@ include_directories(.) -set(lldbBase_SOURCES - lldb.cpp - ) - - -find_first_existing_vc_file("${LLDB_SOURCE_DIR}" lldb_vc) - -set(version_inc "${CMAKE_CURRENT_BINARY_DIR}/VCSVersion.inc") -set(generate_vcs_version_script "${LLVM_CMAKE_DIR}/GenerateVersionFromVCS.cmake") - -if(lldb_vc AND LLVM_APPEND_VC_REV) - set(lldb_source_dir ${LLDB_SOURCE_DIR}) -endif() - -add_custom_command(OUTPUT "${version_inc}" - DEPENDS "${lldb_vc}" "${generate_vcs_version_script}" - COMMAND ${CMAKE_COMMAND} "-DNAMES=LLDB" - "-DLLDB_SOURCE_DIR=${lldb_source_dir}" - "-DHEADER_FILE=${version_inc}" - -P "${generate_vcs_version_script}") - -# Mark the generated header as being generated. -set_source_files_properties("${version_inc}" - PROPERTIES GENERATED TRUE - HEADER_FILE_ONLY TRUE) - -list(APPEND lldbBase_SOURCES ${version_inc}) - -if(LLDB_VERSION_STRING) - set_property(SOURCE lldb.cpp APPEND PROPERTY - COMPILE_DEFINITIONS "LLDB_VERSION_STRING=${LLDB_VERSION_STRING}") -endif() - -add_lldb_library(lldbBase - ${lldbBase_SOURCES} - ) - +add_subdirectory(Basic) add_subdirectory(Breakpoint) add_subdirectory(Commands) add_subdirectory(Core) Index: lldb/source/Commands/CMakeLists.txt =================================================================== --- lldb/source/Commands/CMakeLists.txt +++ lldb/source/Commands/CMakeLists.txt @@ -41,7 +41,7 @@ CommandOptionsProcessLaunch.cpp LINK_LIBS - lldbBase + lldbBasic lldbBreakpoint lldbCore lldbDataFormatters Index: lldb/source/Commands/CommandObjectVersion.cpp =================================================================== --- lldb/source/Commands/CommandObjectVersion.cpp +++ lldb/source/Commands/CommandObjectVersion.cpp @@ -8,8 +8,8 @@ #include "CommandObjectVersion.h" +#include "lldb/Basic/Version.h" #include "lldb/Interpreter/CommandReturnObject.h" -#include "lldb/lldb-private.h" using namespace lldb; using namespace lldb_private; Index: lldb/source/Initialization/SystemInitializerCommon.cpp =================================================================== --- lldb/source/Initialization/SystemInitializerCommon.cpp +++ lldb/source/Initialization/SystemInitializerCommon.cpp @@ -9,13 +9,13 @@ #include "lldb/Initialization/SystemInitializerCommon.h" #include "Plugins/Process/gdb-remote/ProcessGDBRemoteLog.h" +#include "lldb/Basic/Version.h" #include "lldb/Host/FileSystem.h" #include "lldb/Host/Host.h" #include "lldb/Host/Socket.h" #include "lldb/Utility/Log.h" #include "lldb/Utility/ReproducerProvider.h" #include "lldb/Utility/Timer.h" -#include "lldb/lldb-private.h" #if defined(__linux__) || defined(__FreeBSD__) || defined(__NetBSD__) #include "Plugins/Process/POSIX/ProcessPOSIXLog.h" Index: lldb/tools/lldb-server/CMakeLists.txt =================================================================== --- lldb/tools/lldb-server/CMakeLists.txt +++ lldb/tools/lldb-server/CMakeLists.txt @@ -46,7 +46,7 @@ SystemInitializerLLGS.cpp LINK_LIBS - lldbBase + lldbBasic lldbHost lldbInitialization ${LLDB_PLUGINS} Index: lldb/tools/lldb-server/lldb-server.cpp =================================================================== --- lldb/tools/lldb-server/lldb-server.cpp +++ lldb/tools/lldb-server/lldb-server.cpp @@ -7,8 +7,8 @@ //===----------------------------------------------------------------------===// #include "SystemInitializerLLGS.h" +#include "lldb/Basic/Version.h" #include "lldb/Initialization/SystemLifetimeManager.h" -#include "lldb/lldb-private.h" #include "llvm/ADT/STLExtras.h" #include "llvm/ADT/StringRef.h" Index: lldb/tools/lldb-test/CMakeLists.txt =================================================================== --- lldb/tools/lldb-test/CMakeLists.txt +++ lldb/tools/lldb-test/CMakeLists.txt @@ -6,7 +6,7 @@ SystemInitializerTest.cpp LINK_LIBS - lldbBase + lldbBasic lldbBreakpoint lldbCore lldbDataFormatters