| 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 | |
| Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 20 | static const char *GetLLDBRevision() { |
| Greg Clayton | 7170f3f | 2013-02-28 18:09:18 +0000 | [diff] [blame] | 21 | #ifdef LLDB_REVISION |
| Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 22 | return LLDB_REVISION; |
| Greg Clayton | 7170f3f | 2013-02-28 18:09:18 +0000 | [diff] [blame] | 23 | #else |
| Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 24 | return NULL; |
| Greg Clayton | 7170f3f | 2013-02-28 18:09:18 +0000 | [diff] [blame] | 25 | #endif |
| 26 | } |
| 27 | |
| Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 28 | static const char *GetLLDBRepository() { |
| Greg Clayton | 7170f3f | 2013-02-28 18:09:18 +0000 | [diff] [blame] | 29 | #ifdef LLDB_REPOSITORY |
| Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 30 | return LLDB_REPOSITORY; |
| Greg Clayton | 7170f3f | 2013-02-28 18:09:18 +0000 | [diff] [blame] | 31 | #else |
| Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 32 | return NULL; |
| Greg Clayton | 7170f3f | 2013-02-28 18:09:18 +0000 | [diff] [blame] | 33 | #endif |
| 34 | } |
| 35 | |
| Chris Bieneman | 1778f69 | 2016-11-10 21:30:16 +0000 | [diff] [blame] | 36 | #define QUOTE(str) #str |
| 37 | #define EXPAND_AND_QUOTE(str) QUOTE(str) |
| 38 | |
| Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 39 | const char *lldb_private::GetVersion() { |
| Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 40 | // 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 Sezer | b55c8b1 | 2017-11-02 16:56:19 +0000 | [diff] [blame] | 46 | |
| Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 47 | const char *lldb_repo = GetLLDBRepository(); |
| Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 48 | const char *lldb_rev = GetLLDBRevision(); |
| Chris Bieneman | bd3d026 | 2016-11-14 22:43:08 +0000 | [diff] [blame] | 49 | 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 Bieneman | b92cfe6 | 2016-11-10 17:33:19 +0000 | [diff] [blame] | 57 | g_version_str += ")"; |
| Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 58 | } |
| Chris Bieneman | bd3d026 | 2016-11-14 22:43:08 +0000 | [diff] [blame] | 59 | |
| Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 60 | std::string clang_rev(clang::getClangRevision()); |
| 61 | if (clang_rev.length() > 0) { |
| Chris Bieneman | b92cfe6 | 2016-11-10 17:33:19 +0000 | [diff] [blame] | 62 | g_version_str += "\n clang revision "; |
| Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 63 | g_version_str += clang_rev; |
| 64 | } |
| 65 | std::string llvm_rev(clang::getLLVMRevision()); |
| 66 | if (llvm_rev.length() > 0) { |
| Chris Bieneman | b92cfe6 | 2016-11-10 17:33:19 +0000 | [diff] [blame] | 67 | g_version_str += "\n llvm revision "; |
| Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 68 | g_version_str += llvm_rev; |
| 69 | } |
| Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 70 | } |
| 71 | return g_version_str.c_str(); |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 72 | } |