[Lldb-commits] [lldb] r122515 - in /lldb/trunk: lldb.xcodeproj/project.pbxproj source/Commands/CommandObjectVersion.cpp source/Commands/CommandObjectVersion.h source/Interpreter/CommandInterpreter.cpp test/help/TestHelp.py

Johnny Chen johnny.chen at apple.com
Thu Dec 23 12:21:44 PST 2010


Author: johnny
Date: Thu Dec 23 14:21:44 2010
New Revision: 122515

URL: http://llvm.org/viewvc/llvm-project?rev=122515&view=rev
Log:
Add a simple command: 'version' to the command interpreter, and an accompanying
test case test_help_version().

Added:
    lldb/trunk/source/Commands/CommandObjectVersion.cpp
    lldb/trunk/source/Commands/CommandObjectVersion.h
Modified:
    lldb/trunk/lldb.xcodeproj/project.pbxproj
    lldb/trunk/source/Interpreter/CommandInterpreter.cpp
    lldb/trunk/test/help/TestHelp.py

Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=122515&r1=122514&r2=122515&view=diff
==============================================================================
--- lldb/trunk/lldb.xcodeproj/project.pbxproj (original)
+++ lldb/trunk/lldb.xcodeproj/project.pbxproj Thu Dec 23 14:21:44 2010
@@ -377,6 +377,7 @@
 		AF68D2561255416E002FF25B /* RegisterContextLLDB.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AF68D2541255416E002FF25B /* RegisterContextLLDB.cpp */; };
 		AF68D3311255A111002FF25B /* UnwindLLDB.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AF68D32F1255A110002FF25B /* UnwindLLDB.cpp */; };
 		AF94005911C03F6500085DB9 /* SymbolVendor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AF94005711C03F6500085DB9 /* SymbolVendor.cpp */; };
+		B296983712C2FB98002D92C3 /* CommandObjectVersion.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B296983412C2FB2B002D92C3 /* CommandObjectVersion.cpp */; };
 /* End PBXBuildFile section */
 
 /* Begin PBXContainerItemProxy section */
@@ -1081,6 +1082,8 @@
 		AF68D32F1255A110002FF25B /* UnwindLLDB.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = UnwindLLDB.cpp; path = Utility/UnwindLLDB.cpp; sourceTree = "<group>"; };
 		AF68D3301255A110002FF25B /* UnwindLLDB.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = UnwindLLDB.h; path = Utility/UnwindLLDB.h; sourceTree = "<group>"; };
 		AF94005711C03F6500085DB9 /* SymbolVendor.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SymbolVendor.cpp; path = source/Symbol/SymbolVendor.cpp; sourceTree = "<group>"; };
+		B296983412C2FB2B002D92C3 /* CommandObjectVersion.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CommandObjectVersion.cpp; path = source/Commands/CommandObjectVersion.cpp; sourceTree = "<group>"; };
+		B296983512C2FB2B002D92C3 /* CommandObjectVersion.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CommandObjectVersion.h; path = source/Commands/CommandObjectVersion.h; sourceTree = "<group>"; };
 /* End PBXFileReference section */
 
 /* Begin PBXFrameworksBuildPhase section */
@@ -1840,6 +1843,8 @@
 		26BC7D0D10F1B71D00F91463 /* Commands */ = {
 			isa = PBXGroup;
 			children = (
+				B296983512C2FB2B002D92C3 /* CommandObjectVersion.h */,
+				B296983412C2FB2B002D92C3 /* CommandObjectVersion.cpp */,
 				4CA9637A11B6E99A00780E28 /* CommandObjectApropos.h */,
 				4CA9637911B6E99A00780E28 /* CommandObjectApropos.cpp */,
 				499F381E11A5B3F300F5CE02 /* CommandObjectArgs.h */,
@@ -2358,7 +2363,6 @@
 			isa = PBXProject;
 			buildConfigurationList = 1DEB91EF08733DB70010E9CD /* Build configuration list for PBXProject "lldb" */;
 			compatibilityVersion = "Xcode 3.1";
-			developmentRegion = English;
 			hasScannedForEncodings = 1;
 			knownRegions = (
 				en,
@@ -2786,6 +2790,7 @@
 				4CC2A149128C73ED001531C4 /* ThreadPlanTracer.cpp in Sources */,
 				266A42D6128E3FFB0090CF7C /* ClangNamespaceDecl.cpp in Sources */,
 				4C7CF7E61295E12B00B4FBB5 /* ThreadPlanCallUserExpression.cpp in Sources */,
+				B296983712C2FB98002D92C3 /* CommandObjectVersion.cpp in Sources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};

Added: lldb/trunk/source/Commands/CommandObjectVersion.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectVersion.cpp?rev=122515&view=auto
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectVersion.cpp (added)
+++ lldb/trunk/source/Commands/CommandObjectVersion.cpp Thu Dec 23 14:21:44 2010
@@ -0,0 +1,48 @@
+//===-- CommandObjectVersion.cpp --------------------------------*- C++ -*-===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "CommandObjectVersion.h"
+
+// C Includes
+// C++ Includes
+// Other libraries and framework includes
+// Project includes
+#include "lldb/lldb-private.h"
+#include "lldb/Interpreter/CommandInterpreter.h"
+#include "lldb/Interpreter/CommandReturnObject.h"
+
+using namespace lldb;
+using namespace lldb_private;
+
+//-------------------------------------------------------------------------
+// CommandObjectVersion
+//-------------------------------------------------------------------------
+
+CommandObjectVersion::CommandObjectVersion (CommandInterpreter &interpreter) :
+    CommandObject (interpreter, "version", "Show version of LLDB debugger.", "version")
+{
+}
+
+CommandObjectVersion::~CommandObjectVersion ()
+{
+}
+
+bool
+CommandObjectVersion::Execute
+(
+    Args& args,
+    CommandReturnObject &result
+)
+{
+    StreamString &output_stream = result.GetOutputStream();
+    output_stream.Printf ("%s\n", lldb_private::GetVersion());
+    result.SetStatus (eReturnStatusSuccessFinishResult);
+    return true;
+}
+

Added: lldb/trunk/source/Commands/CommandObjectVersion.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectVersion.h?rev=122515&view=auto
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectVersion.h (added)
+++ lldb/trunk/source/Commands/CommandObjectVersion.h Thu Dec 23 14:21:44 2010
@@ -0,0 +1,42 @@
+//===-- CommandObjectVersion.h ----------------------------------*- C++ -*-===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef liblldb_CommandObjectVersion_h_
+#define liblldb_CommandObjectVersion_h_
+
+// C Includes
+// C++ Includes
+// Other libraries and framework includes
+// Project includes
+#include "lldb/Interpreter/CommandObject.h"
+
+namespace lldb_private {
+
+//-------------------------------------------------------------------------
+// CommandObjectVersion
+//-------------------------------------------------------------------------
+
+class CommandObjectVersion : public CommandObject
+{
+public:
+
+    CommandObjectVersion (CommandInterpreter &interpreter);
+
+    virtual
+    ~CommandObjectVersion ();
+
+    virtual bool
+    Execute (Args& args,
+             CommandReturnObject &result);
+
+};
+
+} // namespace lldb_private
+
+#endif  // liblldb_CommandObjectVersion_h_

Modified: lldb/trunk/source/Interpreter/CommandInterpreter.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/CommandInterpreter.cpp?rev=122515&r1=122514&r2=122515&view=diff
==============================================================================
--- lldb/trunk/source/Interpreter/CommandInterpreter.cpp (original)
+++ lldb/trunk/source/Interpreter/CommandInterpreter.cpp Thu Dec 23 14:21:44 2010
@@ -36,6 +36,7 @@
 #include "../Commands/CommandObjectSyntax.h"
 #include "../Commands/CommandObjectTarget.h"
 #include "../Commands/CommandObjectThread.h"
+#include "../Commands/CommandObjectVersion.h"
 
 #include "lldb/Interpreter/Args.h"
 #include "lldb/Core/Debugger.h"
@@ -168,6 +169,7 @@
     m_command_dict["source"]    = CommandObjectSP (new CommandObjectMultiwordSource (*this));
     m_command_dict["target"]    = CommandObjectSP (new CommandObjectMultiwordTarget (*this));
     m_command_dict["thread"]    = CommandObjectSP (new CommandObjectMultiwordThread (*this));
+    m_command_dict["version"]   = CommandObjectSP (new CommandObjectVersion (*this));
 
     std::auto_ptr<CommandObjectRegexCommand>
     break_regex_cmd_ap(new CommandObjectRegexCommand (*this,

Modified: lldb/trunk/test/help/TestHelp.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/help/TestHelp.py?rev=122515&r1=122514&r2=122515&view=diff
==============================================================================
--- lldb/trunk/test/help/TestHelp.py (original)
+++ lldb/trunk/test/help/TestHelp.py Thu Dec 23 14:21:44 2010
@@ -18,6 +18,13 @@
         self.expect("help",
             startstr = 'The following is a list of built-in, permanent debugger commands')
 
+    def test_help_version(self):
+        """Test 'help version' and 'version' commands."""
+        self.expect("help version",
+            substrs = ['Show version of LLDB debugger.'])
+        self.expect("version",
+            patterns = ['LLDB-[0-9]+'])
+
     def test_help_should_not_hang_emacsshell(self):
         """Command 'settings set term-width 0' should not hang the help command."""
         self.runCmd("settings set term-width 0")





More information about the lldb-commits mailing list