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 42 #define QUOTE(str) #str 43 #define EXPAND_AND_QUOTE(str) QUOTE(str) 44 45 const char *lldb_private::GetVersion() { 46 // On platforms other than Darwin, report a version number in the same style 47 // as the clang tool. 48 static std::string g_version_str; 49 if (g_version_str.empty()) { 50 51 #ifdef LLDB_VERSION_STRING 52 g_version_str += EXPAND_AND_QUOTE(LLDB_VERSION_STRING); 53 #else 54 g_version_str += "lldb version "; 55 g_version_str += CLANG_VERSION_STRING; 56 #endif 57 const char *lldb_repo = GetLLDBRepository(); 58 const char *lldb_rev = GetLLDBRevision(); 59 if (lldb_repo || lldb_rev) { 60 g_version_str += " ("; 61 if (lldb_repo) 62 g_version_str += lldb_repo; 63 if (lldb_rev) { 64 g_version_str += " revision "; 65 g_version_str += lldb_rev; 66 } 67 g_version_str += ")"; 68 } 69 70 std::string clang_rev(clang::getClangRevision()); 71 if (clang_rev.length() > 0) { 72 g_version_str += "\n clang revision "; 73 g_version_str += clang_rev; 74 } 75 std::string llvm_rev(clang::getLLVMRevision()); 76 if (llvm_rev.length() > 0) { 77 g_version_str += "\n llvm revision "; 78 g_version_str += llvm_rev; 79 } 80 81 } 82 return g_version_str.c_str(); 83 } 84