[Lldb-commits] [lldb] r176268 - Remove LLDB dependency on xcodeworkspace (on Linux) for version number
Daniel Malea
daniel.malea at intel.com
Thu Feb 28 08:51:16 PST 2013
Author: dmalea
Date: Thu Feb 28 10:51:15 2013
New Revision: 176268
URL: http://llvm.org/viewvc/llvm-project?rev=176268&view=rev
Log:
Remove LLDB dependency on xcodeworkspace (on Linux) for version number
- make LLDB version number match Clang (and the Debian package)
- use the same revision detection magic that Clang uses to report SVN/Git revisions
- update test case as per above
Example output:
$ lldb -v
lldb version 3.3 (https://dmalea@llvm.org/svn/llvm-project/lldb/trunk revision 176211 clang revision 176208 llvm revision 176208)
ss
This line, and those below, will be ignored--
M source/lldb.cpp
M test/help/TestHelp.py
M source/Makefile
Modified:
lldb/trunk/source/Makefile
lldb/trunk/source/lldb.cpp
lldb/trunk/test/help/TestHelp.py
Modified: lldb/trunk/source/Makefile
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Makefile?rev=176268&r1=176267&r2=176268&view=diff
==============================================================================
--- lldb/trunk/source/Makefile (original)
+++ lldb/trunk/source/Makefile Thu Feb 28 10:51:15 2013
@@ -12,10 +12,26 @@ DIRS := API Breakpoint Commands Core Dat
LIBRARYNAME := lldbInitAndLog
BUILD_ARCHIVE = 1
+# Although LLVM makefiles provide $(HOST_OS), we cannot use that here because it is defined by including the $(LLDB_LEVEL)/Makefile
+# below. Instead, we use uname -s to detect the HOST_OS and generate LLDB_vers.c only on Mac. On Linux, the version number is
+# calculated in the same way as Clang's version.
+ifeq (Darwin,$(shell uname -s))
BUILT_SOURCES = LLDB_vers.c
+endif
+
SOURCES := lldb-log.cpp lldb.cpp
include $(LLDB_LEVEL)/Makefile
+ifeq ($(HOST_OS),Darwin)
LLDB_vers.c: $(PROJ_SRC_DIR)/$(LLDB_LEVEL)/scripts/generate-vers.pl $(PROJ_SRC_DIR)/$(LLDB_LEVEL)/lldb.xcodeproj/project.pbxproj
"$(PROJ_SRC_DIR)/$(LLDB_LEVEL)/scripts/generate-vers.pl" "$(PROJ_SRC_DIR)/$(LLDB_LEVEL)/lldb.xcodeproj/project.pbxproj" > LLDB_vers.c
+else
+LLDB_REVISION := $(strip \
+ $(shell $(LLVM_SRC_ROOT)/utils/GetSourceVersion $(LLVM_SRC_ROOT)/tools/lldb))
+
+LLDB_REPOSITORY := $(strip \
+ $(shell $(LLVM_SRC_ROOT)/utils/GetRepositoryPath $(LLVM_SRC_ROOT)/tools/lldb))
+
+CPP.Defines += -DLLDB_REVISION='"$(LLDB_REVISION)"' -DLLDB_REPOSITORY='"$(LLDB_REPOSITORY)"'
+endif
Modified: lldb/trunk/source/lldb.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/lldb.cpp?rev=176268&r1=176267&r2=176268&view=diff
==============================================================================
--- lldb/trunk/source/lldb.cpp (original)
+++ lldb/trunk/source/lldb.cpp Thu Feb 28 10:51:15 2013
@@ -7,6 +7,8 @@
//
//===----------------------------------------------------------------------===//
+#include "clang/Basic/Version.h"
+
#include "lldb/lldb-python.h"
#include "lldb/lldb-private.h"
@@ -23,6 +25,7 @@
#include "lldb/Target/Thread.h"
#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/raw_ostream.h"
#include "Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.h"
#include "Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.h"
@@ -77,6 +80,26 @@
using namespace lldb;
using namespace lldb_private;
+namespace {
+
+std::string getLLDBRevision() {
+#ifdef LLDB_REVISION
+ return LLDB_REVISION;
+#else
+ return "";
+#endif
+}
+
+std::string getLLDBRepository() {
+#ifdef LLDB_REPOSITORY
+ return LLDB_REPOSITORY;
+#else
+ return "";
+#endif
+}
+
+}
+
void
lldb_private::Initialize ()
{
@@ -224,15 +247,47 @@ lldb_private::Terminate ()
Log::Terminate();
}
+
+#if defined (__APPLE__)
extern "C" const double liblldb_coreVersionNumber;
+#endif
+
const char *
lldb_private::GetVersion ()
{
+#if defined (__APPLE__)
static char g_version_string[32];
if (g_version_string[0] == '\0')
::snprintf (g_version_string, sizeof(g_version_string), "LLDB-%g", liblldb_coreVersionNumber);
return g_version_string;
+#else
+ // On Linux/FreeBSD/Windows, report a version number in the same style as the clang tool.
+ static std::string buf;
+ llvm::raw_string_ostream OS(buf);
+ OS << "lldb version " CLANG_VERSION_STRING " ";
+
+ std::string lldb_repo = getLLDBRepository();
+ if (lldb_repo.length() > 0)
+ OS << "(" << lldb_repo;
+
+ std::string lldb_rev = getLLDBRevision();
+ if (lldb_rev.length() > 0)
+ OS << " revision " << lldb_rev;
+
+ std::string clang_rev = clang::getClangRevision();
+ if (clang_rev.length() > 0)
+ OS << " clang revision " << clang_rev;
+
+ std::string llvm_rev = clang::getLLVMRevision();
+ if (llvm_rev.length() > 0)
+ OS << " llvm revision " << llvm_rev;
+
+ if (lldb_repo.length() > 0)
+ OS << ")";
+
+ return OS.str().c_str();
+#endif
}
const char *
Modified: lldb/trunk/test/help/TestHelp.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/help/TestHelp.py?rev=176268&r1=176267&r2=176268&view=diff
==============================================================================
--- lldb/trunk/test/help/TestHelp.py (original)
+++ lldb/trunk/test/help/TestHelp.py Thu Feb 28 10:51:15 2013
@@ -77,8 +77,13 @@ class HelpCommandTestCase(TestBase):
version_str = self.version_number_string()
import re
match = re.match('[0-9]+', version_str)
+ if sys.platform.startswith("darwin"):
+ search_regexp = ['LLDB-' + (version_str if match else '[0-9]+')]
+ else:
+ search_regexp = ['lldb version (\d|\.)+.*$']
+
self.expect("version",
- patterns = ['LLDB-' + (version_str if match else '[0-9]+')])
+ patterns = search_regexp)
def test_help_should_not_crash_lldb(self):
"""Command 'help disasm' should not crash lldb."""
More information about the lldb-commits
mailing list