blob: 1be04619777005039abde0a13f4c1a81e56595b2 [file] [log] [blame]
Chris Lattner30fdc8d2010-06-08 16:52:241//===-- lldb.cpp ------------------------------------------------*- C++ -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9
10#include "lldb/lldb-private.h"
Greg Claytonfc7117a2011-03-05 01:04:5611
Greg Claytonce6d19a2010-12-16 21:33:4112using namespace lldb;
Chris Lattner30fdc8d2010-06-08 16:52:2413using namespace lldb_private;
14
Greg Clayton7170f3f2013-02-28 18:09:1815#include "clang/Basic/Version.h"
16
Chris Bienemanaa098de2016-09-23 23:33:5217#ifdef HAVE_SVN_VERSION_INC
Stephane Sezer7a0c2182017-11-02 16:56:5218#include "SVNVersion.inc"
Chris Bienemanaa098de2016-09-23 23:33:5219#endif
20
Chris Bienemanb92cfe62016-11-10 17:33:1921#ifdef HAVE_APPLE_VERSION_INC
Stephane Sezer7a0c2182017-11-02 16:56:5222#include "AppleVersion.inc"
Chris Bienemanb92cfe62016-11-10 17:33:1923#endif
24
Kate Stoneb9c1b512016-09-06 20:57:5025static const char *GetLLDBRevision() {
Greg Clayton7170f3f2013-02-28 18:09:1826#ifdef LLDB_REVISION
Kate Stoneb9c1b512016-09-06 20:57:5027 return LLDB_REVISION;
Greg Clayton7170f3f2013-02-28 18:09:1828#else
Kate Stoneb9c1b512016-09-06 20:57:5029 return NULL;
Greg Clayton7170f3f2013-02-28 18:09:1830#endif
31}
32
Kate Stoneb9c1b512016-09-06 20:57:5033static const char *GetLLDBRepository() {
Greg Clayton7170f3f2013-02-28 18:09:1834#ifdef LLDB_REPOSITORY
Kate Stoneb9c1b512016-09-06 20:57:5035 return LLDB_REPOSITORY;
Greg Clayton7170f3f2013-02-28 18:09:1836#else
Kate Stoneb9c1b512016-09-06 20:57:5037 return NULL;
Greg Clayton7170f3f2013-02-28 18:09:1838#endif
39}
40
Chris Bieneman1778f692016-11-10 21:30:1641#define QUOTE(str) #str
42#define EXPAND_AND_QUOTE(str) QUOTE(str)
43
Kate Stoneb9c1b512016-09-06 20:57:5044const char *lldb_private::GetVersion() {
Kate Stoneb9c1b512016-09-06 20:57:5045 // On platforms other than Darwin, report a version number in the same style
46 // as the clang tool.
47 static std::string g_version_str;
48 if (g_version_str.empty()) {
49 g_version_str += "lldb version ";
50 g_version_str += CLANG_VERSION_STRING;
Stephane Sezerb55c8b12017-11-02 16:56:1951
Kate Stoneb9c1b512016-09-06 20:57:5052 const char *lldb_repo = GetLLDBRepository();
Kate Stoneb9c1b512016-09-06 20:57:5053 const char *lldb_rev = GetLLDBRevision();
Chris Bienemanbd3d0262016-11-14 22:43:0854 if (lldb_repo || lldb_rev) {
55 g_version_str += " (";
56 if (lldb_repo)
57 g_version_str += lldb_repo;
58 if (lldb_rev) {
59 g_version_str += " revision ";
60 g_version_str += lldb_rev;
61 }
Chris Bienemanb92cfe62016-11-10 17:33:1962 g_version_str += ")";
Kate Stoneb9c1b512016-09-06 20:57:5063 }
Chris Bienemanbd3d0262016-11-14 22:43:0864
Kate Stoneb9c1b512016-09-06 20:57:5065 std::string clang_rev(clang::getClangRevision());
66 if (clang_rev.length() > 0) {
Chris Bienemanb92cfe62016-11-10 17:33:1967 g_version_str += "\n clang revision ";
Kate Stoneb9c1b512016-09-06 20:57:5068 g_version_str += clang_rev;
69 }
70 std::string llvm_rev(clang::getLLVMRevision());
71 if (llvm_rev.length() > 0) {
Chris Bienemanb92cfe62016-11-10 17:33:1972 g_version_str += "\n llvm revision ";
Kate Stoneb9c1b512016-09-06 20:57:5073 g_version_str += llvm_rev;
74 }
Kate Stoneb9c1b512016-09-06 20:57:5075 }
76 return g_version_str.c_str();
Chris Lattner30fdc8d2010-06-08 16:52:2477}