blob: ebf8c2ed474a6ad7ace76ae580d97327a46b6217 [file] [log] [blame]
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001//===-- lldb.cpp ------------------------------------------------*- C++ -*-===//
2//
Chandler Carruth2946cd72019-01-19 08:50:56 +00003// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
Chris Lattner30fdc8d2010-06-08 16:52:24 +00006//
7//===----------------------------------------------------------------------===//
8
9#include "lldb/lldb-private.h"
Greg Claytonfc7117a2011-03-05 01:04:56 +000010
Greg Claytonce6d19a2010-12-16 21:33:41 +000011using namespace lldb;
Chris Lattner30fdc8d2010-06-08 16:52:24 +000012using namespace lldb_private;
13
Greg Clayton7170f3f2013-02-28 18:09:18 +000014#include "clang/Basic/Version.h"
15
Petr Hosek23fdd5a2019-02-06 03:51:00 +000016#ifdef HAVE_VCS_VERSION_INC
17#include "VCSVersion.inc"
Petr Hosek12062e02019-01-31 07:12:43 +000018#endif
19
Chris Bienemanb92cfe62016-11-10 17:33:19 +000020#ifdef HAVE_APPLE_VERSION_INC
Stephane Sezer7a0c2182017-11-02 16:56:52 +000021#include "AppleVersion.inc"
Chris Bienemanb92cfe62016-11-10 17:33:19 +000022#endif
23
Kate Stoneb9c1b512016-09-06 20:57:50 +000024static const char *GetLLDBRevision() {
Greg Clayton7170f3f2013-02-28 18:09:18 +000025#ifdef LLDB_REVISION
Kate Stoneb9c1b512016-09-06 20:57:50 +000026 return LLDB_REVISION;
Greg Clayton7170f3f2013-02-28 18:09:18 +000027#else
Kate Stoneb9c1b512016-09-06 20:57:50 +000028 return NULL;
Greg Clayton7170f3f2013-02-28 18:09:18 +000029#endif
30}
31
Kate Stoneb9c1b512016-09-06 20:57:50 +000032static const char *GetLLDBRepository() {
Greg Clayton7170f3f2013-02-28 18:09:18 +000033#ifdef LLDB_REPOSITORY
Kate Stoneb9c1b512016-09-06 20:57:50 +000034 return LLDB_REPOSITORY;
Greg Clayton7170f3f2013-02-28 18:09:18 +000035#else
Kate Stoneb9c1b512016-09-06 20:57:50 +000036 return NULL;
Greg Clayton7170f3f2013-02-28 18:09:18 +000037#endif
38}
39
Chris Bieneman1778f692016-11-10 21:30:16 +000040#define QUOTE(str) #str
41#define EXPAND_AND_QUOTE(str) QUOTE(str)
42
Kate Stoneb9c1b512016-09-06 20:57:50 +000043const char *lldb_private::GetVersion() {
Kate Stoneb9c1b512016-09-06 20:57:50 +000044 // On platforms other than Darwin, report a version number in the same style
45 // as the clang tool.
46 static std::string g_version_str;
47 if (g_version_str.empty()) {
48 g_version_str += "lldb version ";
49 g_version_str += CLANG_VERSION_STRING;
Stephane Sezerb55c8b12017-11-02 16:56:19 +000050
Kate Stoneb9c1b512016-09-06 20:57:50 +000051 const char *lldb_repo = GetLLDBRepository();
Kate Stoneb9c1b512016-09-06 20:57:50 +000052 const char *lldb_rev = GetLLDBRevision();
Chris Bienemanbd3d0262016-11-14 22:43:08 +000053 if (lldb_repo || lldb_rev) {
54 g_version_str += " (";
55 if (lldb_repo)
56 g_version_str += lldb_repo;
57 if (lldb_rev) {
58 g_version_str += " revision ";
59 g_version_str += lldb_rev;
60 }
Chris Bienemanb92cfe62016-11-10 17:33:19 +000061 g_version_str += ")";
Kate Stoneb9c1b512016-09-06 20:57:50 +000062 }
Chris Bienemanbd3d0262016-11-14 22:43:08 +000063
Kate Stoneb9c1b512016-09-06 20:57:50 +000064 std::string clang_rev(clang::getClangRevision());
65 if (clang_rev.length() > 0) {
Chris Bienemanb92cfe62016-11-10 17:33:19 +000066 g_version_str += "\n clang revision ";
Kate Stoneb9c1b512016-09-06 20:57:50 +000067 g_version_str += clang_rev;
68 }
69 std::string llvm_rev(clang::getLLVMRevision());
70 if (llvm_rev.length() > 0) {
Chris Bienemanb92cfe62016-11-10 17:33:19 +000071 g_version_str += "\n llvm revision ";
Kate Stoneb9c1b512016-09-06 20:57:50 +000072 g_version_str += llvm_rev;
73 }
Kate Stoneb9c1b512016-09-06 20:57:50 +000074 }
75 return g_version_str.c_str();
Chris Lattner30fdc8d2010-06-08 16:52:24 +000076}