]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/lldb/source/lldb.cpp
MFV: r334448
[FreeBSD/FreeBSD.git] / contrib / llvm / tools / lldb / source / lldb.cpp
1 //===-- 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"
11
12 using namespace lldb;
13 using namespace lldb_private;
14
15 #include "clang/Basic/Version.h"
16
17 #ifdef HAVE_SVN_VERSION_INC
18 #include "SVNVersion.inc"
19 #endif
20
21 #ifdef HAVE_APPLE_VERSION_INC
22 #include "AppleVersion.inc"
23 #endif
24
25 static const char *GetLLDBRevision() {
26 #ifdef LLDB_REVISION
27   return LLDB_REVISION;
28 #else
29   return NULL;
30 #endif
31 }
32
33 static const char *GetLLDBRepository() {
34 #ifdef LLDB_REPOSITORY
35   return LLDB_REPOSITORY;
36 #else
37   return NULL;
38 #endif
39 }
40
41 #define QUOTE(str) #str
42 #define EXPAND_AND_QUOTE(str) QUOTE(str)
43
44 const char *lldb_private::GetVersion() {
45   // 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;
51
52     const char *lldb_repo = GetLLDBRepository();
53     const char *lldb_rev = GetLLDBRevision();
54     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       }
62       g_version_str += ")";
63     }
64
65     std::string clang_rev(clang::getClangRevision());
66     if (clang_rev.length() > 0) {
67       g_version_str += "\n  clang revision ";
68       g_version_str += clang_rev;
69     }
70     std::string llvm_rev(clang::getLLVMRevision());
71     if (llvm_rev.length() > 0) {
72       g_version_str += "\n  llvm revision ";
73       g_version_str += llvm_rev;
74     }
75   }
76   return g_version_str.c_str();
77 }