blob: c96f5d9ee7e17f54ba6d767f67900ca249f0174c [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
Kate Stoneb9c1b512016-09-06 20:57:50 +000020static const char *GetLLDBRevision() {
Greg Clayton7170f3f2013-02-28 18:09:18 +000021#ifdef LLDB_REVISION
Kate Stoneb9c1b512016-09-06 20:57:50 +000022 return LLDB_REVISION;
Greg Clayton7170f3f2013-02-28 18:09:18 +000023#else
Kate Stoneb9c1b512016-09-06 20:57:50 +000024 return NULL;
Greg Clayton7170f3f2013-02-28 18:09:18 +000025#endif
26}
27
Kate Stoneb9c1b512016-09-06 20:57:50 +000028static const char *GetLLDBRepository() {
Greg Clayton7170f3f2013-02-28 18:09:18 +000029#ifdef LLDB_REPOSITORY
Kate Stoneb9c1b512016-09-06 20:57:50 +000030 return LLDB_REPOSITORY;
Greg Clayton7170f3f2013-02-28 18:09:18 +000031#else
Kate Stoneb9c1b512016-09-06 20:57:50 +000032 return NULL;
Greg Clayton7170f3f2013-02-28 18:09:18 +000033#endif
34}
35
Chris Bieneman1778f692016-11-10 21:30:16 +000036#define QUOTE(str) #str
37#define EXPAND_AND_QUOTE(str) QUOTE(str)
38
Kate Stoneb9c1b512016-09-06 20:57:50 +000039const char *lldb_private::GetVersion() {
Kate Stoneb9c1b512016-09-06 20:57:50 +000040 // On platforms other than Darwin, report a version number in the same style
41 // as the clang tool.
42 static std::string g_version_str;
43 if (g_version_str.empty()) {
44 g_version_str += "lldb version ";
45 g_version_str += CLANG_VERSION_STRING;
Stephane Sezerb55c8b12017-11-02 16:56:19 +000046
Kate Stoneb9c1b512016-09-06 20:57:50 +000047 const char *lldb_repo = GetLLDBRepository();
Kate Stoneb9c1b512016-09-06 20:57:50 +000048 const char *lldb_rev = GetLLDBRevision();
Chris Bienemanbd3d0262016-11-14 22:43:08 +000049 if (lldb_repo || lldb_rev) {
50 g_version_str += " (";
51 if (lldb_repo)
52 g_version_str += lldb_repo;
53 if (lldb_rev) {
54 g_version_str += " revision ";
55 g_version_str += lldb_rev;
56 }
Chris Bienemanb92cfe62016-11-10 17:33:19 +000057 g_version_str += ")";
Kate Stoneb9c1b512016-09-06 20:57:50 +000058 }
Chris Bienemanbd3d0262016-11-14 22:43:08 +000059
Kate Stoneb9c1b512016-09-06 20:57:50 +000060 std::string clang_rev(clang::getClangRevision());
61 if (clang_rev.length() > 0) {
Chris Bienemanb92cfe62016-11-10 17:33:19 +000062 g_version_str += "\n clang revision ";
Kate Stoneb9c1b512016-09-06 20:57:50 +000063 g_version_str += clang_rev;
64 }
65 std::string llvm_rev(clang::getLLVMRevision());
66 if (llvm_rev.length() > 0) {
Chris Bienemanb92cfe62016-11-10 17:33:19 +000067 g_version_str += "\n llvm revision ";
Kate Stoneb9c1b512016-09-06 20:57:50 +000068 g_version_str += llvm_rev;
69 }
Kate Stoneb9c1b512016-09-06 20:57:50 +000070 }
71 return g_version_str.c_str();
Chris Lattner30fdc8d2010-06-08 16:52:24 +000072}