]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/lldb/source/lldb.cpp
Merge lldb trunk r366426, resolve conflicts, and update FREEBSD-Xlist.
[FreeBSD/FreeBSD.git] / contrib / llvm / tools / lldb / source / lldb.cpp
1 //===-- lldb.cpp ------------------------------------------------*- C++ -*-===//
2 //
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
6 //
7 //===----------------------------------------------------------------------===//
8
9 #include "lldb/lldb-private.h"
10
11 using namespace lldb;
12 using namespace lldb_private;
13
14 #include "clang/Basic/Version.h"
15
16 #ifdef HAVE_VCS_VERSION_INC
17 #include "VCSVersion.inc"
18 #endif
19
20 static const char *GetLLDBRevision() {
21 #ifdef LLDB_REVISION
22   return LLDB_REVISION;
23 #else
24   return NULL;
25 #endif
26 }
27
28 static const char *GetLLDBRepository() {
29 #ifdef LLDB_REPOSITORY
30   return LLDB_REPOSITORY;
31 #else
32   return NULL;
33 #endif
34 }
35
36 #define QUOTE(str) #str
37 #define EXPAND_AND_QUOTE(str) QUOTE(str)
38
39 const char *lldb_private::GetVersion() {
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;
46
47     const char *lldb_repo = GetLLDBRepository();
48     const char *lldb_rev = GetLLDBRevision();
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       }
57       g_version_str += ")";
58     }
59
60     std::string clang_rev(clang::getClangRevision());
61     if (clang_rev.length() > 0) {
62       g_version_str += "\n  clang revision ";
63       g_version_str += clang_rev;
64     }
65     std::string llvm_rev(clang::getLLVMRevision());
66     if (llvm_rev.length() > 0) {
67       g_version_str += "\n  llvm revision ";
68       g_version_str += llvm_rev;
69     }
70   }
71   return g_version_str.c_str();
72 }