Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1 | //===-- lldb.cpp ------------------------------------------------*- C++ -*-===// |
| 2 | // |
Chandler Carruth | 2946cd7 | 2019-01-19 08:50:56 +0000 | [diff] [blame] | 3 | // 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 Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 6 | // |
| 7 | //===----------------------------------------------------------------------===// |
| 8 | |
| 9 | #include "lldb/lldb-private.h" |
Greg Clayton | fc7117a | 2011-03-05 01:04:56 +0000 | [diff] [blame] | 10 | |
Greg Clayton | ce6d19a | 2010-12-16 21:33:41 +0000 | [diff] [blame] | 11 | using namespace lldb; |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 12 | using namespace lldb_private; |
| 13 | |
Greg Clayton | 7170f3f | 2013-02-28 18:09:18 +0000 | [diff] [blame] | 14 | #include "clang/Basic/Version.h" |
| 15 | |
Petr Hosek | 23fdd5a | 2019-02-06 03:51:00 +0000 | [diff] [blame] | 16 | #ifdef HAVE_VCS_VERSION_INC |
| 17 | #include "VCSVersion.inc" |
Petr Hosek | 12062e0 | 2019-01-31 07:12:43 +0000 | [diff] [blame] | 18 | #endif |
| 19 | |
Chris Bieneman | b92cfe6 | 2016-11-10 17:33:19 +0000 | [diff] [blame] | 20 | #ifdef HAVE_APPLE_VERSION_INC |
Stephane Sezer | 7a0c218 | 2017-11-02 16:56:52 +0000 | [diff] [blame] | 21 | #include "AppleVersion.inc" |
Chris Bieneman | b92cfe6 | 2016-11-10 17:33:19 +0000 | [diff] [blame] | 22 | #endif |
| 23 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 24 | static const char *GetLLDBRevision() { |
Greg Clayton | 7170f3f | 2013-02-28 18:09:18 +0000 | [diff] [blame] | 25 | #ifdef LLDB_REVISION |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 26 | return LLDB_REVISION; |
Greg Clayton | 7170f3f | 2013-02-28 18:09:18 +0000 | [diff] [blame] | 27 | #else |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 28 | return NULL; |
Greg Clayton | 7170f3f | 2013-02-28 18:09:18 +0000 | [diff] [blame] | 29 | #endif |
| 30 | } |
| 31 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 32 | static const char *GetLLDBRepository() { |
Greg Clayton | 7170f3f | 2013-02-28 18:09:18 +0000 | [diff] [blame] | 33 | #ifdef LLDB_REPOSITORY |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 34 | return LLDB_REPOSITORY; |
Greg Clayton | 7170f3f | 2013-02-28 18:09:18 +0000 | [diff] [blame] | 35 | #else |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 36 | return NULL; |
Greg Clayton | 7170f3f | 2013-02-28 18:09:18 +0000 | [diff] [blame] | 37 | #endif |
| 38 | } |
| 39 | |
Chris Bieneman | 1778f69 | 2016-11-10 21:30:16 +0000 | [diff] [blame] | 40 | #define QUOTE(str) #str |
| 41 | #define EXPAND_AND_QUOTE(str) QUOTE(str) |
| 42 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 43 | const char *lldb_private::GetVersion() { |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 44 | // 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 Sezer | b55c8b1 | 2017-11-02 16:56:19 +0000 | [diff] [blame] | 50 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 51 | const char *lldb_repo = GetLLDBRepository(); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 52 | const char *lldb_rev = GetLLDBRevision(); |
Chris Bieneman | bd3d026 | 2016-11-14 22:43:08 +0000 | [diff] [blame] | 53 | 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 Bieneman | b92cfe6 | 2016-11-10 17:33:19 +0000 | [diff] [blame] | 61 | g_version_str += ")"; |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 62 | } |
Chris Bieneman | bd3d026 | 2016-11-14 22:43:08 +0000 | [diff] [blame] | 63 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 64 | std::string clang_rev(clang::getClangRevision()); |
| 65 | if (clang_rev.length() > 0) { |
Chris Bieneman | b92cfe6 | 2016-11-10 17:33:19 +0000 | [diff] [blame] | 66 | g_version_str += "\n clang revision "; |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 67 | g_version_str += clang_rev; |
| 68 | } |
| 69 | std::string llvm_rev(clang::getLLVMRevision()); |
| 70 | if (llvm_rev.length() > 0) { |
Chris Bieneman | b92cfe6 | 2016-11-10 17:33:19 +0000 | [diff] [blame] | 71 | g_version_str += "\n llvm revision "; |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 72 | g_version_str += llvm_rev; |
| 73 | } |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 74 | } |
| 75 | return g_version_str.c_str(); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 76 | } |