[Lldb-commits] [lldb] r107751 - in /lldb/trunk: include/lldb/Interpreter/ lldb.xcodeproj/ source/Commands/ source/Interpreter/

Jim Ingham jingham at apple.com
Tue Jul 6 20:36:20 PDT 2010


Author: jingham
Date: Tue Jul  6 22:36:20 2010
New Revision: 107751

URL: http://llvm.org/viewvc/llvm-project?rev=107751&view=rev
Log:
Fix GetRepeatCommand so it works with multi-word commands.
Move the "source", "alias", and "unalias" commands to "commands *".
Move "source-file" to "source list".
Added a "source info" command but it isn't implemented yet.

Added:
    lldb/trunk/source/Commands/CommandObjectCommands.cpp
    lldb/trunk/source/Commands/CommandObjectCommands.h
Removed:
    lldb/trunk/source/Commands/CommandObjectAlias.cpp
    lldb/trunk/source/Commands/CommandObjectAlias.h
    lldb/trunk/source/Commands/CommandObjectSourceFile.cpp
    lldb/trunk/source/Commands/CommandObjectSourceFile.h
    lldb/trunk/source/Commands/CommandObjectUnalias.cpp
    lldb/trunk/source/Commands/CommandObjectUnalias.h
Modified:
    lldb/trunk/include/lldb/Interpreter/CommandObject.h
    lldb/trunk/include/lldb/Interpreter/CommandObjectMultiword.h
    lldb/trunk/lldb.xcodeproj/project.pbxproj
    lldb/trunk/source/Commands/CommandObjectApropos.cpp
    lldb/trunk/source/Commands/CommandObjectMultiword.cpp
    lldb/trunk/source/Commands/CommandObjectProcess.cpp
    lldb/trunk/source/Commands/CommandObjectSource.cpp
    lldb/trunk/source/Commands/CommandObjectSource.h
    lldb/trunk/source/Interpreter/CommandInterpreter.cpp

Modified: lldb/trunk/include/lldb/Interpreter/CommandObject.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/CommandObject.h?rev=107751&r1=107750&r2=107751&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Interpreter/CommandObject.h (original)
+++ lldb/trunk/include/lldb/Interpreter/CommandObject.h Tue Jul  6 22:36:20 2010
@@ -260,12 +260,13 @@
     ///    The complete current command line.
     ///
     /// @return
-    ///     NULL if the command is not to be repeated.
-    ///     Otherwise a pointer to the command to be repeated.    
+    ///     NULL if there is no special repeat command - it will use the current command line.
+    ///     Otherwise a pointer to the command to be repeated.
+    ///     If the returned string is the empty string, the command won't be repeated.    
     //------------------------------------------------------------------
-    virtual const char *GetRepeatCommand (const char *current_command_line)
+    virtual const char *GetRepeatCommand (Args &current_command_args, uint32_t index)
     {
-        return current_command_line;
+        return NULL;
     }
 
 protected:

Modified: lldb/trunk/include/lldb/Interpreter/CommandObjectMultiword.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/CommandObjectMultiword.h?rev=107751&r1=107750&r2=107751&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Interpreter/CommandObjectMultiword.h (original)
+++ lldb/trunk/include/lldb/Interpreter/CommandObjectMultiword.h Tue Jul  6 22:36:20 2010
@@ -67,6 +67,8 @@
                       bool &word_complete,
                       StringList &matches);
 
+    virtual const char *GetRepeatCommand (Args &current_command_args, uint32_t index);
+
     CommandObject::CommandMap m_subcommand_dict;
 };
 

Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=107751&r1=107750&r2=107751&view=diff
==============================================================================
--- lldb/trunk/lldb.xcodeproj/project.pbxproj (original)
+++ lldb/trunk/lldb.xcodeproj/project.pbxproj Tue Jul  6 22:36:20 2010
@@ -76,7 +76,6 @@
 		26D5B07211B07550009A862E /* Stoppoint.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7E1610F1B83100F91463 /* Stoppoint.cpp */; };
 		26D5B07311B07550009A862E /* StoppointLocation.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7E1710F1B83100F91463 /* StoppointLocation.cpp */; };
 		26D5B07411B07550009A862E /* WatchpointLocation.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7E1810F1B83100F91463 /* WatchpointLocation.cpp */; };
-		26D5B07511B07550009A862E /* CommandObjectAlias.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7E2A10F1B84700F91463 /* CommandObjectAlias.cpp */; };
 		26D5B07611B07550009A862E /* CommandObjectAppend.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7E2B10F1B84700F91463 /* CommandObjectAppend.cpp */; };
 		26D5B07711B07550009A862E /* CommandObjectBreakpoint.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7E2D10F1B84700F91463 /* CommandObjectBreakpoint.cpp */; };
 		26D5B07811B07550009A862E /* CommandObjectDelete.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7E2F10F1B84700F91463 /* CommandObjectDelete.cpp */; };
@@ -96,7 +95,6 @@
 		26D5B08611B07550009A862E /* CommandObjectSettings.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7E4010F1B84700F91463 /* CommandObjectSettings.cpp */; };
 		26D5B08711B07550009A862E /* CommandObjectShow.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7E4110F1B84700F91463 /* CommandObjectShow.cpp */; };
 		26D5B08811B07550009A862E /* CommandObjectSource.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7E4210F1B84700F91463 /* CommandObjectSource.cpp */; };
-		26D5B08911B07550009A862E /* CommandObjectSourceFile.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7E4310F1B84700F91463 /* CommandObjectSourceFile.cpp */; };
 		26D5B08B11B07550009A862E /* CommandObjectSyntax.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7E4510F1B84700F91463 /* CommandObjectSyntax.cpp */; };
 		26D5B08C11B07550009A862E /* CommandObjectThread.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7E4610F1B84700F91463 /* CommandObjectThread.cpp */; };
 		26D5B08D11B07550009A862E /* CommandObjectVariable.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7E4810F1B84700F91463 /* CommandObjectVariable.cpp */; };
@@ -240,7 +238,6 @@
 		26D5B11A11B07550009A862E /* SymbolFileDWARFDebugMap.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 260C89DB10F57C5600BB2B04 /* SymbolFileDWARFDebugMap.cpp */; };
 		26D5B11B11B07550009A862E /* SymbolFileSymtab.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 260C89DE10F57C5600BB2B04 /* SymbolFileSymtab.cpp */; };
 		26D5B11C11B07550009A862E /* SymbolVendorMacOSX.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 260C89E210F57C5600BB2B04 /* SymbolVendorMacOSX.cpp */; };
-		26D5B11D11B07550009A862E /* CommandObjectUnalias.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A8B4EA310FD516400C68FF2 /* CommandObjectUnalias.cpp */; };
 		26D5B11E11B07550009A862E /* ScriptInterpreter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A82010B10FFB49800182560 /* ScriptInterpreter.cpp */; };
 		26D5B11F11B07550009A862E /* BreakpointResolverAddress.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26D0DD5310FE555900271C65 /* BreakpointResolverAddress.cpp */; };
 		26D5B12011B07550009A862E /* BreakpointResolverFileLine.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26D0DD5410FE555900271C65 /* BreakpointResolverFileLine.cpp */; };
@@ -340,6 +337,8 @@
 		49F1A74A11B338AE003ED505 /* ClangExpressionDeclMap.h in Headers */ = {isa = PBXBuildFile; fileRef = 49F1A74911B338AE003ED505 /* ClangExpressionDeclMap.h */; };
 		4C08CDE811C81EF8001610A8 /* ThreadSpec.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C08CDE711C81EF8001610A8 /* ThreadSpec.cpp */; };
 		4C08CDEC11C81F1E001610A8 /* ThreadSpec.h in Headers */ = {isa = PBXBuildFile; fileRef = 4C08CDEB11C81F1E001610A8 /* ThreadSpec.h */; };
+		4C5DBBC811E3FEC60035160F /* CommandObjectCommands.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C5DBBC611E3FEC60035160F /* CommandObjectCommands.cpp */; };
+		4C5DBBC911E3FEC60035160F /* CommandObjectCommands.h in Headers */ = {isa = PBXBuildFile; fileRef = 4C5DBBC711E3FEC60035160F /* CommandObjectCommands.h */; };
 		4CA9637B11B6E99A00780E28 /* CommandObjectApropos.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4CA9637911B6E99A00780E28 /* CommandObjectApropos.cpp */; };
 		9A19A6AF1163BBB200E0D453 /* SBValue.h in Headers */ = {isa = PBXBuildFile; fileRef = 9A19A6A51163BB7E00E0D453 /* SBValue.h */; settings = {ATTRIBUTES = (Public, ); }; };
 		9A19A6B01163BBB300E0D453 /* SBValue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A19A6AD1163BB9800E0D453 /* SBValue.cpp */; };
@@ -594,7 +593,6 @@
 		26BC7CFA10F1B71400F91463 /* Stoppoint.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Stoppoint.h; path = include/lldb/Breakpoint/Stoppoint.h; sourceTree = "<group>"; };
 		26BC7CFB10F1B71400F91463 /* StoppointLocation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = StoppointLocation.h; path = include/lldb/Breakpoint/StoppointLocation.h; sourceTree = "<group>"; };
 		26BC7CFC10F1B71400F91463 /* WatchpointLocation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WatchpointLocation.h; path = include/lldb/Breakpoint/WatchpointLocation.h; sourceTree = "<group>"; };
-		26BC7D1110F1B76300F91463 /* CommandObjectAlias.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CommandObjectAlias.h; path = source/Commands/CommandObjectAlias.h; sourceTree = "<group>"; };
 		26BC7D1210F1B76300F91463 /* CommandObjectAppend.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CommandObjectAppend.h; path = source/Commands/CommandObjectAppend.h; sourceTree = "<group>"; };
 		26BC7D1410F1B76300F91463 /* CommandObjectBreakpoint.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CommandObjectBreakpoint.h; path = source/Commands/CommandObjectBreakpoint.h; sourceTree = "<group>"; };
 		26BC7D1610F1B76300F91463 /* CommandObjectDelete.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CommandObjectDelete.h; path = source/Commands/CommandObjectDelete.h; sourceTree = "<group>"; };
@@ -614,7 +612,6 @@
 		26BC7D2710F1B76300F91463 /* CommandObjectSettings.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CommandObjectSettings.h; path = source/Commands/CommandObjectSettings.h; sourceTree = "<group>"; };
 		26BC7D2810F1B76300F91463 /* CommandObjectShow.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CommandObjectShow.h; path = source/Commands/CommandObjectShow.h; sourceTree = "<group>"; };
 		26BC7D2910F1B76300F91463 /* CommandObjectSource.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CommandObjectSource.h; path = source/Commands/CommandObjectSource.h; sourceTree = "<group>"; };
-		26BC7D2A10F1B76300F91463 /* CommandObjectSourceFile.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CommandObjectSourceFile.h; path = source/Commands/CommandObjectSourceFile.h; sourceTree = "<group>"; };
 		26BC7D2C10F1B76300F91463 /* CommandObjectSyntax.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CommandObjectSyntax.h; path = source/Commands/CommandObjectSyntax.h; sourceTree = "<group>"; };
 		26BC7D2D10F1B76300F91463 /* CommandObjectThread.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CommandObjectThread.h; path = source/Commands/CommandObjectThread.h; sourceTree = "<group>"; };
 		26BC7D2F10F1B76300F91463 /* CommandObjectVariable.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CommandObjectVariable.h; path = source/Commands/CommandObjectVariable.h; sourceTree = "<group>"; };
@@ -712,7 +709,6 @@
 		26BC7E1610F1B83100F91463 /* Stoppoint.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Stoppoint.cpp; path = source/Breakpoint/Stoppoint.cpp; sourceTree = "<group>"; };
 		26BC7E1710F1B83100F91463 /* StoppointLocation.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = StoppointLocation.cpp; path = source/Breakpoint/StoppointLocation.cpp; sourceTree = "<group>"; };
 		26BC7E1810F1B83100F91463 /* WatchpointLocation.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = WatchpointLocation.cpp; path = source/Breakpoint/WatchpointLocation.cpp; sourceTree = "<group>"; };
-		26BC7E2A10F1B84700F91463 /* CommandObjectAlias.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CommandObjectAlias.cpp; path = source/Commands/CommandObjectAlias.cpp; sourceTree = "<group>"; };
 		26BC7E2B10F1B84700F91463 /* CommandObjectAppend.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CommandObjectAppend.cpp; path = source/Commands/CommandObjectAppend.cpp; sourceTree = "<group>"; };
 		26BC7E2D10F1B84700F91463 /* CommandObjectBreakpoint.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CommandObjectBreakpoint.cpp; path = source/Commands/CommandObjectBreakpoint.cpp; sourceTree = "<group>"; };
 		26BC7E2F10F1B84700F91463 /* CommandObjectDelete.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CommandObjectDelete.cpp; path = source/Commands/CommandObjectDelete.cpp; sourceTree = "<group>"; };
@@ -732,7 +728,6 @@
 		26BC7E4010F1B84700F91463 /* CommandObjectSettings.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CommandObjectSettings.cpp; path = source/Commands/CommandObjectSettings.cpp; sourceTree = "<group>"; };
 		26BC7E4110F1B84700F91463 /* CommandObjectShow.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CommandObjectShow.cpp; path = source/Commands/CommandObjectShow.cpp; sourceTree = "<group>"; };
 		26BC7E4210F1B84700F91463 /* CommandObjectSource.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CommandObjectSource.cpp; path = source/Commands/CommandObjectSource.cpp; sourceTree = "<group>"; };
-		26BC7E4310F1B84700F91463 /* CommandObjectSourceFile.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CommandObjectSourceFile.cpp; path = source/Commands/CommandObjectSourceFile.cpp; sourceTree = "<group>"; };
 		26BC7E4510F1B84700F91463 /* CommandObjectSyntax.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CommandObjectSyntax.cpp; path = source/Commands/CommandObjectSyntax.cpp; sourceTree = "<group>"; };
 		26BC7E4610F1B84700F91463 /* CommandObjectThread.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CommandObjectThread.cpp; path = source/Commands/CommandObjectThread.cpp; sourceTree = "<group>"; };
 		26BC7E4810F1B84700F91463 /* CommandObjectVariable.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CommandObjectVariable.cpp; path = source/Commands/CommandObjectVariable.cpp; sourceTree = "<group>"; };
@@ -930,6 +925,8 @@
 		4C43DF8A11069C3200E55CBF /* ThreadPlanStepOverRange.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ThreadPlanStepOverRange.cpp; path = source/Target/ThreadPlanStepOverRange.cpp; sourceTree = "<group>"; };
 		4C51FF1511A4C485007C962F /* ObjCTrampolineHandler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ObjCTrampolineHandler.h; sourceTree = "<group>"; };
 		4C51FF1611A4C486007C962F /* ObjCTrampolineHandler.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ObjCTrampolineHandler.cpp; sourceTree = "<group>"; };
+		4C5DBBC611E3FEC60035160F /* CommandObjectCommands.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CommandObjectCommands.cpp; path = source/Commands/CommandObjectCommands.cpp; sourceTree = "<group>"; };
+		4C5DBBC711E3FEC60035160F /* CommandObjectCommands.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CommandObjectCommands.h; path = source/Commands/CommandObjectCommands.h; sourceTree = "<group>"; };
 		4C98D3DA118FB96F00E575D0 /* ClangFunction.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ClangFunction.cpp; path = source/Expression/ClangFunction.cpp; sourceTree = "<group>"; };
 		4C98D3DB118FB96F00E575D0 /* RecordingMemoryManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = RecordingMemoryManager.cpp; path = source/Expression/RecordingMemoryManager.cpp; sourceTree = "<group>"; };
 		4C98D3E0118FB98F00E575D0 /* ClangFunction.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ClangFunction.h; path = include/lldb/Expression/ClangFunction.h; sourceTree = "<group>"; };
@@ -991,8 +988,6 @@
 		9A633FE7112DCE3C001A7E43 /* SBFrame.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SBFrame.cpp; path = source/API/SBFrame.cpp; sourceTree = "<group>"; };
 		9A633FE8112DCE3C001A7E43 /* SBFrame.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SBFrame.h; path = include/lldb/API/SBFrame.h; sourceTree = "<group>"; };
 		9A82010B10FFB49800182560 /* ScriptInterpreter.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ScriptInterpreter.cpp; path = source/Interpreter/ScriptInterpreter.cpp; sourceTree = "<group>"; };
-		9A8B4EA210FD515000C68FF2 /* CommandObjectUnalias.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CommandObjectUnalias.h; path = source/Commands/CommandObjectUnalias.h; sourceTree = "<group>"; };
-		9A8B4EA310FD516400C68FF2 /* CommandObjectUnalias.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CommandObjectUnalias.cpp; path = source/Commands/CommandObjectUnalias.cpp; sourceTree = "<group>"; };
 		9A9830F21125FC5800A56CB0 /* SBBroadcaster.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SBBroadcaster.cpp; path = source/API/SBBroadcaster.cpp; sourceTree = "<group>"; };
 		9A9830F31125FC5800A56CB0 /* SBBroadcaster.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SBBroadcaster.h; path = include/lldb/API/SBBroadcaster.h; sourceTree = "<group>"; };
 		9A9830F41125FC5800A56CB0 /* SBCommandContext.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SBCommandContext.cpp; path = source/API/SBCommandContext.cpp; sourceTree = "<group>"; };
@@ -1753,8 +1748,6 @@
 		26BC7D0D10F1B71D00F91463 /* Commands */ = {
 			isa = PBXGroup;
 			children = (
-				26BC7D1110F1B76300F91463 /* CommandObjectAlias.h */,
-				26BC7E2A10F1B84700F91463 /* CommandObjectAlias.cpp */,
 				26BC7D1210F1B76300F91463 /* CommandObjectAppend.h */,
 				26BC7E2B10F1B84700F91463 /* CommandObjectAppend.cpp */,
 				4CA9637A11B6E99A00780E28 /* CommandObjectApropos.h */,
@@ -1767,6 +1760,8 @@
 				9A42976211861AA600FE05CD /* CommandObjectBreakpointCommand.cpp */,
 				4C98D3E5118FB9B100E575D0 /* CommandObjectCall.h */,
 				4C98D3E4118FB9B100E575D0 /* CommandObjectCall.cpp */,
+				4C5DBBC711E3FEC60035160F /* CommandObjectCommands.h */,
+				4C5DBBC611E3FEC60035160F /* CommandObjectCommands.cpp */,
 				26BC7D1610F1B76300F91463 /* CommandObjectDelete.h */,
 				26BC7E2F10F1B84700F91463 /* CommandObjectDelete.cpp */,
 				26BC7D1710F1B76300F91463 /* CommandObjectDisassemble.h */,
@@ -1805,16 +1800,12 @@
 				26BC7E4110F1B84700F91463 /* CommandObjectShow.cpp */,
 				26BC7D2910F1B76300F91463 /* CommandObjectSource.h */,
 				26BC7E4210F1B84700F91463 /* CommandObjectSource.cpp */,
-				26BC7D2A10F1B76300F91463 /* CommandObjectSourceFile.h */,
-				26BC7E4310F1B84700F91463 /* CommandObjectSourceFile.cpp */,
 				26BC7D2C10F1B76300F91463 /* CommandObjectSyntax.h */,
 				26BC7E4510F1B84700F91463 /* CommandObjectSyntax.cpp */,
 				269416AE119A024800FF2715 /* CommandObjectTarget.h */,
 				269416AD119A024800FF2715 /* CommandObjectTarget.cpp */,
 				26BC7D2D10F1B76300F91463 /* CommandObjectThread.h */,
 				26BC7E4610F1B84700F91463 /* CommandObjectThread.cpp */,
-				9A8B4EA210FD515000C68FF2 /* CommandObjectUnalias.h */,
-				9A8B4EA310FD516400C68FF2 /* CommandObjectUnalias.cpp */,
 				26BC7D2F10F1B76300F91463 /* CommandObjectVariable.h */,
 				26BC7E4810F1B84700F91463 /* CommandObjectVariable.cpp */,
 			);
@@ -2198,6 +2189,7 @@
 				49A8A3A411D568BF00AD3B68 /* ClangResultSynthesizer.h in Headers */,
 				49DA743511DE6BB2006AEF7E /* IRToDWARF.h in Headers */,
 				49307AB211DEA4F20081F992 /* IRForTarget.h in Headers */,
+				4C5DBBC911E3FEC60035160F /* CommandObjectCommands.h in Headers */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
@@ -2380,7 +2372,6 @@
 				26D5B07211B07550009A862E /* Stoppoint.cpp in Sources */,
 				26D5B07311B07550009A862E /* StoppointLocation.cpp in Sources */,
 				26D5B07411B07550009A862E /* WatchpointLocation.cpp in Sources */,
-				26D5B07511B07550009A862E /* CommandObjectAlias.cpp in Sources */,
 				26D5B07611B07550009A862E /* CommandObjectAppend.cpp in Sources */,
 				26D5B07711B07550009A862E /* CommandObjectBreakpoint.cpp in Sources */,
 				26D5B07811B07550009A862E /* CommandObjectDelete.cpp in Sources */,
@@ -2400,7 +2391,6 @@
 				26D5B08611B07550009A862E /* CommandObjectSettings.cpp in Sources */,
 				26D5B08711B07550009A862E /* CommandObjectShow.cpp in Sources */,
 				26D5B08811B07550009A862E /* CommandObjectSource.cpp in Sources */,
-				26D5B08911B07550009A862E /* CommandObjectSourceFile.cpp in Sources */,
 				26D5B08B11B07550009A862E /* CommandObjectSyntax.cpp in Sources */,
 				26D5B08C11B07550009A862E /* CommandObjectThread.cpp in Sources */,
 				26D5B08D11B07550009A862E /* CommandObjectVariable.cpp in Sources */,
@@ -2544,7 +2534,6 @@
 				26D5B11A11B07550009A862E /* SymbolFileDWARFDebugMap.cpp in Sources */,
 				26D5B11B11B07550009A862E /* SymbolFileSymtab.cpp in Sources */,
 				26D5B11C11B07550009A862E /* SymbolVendorMacOSX.cpp in Sources */,
-				26D5B11D11B07550009A862E /* CommandObjectUnalias.cpp in Sources */,
 				26D5B11E11B07550009A862E /* ScriptInterpreter.cpp in Sources */,
 				26D5B11F11B07550009A862E /* BreakpointResolverAddress.cpp in Sources */,
 				26D5B12011B07550009A862E /* BreakpointResolverFileLine.cpp in Sources */,
@@ -2649,6 +2638,7 @@
 				49A8A3A011D568A300AD3B68 /* ClangResultSynthesizer.cpp in Sources */,
 				49DA743011DE6A5A006AEF7E /* IRToDWARF.cpp in Sources */,
 				49307AAE11DEA4D90081F992 /* IRForTarget.cpp in Sources */,
+				4C5DBBC811E3FEC60035160F /* CommandObjectCommands.cpp in Sources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};

Removed: lldb/trunk/source/Commands/CommandObjectAlias.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectAlias.cpp?rev=107750&view=auto
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectAlias.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectAlias.cpp (removed)
@@ -1,229 +0,0 @@
-//===-- CommandObjectAlias.cpp ----------------------------------*- C++ -*-===//
-//
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include "CommandObjectAlias.h"
-
-
-// C Includes
-// C++ Includes
-// Other libraries and framework includes
-// Project includes
-#include "lldb/Interpreter/CommandObjectMultiword.h"
-#include "lldb/Interpreter/Args.h"
-#include "lldb/Interpreter/Options.h"
-#include "lldb/Interpreter/CommandInterpreter.h"
-#include "lldb/Interpreter/CommandReturnObject.h"
-#include "lldb/Interpreter/CommandInterpreter.h"
-
-using namespace lldb;
-using namespace lldb_private;
-
-//-------------------------------------------------------------------------
-// CommandObjectAlias
-//-------------------------------------------------------------------------
-
-CommandObjectAlias::CommandObjectAlias () :
-    CommandObject ("alias",
-                     "Allows users to define their own debugger command abbreviations.",
-                     "alias <new_command> <old_command> [<options-for-aliased-command>]")
-{
-    SetHelpLong(
-"'alias' allows the user to create a short-cut or abbreviation for long \n\
-commands, multi-word commands, and commands that take particular options. \n\
-Below are some simple examples of how one might use the 'alias' command: \n\
-\n  'alias sc script'       // Creates the abbreviation 'sc' for the 'script' \n\
-                          // command. \n\
-  'alias bp breakpoint'   // Creates the abbreviation 'bp' for the 'breakpoint' \n\
-                          // command.  Since breakpoint commands are two-word \n\
-                          // commands, the user will still need to enter the \n\
-                          // second word after 'bp', e.g. 'bp enable' or \n\
-                          // 'bp delete'. \n\
-  'alias bpi breakpoint list'   // Creates the abbreviation 'bpi' for the \n\
-                                // two-word command 'breakpoint list'. \n\
-\nAn alias can include some options for the command, with the values either \n\
-filled in at the time the alias is created, or specified as positional \n\
-arguments, to be filled in when the alias is invoked.  The following example \n\
-shows how to create aliases with options: \n\
-\n\
-    'alias bfl breakpoint set -f %1 -l %2' \n\
-\nThis creates the abbreviation 'bfl' (for break-file-line), with the -f and -l \n\
-options already part of the alias.  So if the user wants to set a breakpoint \n\
-by file and line without explicitly having to use the -f and -l options, the \n\
-user can now use 'bfl' instead.  The '%1' and '%2' are positional placeholders \n\
-for the actual arguments that will be passed when the alias command is used. \n\
-The number in the placeholder refers to the position/order the actual value \n\
-occupies when the alias is used.  So all the occurrences of '%1' in the alias \n\
-will be replaced with the first argument, all the occurrences of '%2' in the \n\
-alias will be replaced with the second argument, and so on.  This also allows \n\
-actual arguments to be used multiple times within an alias (see 'process \n\
-launch' example below).  So in the 'bfl' case, the actual file value will be \n\
-filled in with the first argument following 'bfl' and the actual line number \n\
-value will be filled in with the second argument.  The user would use this \n\
-alias as follows: \n\
-\n   (dbg)  alias bfl breakpoint set -f %1 -l %2 \n\
-   <... some time later ...> \n\
-   (dbg)  bfl my-file.c 137 \n\
-\nThis would be the same as if the user had entered \n\
-'breakpoint set -f my-file.c -l 137'. \n\
-\nAnother example: \n\
-\n    (dbg)  alias pltty  process launch -s -o %1 -e %1 \n\
-    (dbg)  pltty /dev/tty0 \n\
-    // becomes 'process launch -s -o /dev/tty0 -e /dev/tty0' \n\
-\nIf the user always wanted to pass the same value to a particular option, the \n\
-alias could be defined with that value directly in the alias as a constant, \n\
-rather than using a positional placeholder: \n\
-\n     alias bl3  breakpoint set -f %1 -l 3  // Always sets a breakpoint on line \n\
-                                           // 3 of whatever file is indicated. \n");
-
-}
-
-CommandObjectAlias::~CommandObjectAlias ()
-{
-}
-
-
-bool
-CommandObjectAlias::Execute
-(
-    CommandInterpreter &interpreter,
-    Args& args,
-    CommandReturnObject &result
-)
-{
-    const int argc = args.GetArgumentCount();
-
-    if (argc < 2)
-      {
-        result.AppendError ("'alias' requires at least two arguments");
-        result.SetStatus (eReturnStatusFailed);
-        return false;
-      }
-
-    const std::string alias_command = args.GetArgumentAtIndex(0);
-    const std::string actual_command = args.GetArgumentAtIndex(1);
-
-    args.Shift();  // Shift the alias command word off the argument vector.
-    args.Shift();  // Shift the old command word off the argument vector.
-
-    // Verify that the command is alias'able, and get the appropriate command object.
-
-    if (interpreter.CommandExists (alias_command.c_str()))
-    {
-        result.AppendErrorWithFormat ("'%s' is a permanent debugger command and cannot be redefined.\n",
-                                     alias_command.c_str());
-        result.SetStatus (eReturnStatusFailed);
-    }
-    else
-    {
-         CommandObjectSP command_obj_sp(interpreter.GetCommandSPExact (actual_command.c_str(), true));
-         CommandObjectSP subcommand_obj_sp;
-         bool use_subcommand = false;
-         if (command_obj_sp.get())
-         {
-             CommandObject *cmd_obj = command_obj_sp.get();
-             CommandObject *sub_cmd_obj;
-             OptionArgVectorSP option_arg_vector_sp = OptionArgVectorSP (new OptionArgVector);
-             OptionArgVector *option_arg_vector = option_arg_vector_sp.get();
-
-             if (cmd_obj->IsMultiwordObject())
-             {
-                 if (argc >= 3)
-                 {
-                     const std::string sub_command = args.GetArgumentAtIndex(0);
-                     assert (sub_command.length() != 0);
-                     subcommand_obj_sp =
-                                       (((CommandObjectMultiword *) cmd_obj)->GetSubcommandSP (sub_command.c_str()));
-                     if (subcommand_obj_sp.get())
-                     {
-                         sub_cmd_obj = subcommand_obj_sp.get();
-                         use_subcommand = true;
-                         args.Shift();  // Shift the sub_command word off the argument vector.
-                     }
-                     else
-                     {
-                         result.AppendErrorWithFormat ("Error occurred while attempting to look up command '%s %s'.\n",
-                                                      alias_command.c_str(), sub_command.c_str());
-                         result.SetStatus (eReturnStatusFailed);
-                         return false;
-                     }
-                 }
-             }
-
-             // Verify & handle any options/arguments passed to the alias command
-
-             if (args.GetArgumentCount () > 0)
-             {
-                 if ((!use_subcommand && (cmd_obj->WantsRawCommandString()))
-                     || (use_subcommand && (sub_cmd_obj->WantsRawCommandString())))
-                 {
-                     result.AppendErrorWithFormat ("'%s' cannot be aliased with any options or arguments.\n",
-                                                  (use_subcommand ? sub_cmd_obj->GetCommandName()
-                                                                  : cmd_obj->GetCommandName()));
-                     result.SetStatus (eReturnStatusFailed);
-                     return false;
-                 }
-
-                 // options or arguments have been passed to the alias command, and must be verified & processed here.
-                 if ((!use_subcommand && (cmd_obj->GetOptions() != NULL))
-                     || (use_subcommand && (sub_cmd_obj->GetOptions() != NULL)))
-                 {
-                     Options *options;
-                     if (use_subcommand)
-                         options = sub_cmd_obj->GetOptions();
-                     else
-                         options = cmd_obj->GetOptions();
-                     options->ResetOptionValues ();
-                     args.Unshift ("dummy_arg");
-                     args.ParseAliasOptions (*options, result, option_arg_vector);
-                     args.Shift ();
-                     if (result.Succeeded())
-                         options->VerifyPartialOptions (result);
-                     if (!result.Succeeded())
-                         return false;
-                 }
-                 else
-                 {
-                     for (int i = 0; i < args.GetArgumentCount(); ++i)
-                         option_arg_vector->push_back (OptionArgPair ("<argument>",
-                                                                      std::string (args.GetArgumentAtIndex (i))));
-                 }
-             }
-
-             // Create the alias.
-
-             if (interpreter.AliasExists (alias_command.c_str())
-                 || interpreter.UserCommandExists (alias_command.c_str()))
-             {
-                 OptionArgVectorSP tmp_option_arg_sp (interpreter.GetAliasOptions (alias_command.c_str()));
-                 if (tmp_option_arg_sp.get())
-                 {
-                     if (option_arg_vector->size() == 0)
-                         interpreter.RemoveAliasOptions (alias_command.c_str());
-                 }
-                 result.AppendWarningWithFormat ("Overwriting existing definition for '%s'.\n", alias_command.c_str());
-             }
-
-             if (use_subcommand)
-                 interpreter.AddAlias (alias_command.c_str(), subcommand_obj_sp);
-             else
-                 interpreter.AddAlias (alias_command.c_str(), command_obj_sp);
-             if (option_arg_vector->size() > 0)
-                 interpreter.AddOrReplaceAliasOptions (alias_command.c_str(), option_arg_vector_sp);
-             result.SetStatus (eReturnStatusSuccessFinishNoResult);
-         }
-         else
-         {
-             result.AppendErrorWithFormat ("'%s' is not an existing command.\n", actual_command.c_str());
-             result.SetStatus (eReturnStatusFailed);
-         }
-    }
-
-    return result.Succeeded();
-}
-

Removed: lldb/trunk/source/Commands/CommandObjectAlias.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectAlias.h?rev=107750&view=auto
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectAlias.h (original)
+++ lldb/trunk/source/Commands/CommandObjectAlias.h (removed)
@@ -1,42 +0,0 @@
-//===-- CommandObjectAlias.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_CommandObjectAlias_h_
-#define liblldb_CommandObjectAlias_h_
-
-// C Includes
-// C++ Includes
-// Other libraries and framework includes
-// Project includes
-#include "lldb/Interpreter/CommandObject.h"
-
-namespace lldb_private {
-
-//-------------------------------------------------------------------------
-// CommandObjectAlias
-//-------------------------------------------------------------------------
-
-class CommandObjectAlias : public CommandObject
-{
-public:
-
-    CommandObjectAlias ();
-
-    virtual
-    ~CommandObjectAlias ();
-
-    virtual bool
-    Execute (CommandInterpreter &interpreter,
-             Args& command,
-             CommandReturnObject &result);
-};
-
-} // namespace lldb_private
-
-#endif  // liblldb_CommandObjectAlias_h_

Modified: lldb/trunk/source/Commands/CommandObjectApropos.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectApropos.cpp?rev=107751&r1=107750&r2=107751&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectApropos.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectApropos.cpp Tue Jul  6 22:36:20 2010
@@ -18,7 +18,6 @@
 
 #include "lldb/Interpreter/CommandInterpreter.h"
 #include "lldb/Interpreter/CommandReturnObject.h"
-#include "lldb/Interpreter/CommandObjectMultiword.h"
 
 using namespace lldb;
 using namespace lldb_private;

Added: lldb/trunk/source/Commands/CommandObjectCommands.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectCommands.cpp?rev=107751&view=auto
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectCommands.cpp (added)
+++ lldb/trunk/source/Commands/CommandObjectCommands.cpp Tue Jul  6 22:36:20 2010
@@ -0,0 +1,437 @@
+//===-- CommandObjectSource.cpp ---------------------------------*- C++ -*-===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "CommandObjectCommands.h"
+
+// C Includes
+// C++ Includes
+// Other libraries and framework includes
+// Project includes
+#include "lldb/Interpreter/Args.h"
+#include "lldb/Core/Debugger.h"
+#include "lldb/Interpreter/CommandInterpreter.h"
+#include "lldb/Interpreter/CommandReturnObject.h"
+#include "lldb/Interpreter/Options.h"
+
+using namespace lldb;
+using namespace lldb_private;
+
+const char *k_space_characters = "\t\n\v\f\r ";
+
+//-------------------------------------------------------------------------
+// CommandObjectCommandsSource
+//-------------------------------------------------------------------------
+
+class CommandObjectCommandsSource : public CommandObject
+{
+public:
+    CommandObjectCommandsSource() :
+        CommandObject ("commands source",
+                   "Reads in debugger commands from the file <filename> and executes them.",
+                   "command source <filename>")
+    {
+    }
+
+    ~CommandObjectCommandsSource ()
+    {
+    }
+
+    bool
+    Execute
+    (
+        CommandInterpreter &interpreter,
+        Args& args,
+        CommandReturnObject &result
+    )
+    {
+        const int argc = args.GetArgumentCount();
+        if (argc == 1)
+        {
+            const char *filename = args.GetArgumentAtIndex(0);
+            bool success = true;
+
+            result.AppendMessageWithFormat ("Executing commands in '%s'.\n", filename);
+
+            FileSpec cmd_file (filename);
+            if (cmd_file.Exists())
+            {
+                STLStringArray commands;
+                success = cmd_file.ReadFileLines (commands);
+
+                STLStringArray::iterator pos = commands.begin();
+
+                // Trim out any empty lines or lines that start with the comment
+                // char '#'
+                while (pos != commands.end())
+                {
+                    bool remove_string = false;
+                    size_t non_space = pos->find_first_not_of (k_space_characters);
+                    if (non_space == std::string::npos)
+                        remove_string = true; // Empty line
+                    else if ((*pos)[non_space] == '#')
+                        remove_string = true; // Comment line that starts with '#'
+
+                    if (remove_string)
+                        pos = commands.erase(pos);
+                    else
+                        ++pos;
+                }
+
+                if (commands.size() > 0)
+                {
+                    const size_t num_commands = commands.size();
+                    size_t i;
+                    for (i = 0; i<num_commands; ++i)
+                    {
+                        result.GetOutputStream().Printf("%s %s\n", interpreter.GetPrompt(), commands[i].c_str());
+                        if (!interpreter.HandleCommand(commands[i].c_str(), false, result))
+                            break;
+                    }
+
+                    if (i < num_commands)
+                    {
+                        result.AppendErrorWithFormat("Aborting source of '%s' after command '%s' failed.\n", 
+                                                     filename, commands[i].c_str());
+                        result.SetStatus (eReturnStatusSuccessFinishResult);
+                    }
+                    else
+                    {
+                        success = true;
+                        result.SetStatus (eReturnStatusFailed);
+                    }
+                }
+            }
+            else
+            {
+                result.AppendErrorWithFormat ("File '%s' does not exist.\n", filename);
+                result.SetStatus (eReturnStatusFailed);
+                success = false;
+            }
+
+            if (success)
+            {
+                result.SetStatus (eReturnStatusSuccessFinishNoResult);
+            }
+        }
+        else
+        {
+            result.AppendErrorWithFormat("'%s' takes exactly one executable filename argument.\n", GetCommandName());
+            result.SetStatus (eReturnStatusFailed);
+        }
+        return result.Succeeded();
+
+    }
+};
+
+#pragma mark CommandObjectCommandsAlias
+//-------------------------------------------------------------------------
+// CommandObjectCommandsAlias
+//-------------------------------------------------------------------------
+
+class CommandObjectCommandsAlias : public CommandObject
+{
+public:
+    CommandObjectCommandsAlias () :
+        CommandObject ("commands alias",
+                         "Allows users to define their own debugger command abbreviations.",
+                         "alias <new_command> <old_command> [<options-for-aliased-command>]")
+    {
+        SetHelpLong(
+    "'alias' allows the user to create a short-cut or abbreviation for long \n\
+    commands, multi-word commands, and commands that take particular options. \n\
+    Below are some simple examples of how one might use the 'alias' command: \n\
+    \n  'alias sc script'       // Creates the abbreviation 'sc' for the 'script' \n\
+                              // command. \n\
+      'alias bp breakpoint'   // Creates the abbreviation 'bp' for the 'breakpoint' \n\
+                              // command.  Since breakpoint commands are two-word \n\
+                              // commands, the user will still need to enter the \n\
+                              // second word after 'bp', e.g. 'bp enable' or \n\
+                              // 'bp delete'. \n\
+      'alias bpi breakpoint list'   // Creates the abbreviation 'bpi' for the \n\
+                                    // two-word command 'breakpoint list'. \n\
+    \nAn alias can include some options for the command, with the values either \n\
+    filled in at the time the alias is created, or specified as positional \n\
+    arguments, to be filled in when the alias is invoked.  The following example \n\
+    shows how to create aliases with options: \n\
+    \n\
+        'alias bfl breakpoint set -f %1 -l %2' \n\
+    \nThis creates the abbreviation 'bfl' (for break-file-line), with the -f and -l \n\
+    options already part of the alias.  So if the user wants to set a breakpoint \n\
+    by file and line without explicitly having to use the -f and -l options, the \n\
+    user can now use 'bfl' instead.  The '%1' and '%2' are positional placeholders \n\
+    for the actual arguments that will be passed when the alias command is used. \n\
+    The number in the placeholder refers to the position/order the actual value \n\
+    occupies when the alias is used.  So all the occurrences of '%1' in the alias \n\
+    will be replaced with the first argument, all the occurrences of '%2' in the \n\
+    alias will be replaced with the second argument, and so on.  This also allows \n\
+    actual arguments to be used multiple times within an alias (see 'process \n\
+    launch' example below).  So in the 'bfl' case, the actual file value will be \n\
+    filled in with the first argument following 'bfl' and the actual line number \n\
+    value will be filled in with the second argument.  The user would use this \n\
+    alias as follows: \n\
+    \n   (dbg)  alias bfl breakpoint set -f %1 -l %2 \n\
+       <... some time later ...> \n\
+       (dbg)  bfl my-file.c 137 \n\
+    \nThis would be the same as if the user had entered \n\
+    'breakpoint set -f my-file.c -l 137'. \n\
+    \nAnother example: \n\
+    \n    (dbg)  alias pltty  process launch -s -o %1 -e %1 \n\
+        (dbg)  pltty /dev/tty0 \n\
+        // becomes 'process launch -s -o /dev/tty0 -e /dev/tty0' \n\
+    \nIf the user always wanted to pass the same value to a particular option, the \n\
+    alias could be defined with that value directly in the alias as a constant, \n\
+    rather than using a positional placeholder: \n\
+    \n     alias bl3  breakpoint set -f %1 -l 3  // Always sets a breakpoint on line \n\
+                                               // 3 of whatever file is indicated. \n");
+
+    }
+
+    ~CommandObjectCommandsAlias ()
+    {
+    }
+
+
+    bool
+    Execute
+    (
+        CommandInterpreter &interpreter,
+        Args& args,
+        CommandReturnObject &result
+    )
+    {
+        const int argc = args.GetArgumentCount();
+
+        if (argc < 2)
+          {
+            result.AppendError ("'alias' requires at least two arguments");
+            result.SetStatus (eReturnStatusFailed);
+            return false;
+          }
+
+        const std::string alias_command = args.GetArgumentAtIndex(0);
+        const std::string actual_command = args.GetArgumentAtIndex(1);
+
+        args.Shift();  // Shift the alias command word off the argument vector.
+        args.Shift();  // Shift the old command word off the argument vector.
+
+        // Verify that the command is alias'able, and get the appropriate command object.
+
+        if (interpreter.CommandExists (alias_command.c_str()))
+        {
+            result.AppendErrorWithFormat ("'%s' is a permanent debugger command and cannot be redefined.\n",
+                                         alias_command.c_str());
+            result.SetStatus (eReturnStatusFailed);
+        }
+        else
+        {
+             CommandObjectSP command_obj_sp(interpreter.GetCommandSPExact (actual_command.c_str(), true));
+             CommandObjectSP subcommand_obj_sp;
+             bool use_subcommand = false;
+             if (command_obj_sp.get())
+             {
+                 CommandObject *cmd_obj = command_obj_sp.get();
+                 CommandObject *sub_cmd_obj;
+                 OptionArgVectorSP option_arg_vector_sp = OptionArgVectorSP (new OptionArgVector);
+                 OptionArgVector *option_arg_vector = option_arg_vector_sp.get();
+
+                 if (cmd_obj->IsMultiwordObject())
+                 {
+                     if (argc >= 3)
+                     {
+                         const std::string sub_command = args.GetArgumentAtIndex(0);
+                         assert (sub_command.length() != 0);
+                         subcommand_obj_sp =
+                                           (((CommandObjectMultiword *) cmd_obj)->GetSubcommandSP (sub_command.c_str()));
+                         if (subcommand_obj_sp.get())
+                         {
+                             sub_cmd_obj = subcommand_obj_sp.get();
+                             use_subcommand = true;
+                             args.Shift();  // Shift the sub_command word off the argument vector.
+                         }
+                         else
+                         {
+                             result.AppendErrorWithFormat ("Error occurred while attempting to look up command '%s %s'.\n",
+                                                          alias_command.c_str(), sub_command.c_str());
+                             result.SetStatus (eReturnStatusFailed);
+                             return false;
+                         }
+                     }
+                 }
+
+                 // Verify & handle any options/arguments passed to the alias command
+
+                 if (args.GetArgumentCount () > 0)
+                 {
+                     if ((!use_subcommand && (cmd_obj->WantsRawCommandString()))
+                         || (use_subcommand && (sub_cmd_obj->WantsRawCommandString())))
+                     {
+                         result.AppendErrorWithFormat ("'%s' cannot be aliased with any options or arguments.\n",
+                                                      (use_subcommand ? sub_cmd_obj->GetCommandName()
+                                                                      : cmd_obj->GetCommandName()));
+                         result.SetStatus (eReturnStatusFailed);
+                         return false;
+                     }
+
+                     // options or arguments have been passed to the alias command, and must be 
+                     // verified & processed here.
+                     if ((!use_subcommand && (cmd_obj->GetOptions() != NULL))
+                         || (use_subcommand && (sub_cmd_obj->GetOptions() != NULL)))
+                     {
+                         Options *options;
+                         if (use_subcommand)
+                             options = sub_cmd_obj->GetOptions();
+                         else
+                             options = cmd_obj->GetOptions();
+                         options->ResetOptionValues ();
+                         args.Unshift ("dummy_arg");
+                         args.ParseAliasOptions (*options, result, option_arg_vector);
+                         args.Shift ();
+                         if (result.Succeeded())
+                             options->VerifyPartialOptions (result);
+                         if (!result.Succeeded())
+                             return false;
+                     }
+                     else
+                     {
+                         for (int i = 0; i < args.GetArgumentCount(); ++i)
+                             option_arg_vector->push_back (OptionArgPair ("<argument>",
+                                                                          std::string (args.GetArgumentAtIndex (i))));
+                     }
+                 }
+
+                 // Create the alias.
+
+                 if (interpreter.AliasExists (alias_command.c_str())
+                     || interpreter.UserCommandExists (alias_command.c_str()))
+                 {
+                     OptionArgVectorSP tmp_option_arg_sp (interpreter.GetAliasOptions (alias_command.c_str()));
+                     if (tmp_option_arg_sp.get())
+                     {
+                         if (option_arg_vector->size() == 0)
+                             interpreter.RemoveAliasOptions (alias_command.c_str());
+                     }
+                     result.AppendWarningWithFormat ("Overwriting existing definition for '%s'.\n", 
+                                                     alias_command.c_str());
+                 }
+
+                 if (use_subcommand)
+                     interpreter.AddAlias (alias_command.c_str(), subcommand_obj_sp);
+                 else
+                     interpreter.AddAlias (alias_command.c_str(), command_obj_sp);
+                 if (option_arg_vector->size() > 0)
+                     interpreter.AddOrReplaceAliasOptions (alias_command.c_str(), option_arg_vector_sp);
+                 result.SetStatus (eReturnStatusSuccessFinishNoResult);
+             }
+             else
+             {
+                 result.AppendErrorWithFormat ("'%s' is not an existing command.\n", actual_command.c_str());
+                 result.SetStatus (eReturnStatusFailed);
+             }
+        }
+
+        return result.Succeeded();
+    }
+};
+
+#pragma mark CommandObjectCommandsUnalias
+//-------------------------------------------------------------------------
+// CommandObjectCommandsUnalias
+//-------------------------------------------------------------------------
+
+class CommandObjectCommandsUnalias : public CommandObject
+{
+public:
+    CommandObjectCommandsUnalias () :
+        CommandObject ("commands unalias",
+                   "Allows the user to remove/delete a user-defined command abbreviation.",
+                   "unalias <alias-name-to-be-removed>")
+    {
+    }
+
+    ~CommandObjectCommandsUnalias()
+    {
+    }
+
+
+    bool
+    Execute
+    (
+        CommandInterpreter &interpreter,
+        Args& args,
+        CommandReturnObject &result
+    )
+    {
+        CommandObject::CommandMap::iterator pos;
+        CommandObject *cmd_obj;
+
+        if (args.GetArgumentCount() != 0)
+        {
+            const char *command_name = args.GetArgumentAtIndex(0);
+            cmd_obj = interpreter.GetCommandObject(command_name);
+            if (cmd_obj)
+            {
+                if (interpreter.CommandExists (command_name))
+                {
+                    result.AppendErrorWithFormat ("'%s' is a permanent debugger command and cannot be removed.\n",
+                                                  command_name);
+                    result.SetStatus (eReturnStatusFailed);
+                }
+                else
+                {
+
+                    if (interpreter.RemoveAlias (command_name) == false)
+                    {
+                        if (interpreter.AliasExists (command_name))
+                            result.AppendErrorWithFormat ("Error occurred while attempting to unalias '%s'.\n", 
+                                                          command_name);
+                        else
+                            result.AppendErrorWithFormat ("'%s' is not an existing alias.\n", command_name);
+                        result.SetStatus (eReturnStatusFailed);
+                    }
+                    else
+                        result.SetStatus (eReturnStatusSuccessFinishNoResult);
+                }
+            }
+            else
+            {
+                result.AppendErrorWithFormat ("'%s' is not a known command.\nTry 'help' to see a "
+                                              "current list of commands.\n",
+                                             command_name);
+                result.SetStatus (eReturnStatusFailed);
+            }
+        }
+        else
+        {
+            result.AppendError ("must call 'unalias' with a valid alias");
+            result.SetStatus (eReturnStatusFailed);
+        }
+
+        return result.Succeeded();
+    }
+};
+
+#pragma mark CommandObjectMultiwordCommands
+
+//-------------------------------------------------------------------------
+// CommandObjectMultiwordCommands
+//-------------------------------------------------------------------------
+
+CommandObjectMultiwordCommands::CommandObjectMultiwordCommands (CommandInterpreter &interpreter) :
+    CommandObjectMultiword ("commands",
+                            "Commands for managing the command interpreters commands",
+                            "commands <subcommand> [<subcommand-options>]")
+{
+    LoadSubCommand (interpreter, "source",   CommandObjectSP (new CommandObjectCommandsSource ()));
+    LoadSubCommand (interpreter, "alias",   CommandObjectSP (new CommandObjectCommandsAlias ()));
+}
+
+CommandObjectMultiwordCommands::~CommandObjectMultiwordCommands ()
+{
+}
+

Added: lldb/trunk/source/Commands/CommandObjectCommands.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectCommands.h?rev=107751&view=auto
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectCommands.h (added)
+++ lldb/trunk/source/Commands/CommandObjectCommands.h Tue Jul  6 22:36:20 2010
@@ -0,0 +1,40 @@
+//===-- CommandObjectCommands.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_CommandObjectCommands_h_
+#define liblldb_CommandObjectCommands_h_
+
+// C Includes
+// C++ Includes
+// Other libraries and framework includes
+// Project includes
+#include "lldb/Interpreter/CommandObject.h"
+#include "lldb/Interpreter/CommandObjectMultiword.h"
+#include "lldb/Core/STLUtils.h"
+
+namespace lldb_private {
+
+//-------------------------------------------------------------------------
+// CommandObjectMultiwordCommands
+//-------------------------------------------------------------------------
+
+class CommandObjectMultiwordCommands : public CommandObjectMultiword
+{
+public:
+
+    CommandObjectMultiwordCommands (CommandInterpreter &interpreter);
+
+    virtual
+    ~CommandObjectMultiwordCommands ();
+
+};
+
+} // namespace lldb_private
+
+#endif  // liblldb_CommandObjectCommands_h_

Modified: lldb/trunk/source/Commands/CommandObjectMultiword.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectMultiword.cpp?rev=107751&r1=107750&r2=107751&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectMultiword.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectMultiword.cpp Tue Jul  6 22:36:20 2010
@@ -287,3 +287,16 @@
     }
 }
 
+const char *
+CommandObjectMultiword::GetRepeatCommand (Args &current_command_args, uint32_t index)
+{
+    if (current_command_args.GetArgumentCount() == 0)
+        return NULL;
+    index++;
+    CommandObject *sub_command_object = GetSubcommandObject (current_command_args.GetArgumentAtIndex(index));
+    if (sub_command_object == NULL)
+        return NULL;
+    else 
+    return sub_command_object->GetRepeatCommand(current_command_args, index);
+}
+

Modified: lldb/trunk/source/Commands/CommandObjectProcess.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectProcess.cpp?rev=107751&r1=107750&r2=107751&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectProcess.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectProcess.cpp Tue Jul  6 22:36:20 2010
@@ -247,6 +247,12 @@
         return result.Succeeded();
     }
 
+    virtual const char *GetRepeatCommand (Args &current_command_args, uint32_t index)
+    {
+        // No repeat for "process launch"...
+        return "";
+    }
+
 protected:
 
     CommandOptions m_options;

Modified: lldb/trunk/source/Commands/CommandObjectSource.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectSource.cpp?rev=107751&r1=107750&r2=107751&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectSource.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectSource.cpp Tue Jul  6 22:36:20 2010
@@ -17,110 +17,347 @@
 #include "lldb/Core/Debugger.h"
 #include "lldb/Interpreter/CommandInterpreter.h"
 #include "lldb/Interpreter/CommandReturnObject.h"
+#include "lldb/Core/FileSpec.h"
 #include "lldb/Target/Process.h"
+#include "lldb/Core/SourceManager.h"
 #include "lldb/Target/TargetList.h"
+#include "lldb/Interpreter/CommandCompletions.h"
+#include "lldb/Interpreter/Options.h"
 
 using namespace lldb;
 using namespace lldb_private;
 
-const char *k_space_characters = "\t\n\v\f\r ";
-
 //-------------------------------------------------------------------------
-// CommandObjectSource
+// CommandObjectSourceList
 //-------------------------------------------------------------------------
 
-CommandObjectSource::CommandObjectSource() :
-    CommandObject ("source",
-                   "Reads in debugger commands from the file <filename> and executes them.",
-                   "source <filename>")
+class CommandObjectSourceInfo : public CommandObject
 {
-}
 
-CommandObjectSource::~CommandObjectSource ()
+    class CommandOptions : public Options
+    {
+    public:
+        CommandOptions () :
+            Options()
+        {
+        }
+
+        ~CommandOptions ()
+        {
+        }
+
+        Error
+        SetOptionValue (int option_idx, const char *option_arg)
+        {
+            Error error;
+            const char short_option = g_option_table[option_idx].short_option;
+            switch (short_option)
+            {
+            case 'l':
+                start_line = Args::StringToUInt32 (option_arg, 0);
+                if (start_line == 0)
+                    error.SetErrorStringWithFormat("Invalid line number: '%s'.\n", option_arg);
+                break;
+
+             case 'f':
+                file_name = option_arg;
+                break;
+
+           default:
+                error.SetErrorStringWithFormat("Unrecognized short option '%c'.\n", short_option);
+                break;
+            }
+
+            return error;
+        }
+
+        void
+        ResetOptionValues ()
+        {
+            Options::ResetOptionValues();
+
+            file_spec.Clear();
+            file_name.clear();
+            start_line = 0;
+        }
+
+        const lldb::OptionDefinition*
+        GetDefinitions ()
+        {
+            return g_option_table;
+        }
+        static lldb::OptionDefinition g_option_table[];
+
+        // Instance variables to hold the values for command options.
+        FileSpec file_spec;
+        std::string file_name;
+        uint32_t start_line;
+        
+    };
+ 
+public:   
+    CommandObjectSourceInfo() :
+        CommandObject ("source info",
+                         "Display info on the source lines from the current executable's debug info.",
+                         "source info [<cmd-options>]")
+    {
+    }
+
+    ~CommandObjectSourceInfo ()
+    {
+    }
+
+
+    Options *
+    GetOptions ()
+    {
+        return &m_options;
+    }
+
+
+    bool
+    Execute
+    (
+        CommandInterpreter &interpreter,
+        Args& args,
+        CommandReturnObject &result
+    )
+    {
+        result.AppendError ("Not yet implemented");
+        result.SetStatus (eReturnStatusFailed);
+        return false;
+    }
+protected:
+    CommandOptions m_options;
+};
+
+lldb::OptionDefinition
+CommandObjectSourceInfo::CommandOptions::g_option_table[] =
 {
-}
+{ LLDB_OPT_SET_1, false, "line",       'l', required_argument, NULL, 0, "<line>",    "The line number at which to start the display source."},
+{ LLDB_OPT_SET_1, false, "file",       'f', required_argument, NULL, CommandCompletions::eSourceFileCompletion, "<file>",    "The file from which to display source."},
+{ 0, false, NULL, 0, 0, NULL, 0, NULL, NULL }
+};
+
+#pragma mark CommandObjectSourceList
+//-------------------------------------------------------------------------
+// CommandObjectSourceList
+//-------------------------------------------------------------------------
 
-bool
-CommandObjectSource::Execute
-(
-    CommandInterpreter &interpreter,
-    Args& args,
-    CommandReturnObject &result
-)
+class CommandObjectSourceList : public CommandObject
 {
-    const int argc = args.GetArgumentCount();
-    if (argc == 1)
+
+    class CommandOptions : public Options
     {
-        const char *filename = args.GetArgumentAtIndex(0);
-        bool success = true;
+    public:
+        CommandOptions () :
+            Options()
+        {
+        }
 
-        result.AppendMessageWithFormat ("Executing commands in '%s'.\n", filename);
+        ~CommandOptions ()
+        {
+        }
 
-        FileSpec cmd_file (filename);
-        if (cmd_file.Exists())
+        Error
+        SetOptionValue (int option_idx, const char *option_arg)
         {
-            STLStringArray commands;
-            success = cmd_file.ReadFileLines (commands);
+            Error error;
+            const char short_option = g_option_table[option_idx].short_option;
+            switch (short_option)
+            {
+            case 'l':
+                start_line = Args::StringToUInt32 (option_arg, 0);
+                if (start_line == 0)
+                    error.SetErrorStringWithFormat("Invalid line number: '%s'.\n", option_arg);
+                break;
+
+            case 'n':
+                num_lines = Args::StringToUInt32 (option_arg, 0);
+                if (num_lines == 0)
+                    error.SetErrorStringWithFormat("Invalid line count: '%s'.\n", option_arg);
+                break;
+
+             case 'f':
+                file_name = option_arg;
+                break;
+
+           default:
+                error.SetErrorStringWithFormat("Unrecognized short option '%c'.\n", short_option);
+                break;
+            }
 
-            STLStringArray::iterator pos = commands.begin();
+            return error;
+        }
 
-            // Trim out any empty lines or lines that start with the comment
-            // char '#'
-            while (pos != commands.end())
-            {
-                bool remove_string = false;
-                size_t non_space = pos->find_first_not_of (k_space_characters);
-                if (non_space == std::string::npos)
-                    remove_string = true; // Empty line
-                else if ((*pos)[non_space] == '#')
-                    remove_string = true; // Comment line that starts with '#'
+        void
+        ResetOptionValues ()
+        {
+            Options::ResetOptionValues();
 
-                if (remove_string)
-                    pos = commands.erase(pos);
-                else
-                    ++pos;
-            }
+            file_spec.Clear();
+            file_name.clear();
+            start_line = 0;
+            num_lines = 10;
+        }
 
-            if (commands.size() > 0)
-            {
-                const size_t num_commands = commands.size();
-                size_t i;
-                for (i = 0; i<num_commands; ++i)
-                {
-                    result.GetOutputStream().Printf("%s %s\n", interpreter.GetPrompt(), commands[i].c_str());
-                    if (!interpreter.HandleCommand(commands[i].c_str(), false, result))
-                        break;
-                }
+        const lldb::OptionDefinition*
+        GetDefinitions ()
+        {
+            return g_option_table;
+        }
+        static lldb::OptionDefinition g_option_table[];
+
+        // Instance variables to hold the values for command options.
+        FileSpec file_spec;
+        std::string file_name;
+        uint32_t start_line;
+        uint32_t num_lines;
+        
+    };
+ 
+public:   
+    CommandObjectSourceList() :
+        CommandObject ("source list",
+                         "Display source files from the current executable's debug info.",
+                         "source list [<cmd-options>] [<filename>]")
+    {
+    }
+
+    ~CommandObjectSourceList ()
+    {
+    }
+
+
+    Options *
+    GetOptions ()
+    {
+        return &m_options;
+    }
 
-                if (i < num_commands)
+
+    bool
+    Execute
+    (
+        CommandInterpreter &interpreter,
+        Args& args,
+        CommandReturnObject &result
+    )
+    {
+        const int argc = args.GetArgumentCount();
+
+        if (argc != 0)
+        {
+            result.AppendErrorWithFormat("'%s' takes no arguments, only flags.\n", GetCommandName());
+            result.SetStatus (eReturnStatusFailed);
+        }
+
+        ExecutionContext exe_ctx(interpreter.GetDebugger().GetExecutionContext());
+        if (m_options.file_name.empty())
+        {
+            // Last valid source manager context, or the current frame if no
+            // valid last context in source manager.
+            // One little trick here, if you type the exact same list command twice in a row, it is
+            // more likely because you typed it once, then typed it again
+            if (m_options.start_line == 0)
+            {
+                if (interpreter.GetDebugger().GetSourceManager().DisplayMoreWithLineNumbers (&result.GetOutputStream()))
                 {
-                    result.AppendErrorWithFormat("Aborting source of '%s' after command '%s' failed.\n", filename, commands[i].c_str());
                     result.SetStatus (eReturnStatusSuccessFinishResult);
                 }
-                else
+            }
+            else
+            {
+                if (interpreter.GetDebugger().GetSourceManager().DisplaySourceLinesWithLineNumbersUsingLastFile(
+                            m_options.start_line,   // Line to display
+                            0,                      // Lines before line to display
+                            m_options.num_lines,    // Lines after line to display
+                            "",                     // Don't mark "line"
+                            &result.GetOutputStream()))
                 {
-                    success = true;
-                    result.SetStatus (eReturnStatusFailed);
+                    result.SetStatus (eReturnStatusSuccessFinishResult);
                 }
+
             }
         }
         else
         {
-            result.AppendErrorWithFormat ("File '%s' does not exist.\n", filename);
-            result.SetStatus (eReturnStatusFailed);
-            success = false;
-        }
+            const char *filename = m_options.file_name.c_str();
+            Target *target = interpreter.GetDebugger().GetCurrentTarget().get();
+            if (target == NULL)
+            {
+                result.AppendError ("invalid target, set executable file using 'file' command");
+                result.SetStatus (eReturnStatusFailed);
+                return false;
+            }
 
-        if (success)
-        {
-            result.SetStatus (eReturnStatusSuccessFinishNoResult);
+
+            bool check_inlines = false;
+            SymbolContextList sc_list;
+            size_t num_matches = target->GetImages().ResolveSymbolContextForFilePath (filename,
+                                                                                      0,
+                                                                                      check_inlines,
+                                                                                      eSymbolContextModule | eSymbolContextCompUnit,
+                                                                                      sc_list);
+            if (num_matches > 0)
+            {
+                SymbolContext sc;
+                if (sc_list.GetContextAtIndex(0, sc))
+                {
+                    if (sc.comp_unit)
+                    {
+                        interpreter.GetDebugger().GetSourceManager().DisplaySourceLinesWithLineNumbers (sc.comp_unit,
+                                                                                                         m_options.start_line,   // Line to display
+                                                                                                         0,                      // Lines before line to display
+                                                                                                         m_options.num_lines,    // Lines after line to display
+                                                                                                         "",                     // Don't mark "line"
+                                                                                                         &result.GetOutputStream());
+                        
+                        result.SetStatus (eReturnStatusSuccessFinishResult);
+
+                    }
+                }
+            }
         }
+
+        return result.Succeeded();
     }
-    else
+    
+    virtual const char *GetRepeatCommand (Args &current_command_args, uint32_t index)
     {
-        result.AppendErrorWithFormat("'%s' takes exactly one executable filename argument.\n", GetCommandName());
-        result.SetStatus (eReturnStatusFailed);
+        return m_cmd_name.c_str();
     }
-    return result.Succeeded();
 
+protected:
+    CommandOptions m_options;
+
+};
+
+lldb::OptionDefinition
+CommandObjectSourceList::CommandOptions::g_option_table[] =
+{
+{ LLDB_OPT_SET_1, false, "line",       'l', required_argument, NULL, 0, "<line>",    "The line number at which to start the display source."},
+{ LLDB_OPT_SET_1, false, "file",       'f', required_argument, NULL, CommandCompletions::eSourceFileCompletion, "<file>",    "The file from which to display source."},
+{ LLDB_OPT_SET_1, false, "count",      'n', required_argument, NULL, 0, "<count>",   "The number of source lines to display."},
+{ 0, false, NULL, 0, 0, NULL, 0, NULL, NULL }
+};
+
+#pragma mark CommandObjectMultiwordSource
+
+//-------------------------------------------------------------------------
+// CommandObjectMultiwordSource
+//-------------------------------------------------------------------------
+
+CommandObjectMultiwordSource::CommandObjectMultiwordSource (CommandInterpreter &interpreter) :
+    CommandObjectMultiword ("source",
+                            "Commands for accessing source file information",
+                            "source <subcommand> [<subcommand-options>]")
+{
+    LoadSubCommand (interpreter, "info",   CommandObjectSP (new CommandObjectSourceInfo ()));
+    LoadSubCommand (interpreter, "list",   CommandObjectSP (new CommandObjectSourceList ()));
+}
+
+CommandObjectMultiwordSource::~CommandObjectMultiwordSource ()
+{
 }
+

Modified: lldb/trunk/source/Commands/CommandObjectSource.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectSource.h?rev=107751&r1=107750&r2=107751&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectSource.h (original)
+++ lldb/trunk/source/Commands/CommandObjectSource.h Tue Jul  6 22:36:20 2010
@@ -1,4 +1,4 @@
-//===-- CommandObjectSource.h -----------------------------------*- C++ -*-===//
+//===-- CommandObjectSource.h.h -----------------------------------*- C++ -*-===//
 //
 //                     The LLVM Compiler Infrastructure
 //
@@ -15,33 +15,26 @@
 // Other libraries and framework includes
 // Project includes
 #include "lldb/Interpreter/CommandObject.h"
+#include "lldb/Interpreter/CommandObjectMultiword.h"
 #include "lldb/Core/STLUtils.h"
 
 namespace lldb_private {
 
 //-------------------------------------------------------------------------
-// CommandObjectSource
+// CommandObjectMultiwordSource
 //-------------------------------------------------------------------------
 
-class CommandObjectSource : public CommandObject
+class CommandObjectMultiwordSource : public CommandObjectMultiword
 {
 public:
 
-    CommandObjectSource ();
+    CommandObjectMultiwordSource (CommandInterpreter &interpreter);
 
     virtual
-    ~CommandObjectSource ();
-
-    STLStringArray &
-    GetCommands ();
-
-    virtual bool
-    Execute (CommandInterpreter &interpreter,
-             Args& command,
-             CommandReturnObject &result);
+    ~CommandObjectMultiwordSource ();
 
 };
 
 } // namespace lldb_private
 
-#endif  // liblldb_CommandObjectSource_h_
+#endif  // liblldb_CommandObjectSource.h_h_

Removed: lldb/trunk/source/Commands/CommandObjectSourceFile.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectSourceFile.cpp?rev=107750&view=auto
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectSourceFile.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectSourceFile.cpp (removed)
@@ -1,205 +0,0 @@
-//===-- CommandObjectSourceFile.cpp -----------------------------*- C++ -*-===//
-//
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include "CommandObjectSourceFile.h"
-
-// C Includes
-// C++ Includes
-// Other libraries and framework includes
-// Project includes
-#include "lldb/Interpreter/Args.h"
-#include "lldb/Core/Debugger.h"
-#include "lldb/Interpreter/CommandInterpreter.h"
-#include "lldb/Interpreter/CommandReturnObject.h"
-#include "lldb/Target/Process.h"
-#include "lldb/Core/SourceManager.h"
-#include "lldb/Target/TargetList.h"
-#include "lldb/Interpreter/CommandCompletions.h"
-
-using namespace lldb;
-using namespace lldb_private;
-
-CommandObjectSourceFile::CommandOptions::CommandOptions () :
-    Options()
-{
-}
-
-CommandObjectSourceFile::CommandOptions::~CommandOptions ()
-{
-}
-
-Error
-CommandObjectSourceFile::CommandOptions::SetOptionValue (int option_idx, const char *option_arg)
-{
-    Error error;
-    const char short_option = g_option_table[option_idx].short_option;
-    switch (short_option)
-    {
-    case 'l':
-        start_line = Args::StringToUInt32 (option_arg, 0);
-        if (start_line == 0)
-            error.SetErrorStringWithFormat("Invalid line number: '%s'.\n", option_arg);
-        break;
-
-    case 'n':
-        num_lines = Args::StringToUInt32 (option_arg, 0);
-        if (num_lines == 0)
-            error.SetErrorStringWithFormat("Invalid line count: '%s'.\n", option_arg);
-        break;
-
-     case 'f':
-        file_name = option_arg;
-        break;
-
-   default:
-        error.SetErrorStringWithFormat("Unrecognized short option '%c'.\n", short_option);
-        break;
-    }
-
-    return error;
-}
-
-void
-CommandObjectSourceFile::CommandOptions::ResetOptionValues ()
-{
-    Options::ResetOptionValues();
-
-    file_spec.Clear();
-    file_name.clear();
-    start_line = 0;
-    num_lines = 10;
-}
-
-const lldb::OptionDefinition*
-CommandObjectSourceFile::CommandOptions::GetDefinitions ()
-{
-    return g_option_table;
-}
-
-lldb::OptionDefinition
-CommandObjectSourceFile::CommandOptions::g_option_table[] =
-{
-{ LLDB_OPT_SET_1, false, "line",       'l', required_argument, NULL, 0, "<line>",    "The line number at which to start the display source."},
-{ LLDB_OPT_SET_1, false, "file",       'f', required_argument, NULL, CommandCompletions::eSourceFileCompletion, "<file>",    "The file from which to display source."},
-{ LLDB_OPT_SET_1, false, "count",      'n', required_argument, NULL, 0, "<count>",   "The number of source lines to display."},
-{ 0, false, NULL, 0, 0, NULL, 0, NULL, NULL }
-};
-
-
-
-//-------------------------------------------------------------------------
-// CommandObjectSourceFile
-//-------------------------------------------------------------------------
-
-CommandObjectSourceFile::CommandObjectSourceFile() :
-    CommandObject ("source-file",
-                     "Display source files from the current executable's debug info.",
-                     "source-file [<cmd-options>] [<filename>]")
-{
-}
-
-CommandObjectSourceFile::~CommandObjectSourceFile ()
-{
-}
-
-
-Options *
-CommandObjectSourceFile::GetOptions ()
-{
-    return &m_options;
-}
-
-
-bool
-CommandObjectSourceFile::Execute
-(
-    CommandInterpreter &interpreter,
-    Args& args,
-    CommandReturnObject &result
-)
-{
-    const int argc = args.GetArgumentCount();
-
-    if (argc != 0)
-    {
-        result.AppendErrorWithFormat("'%s' takes no arguments, only flags.\n", GetCommandName());
-        result.SetStatus (eReturnStatusFailed);
-    }
-
-    ExecutionContext exe_ctx(interpreter.GetDebugger().GetExecutionContext());
-    if (m_options.file_name.empty())
-    {
-        // Last valid source manager context, or the current frame if no
-        // valid last context in source manager.
-        // One little trick here, if you type the exact same list command twice in a row, it is
-        // more likely because you typed it once, then typed it again
-        if (m_options.start_line == 0)
-        {
-            if (interpreter.GetDebugger().GetSourceManager().DisplayMoreWithLineNumbers (&result.GetOutputStream()))
-            {
-                result.SetStatus (eReturnStatusSuccessFinishResult);
-            }
-        }
-        else
-        {
-            if (interpreter.GetDebugger().GetSourceManager().DisplaySourceLinesWithLineNumbersUsingLastFile(
-                        m_options.start_line,   // Line to display
-                        0,                      // Lines before line to display
-                        m_options.num_lines,    // Lines after line to display
-                        "",                     // Don't mark "line"
-                        &result.GetOutputStream()))
-            {
-                result.SetStatus (eReturnStatusSuccessFinishResult);
-            }
-
-        }
-    }
-    else
-    {
-        const char *filename = m_options.file_name.c_str();
-        Target *target = interpreter.GetDebugger().GetCurrentTarget().get();
-        if (target == NULL)
-        {
-            result.AppendError ("invalid target, set executable file using 'file' command");
-            result.SetStatus (eReturnStatusFailed);
-            return false;
-        }
-
-
-        bool check_inlines = false;
-        SymbolContextList sc_list;
-        size_t num_matches = target->GetImages().ResolveSymbolContextForFilePath (filename,
-                                                                                  0,
-                                                                                  check_inlines,
-                                                                                  eSymbolContextModule | eSymbolContextCompUnit,
-                                                                                  sc_list);
-        if (num_matches > 0)
-        {
-            SymbolContext sc;
-            if (sc_list.GetContextAtIndex(0, sc))
-            {
-                if (sc.comp_unit)
-                {
-                    interpreter.GetDebugger().GetSourceManager ().DisplaySourceLinesWithLineNumbers (sc.comp_unit,
-                                                                                                     m_options.start_line,   // Line to display
-                                                                                                     0,                      // Lines before line to display
-                                                                                                     m_options.num_lines,    // Lines after line to display
-                                                                                                     "",                     // Don't mark "line"
-                                                                                                     &result.GetOutputStream());
-                    
-                    result.SetStatus (eReturnStatusSuccessFinishResult);
-
-                }
-            }
-        }
-    }
-
-    return result.Succeeded();
-}
-

Removed: lldb/trunk/source/Commands/CommandObjectSourceFile.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectSourceFile.h?rev=107750&view=auto
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectSourceFile.h (original)
+++ lldb/trunk/source/Commands/CommandObjectSourceFile.h (removed)
@@ -1,86 +0,0 @@
-//===-- CommandObjectSourceFile.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_CommandObjectSourceFile_h_
-#define liblldb_CommandObjectSourceFile_h_
-
-// C Includes
-// C++ Includes
-// Other libraries and framework includes
-// Project includes
-#include "lldb/Interpreter/CommandObject.h"
-#include "lldb/Interpreter/Options.h"
-#include "lldb/Core/FileSpec.h"
-
-namespace lldb_private {
-
-//-------------------------------------------------------------------------
-// CommandObjectSourceFile
-//-------------------------------------------------------------------------
-
-class CommandObjectSourceFile : public CommandObject
-{
-public:
-    class CommandOptions : public Options
-    {
-    public:
-
-        CommandOptions ();
-
-        virtual
-        ~CommandOptions ();
-
-        virtual Error
-        SetOptionValue (int option_idx, const char *option_arg);
-
-        void
-        ResetOptionValues ();
-
-        const lldb::OptionDefinition*
-        GetDefinitions ();
-
-        // Options table: Required for subclasses of Options.
-
-        static lldb::OptionDefinition g_option_table[];
-
-        // Instance variables to hold the values for command options.
-        FileSpec file_spec;
-        std::string file_name;
-        uint32_t start_line;
-        uint32_t num_lines;
-    };
-
-    CommandObjectSourceFile ();
-
-    virtual
-    ~CommandObjectSourceFile ();
-
-    virtual bool
-    Execute (CommandInterpreter &interpreter,
-             Args& command,
-             CommandReturnObject &result);
-
-    virtual
-    Options *
-    GetOptions ();
-    
-    virtual const char *GetRepeatCommand (const char *current_command_line)
-    {
-        printf("\nReturning: \"%s\"\n", m_cmd_name.c_str());
-        return m_cmd_name.c_str();
-    }
-
-
-protected:
-    CommandOptions m_options;
-};
-
-} // namespace lldb_private
-
-#endif  // liblldb_CommandObjectSourceFile_h_

Removed: lldb/trunk/source/Commands/CommandObjectUnalias.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectUnalias.cpp?rev=107750&view=auto
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectUnalias.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectUnalias.cpp (removed)
@@ -1,91 +0,0 @@
-//===-- CommandObjectUnalias.cpp --------------------------------*- C++ -*-===//
-//
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include "CommandObjectUnalias.h"
-
-// C Includes
-// C++ Includes
-// Other libraries and framework includes
-// Project includes
-#include "lldb/Interpreter/CommandInterpreter.h"
-#include "lldb/Interpreter/CommandReturnObject.h"
-
-using namespace lldb;
-using namespace lldb_private;
-
-//-------------------------------------------------------------------------
-// CommandObjectUnalias
-//-------------------------------------------------------------------------
-
-CommandObjectUnalias::CommandObjectUnalias () :
-    CommandObject ("unalias",
-                   "Allows the user to remove/delete a user-defined command abbreviation.",
-                   "unalias <alias-name-to-be-removed>")
-{
-}
-
-CommandObjectUnalias::~CommandObjectUnalias()
-{
-}
-
-
-bool
-CommandObjectUnalias::Execute
-(
-    CommandInterpreter &interpreter,
-    Args& args,
-    CommandReturnObject &result
-)
-{
-    CommandObject::CommandMap::iterator pos;
-    CommandObject *cmd_obj;
-
-    if (args.GetArgumentCount() != 0)
-    {
-        const char *command_name = args.GetArgumentAtIndex(0);
-        cmd_obj = interpreter.GetCommandObject(command_name);
-        if (cmd_obj)
-        {
-            if (interpreter.CommandExists (command_name))
-            {
-                result.AppendErrorWithFormat ("'%s' is a permanent debugger command and cannot be removed.\n",
-                                              command_name);
-                result.SetStatus (eReturnStatusFailed);
-            }
-            else
-            {
-
-                if (interpreter.RemoveAlias (command_name) == false)
-                {
-                    if (interpreter.AliasExists (command_name))
-                        result.AppendErrorWithFormat ("Error occurred while attempting to unalias '%s'.\n", command_name);
-                    else
-                        result.AppendErrorWithFormat ("'%s' is not an existing alias.\n", command_name);
-                    result.SetStatus (eReturnStatusFailed);
-                }
-                else
-                    result.SetStatus (eReturnStatusSuccessFinishNoResult);
-            }
-        }
-        else
-        {
-            result.AppendErrorWithFormat ("'%s' is not a known command.\nTry 'help' to see a current list of commands.\n",
-                                         command_name);
-            result.SetStatus (eReturnStatusFailed);
-        }
-    }
-    else
-    {
-        result.AppendError ("must call 'unalias' with a valid alias");
-        result.SetStatus (eReturnStatusFailed);
-    }
-
-    return result.Succeeded();
-}
-

Removed: lldb/trunk/source/Commands/CommandObjectUnalias.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectUnalias.h?rev=107750&view=auto
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectUnalias.h (original)
+++ lldb/trunk/source/Commands/CommandObjectUnalias.h (removed)
@@ -1,43 +0,0 @@
-//===-- CommandObjectUnalias.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_CommandObjectUnalias_h_
-#define liblldb_CommandObjectUnalias_h_
-
-// C Includes
-// C++ Includes
-// Other libraries and framework includes
-// Project includes
-#include "lldb/Interpreter/CommandObject.h"
-
-namespace lldb_private {
-
-//-------------------------------------------------------------------------
-// CommandObjectUnalias
-//-------------------------------------------------------------------------
-
-class CommandObjectUnalias : public CommandObject
-{
-public:
-
-    CommandObjectUnalias ();
-
-    virtual
-    ~CommandObjectUnalias ();
-
-    virtual bool
-    Execute (CommandInterpreter &interpreter,
-             Args& args,
-             CommandReturnObject &result);
-
-};
-
-} // namespace lldb_private
-
-#endif  // liblldb_CommandObjectUnalias_h_

Modified: lldb/trunk/source/Interpreter/CommandInterpreter.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/CommandInterpreter.cpp?rev=107751&r1=107750&r2=107751&view=diff
==============================================================================
--- lldb/trunk/source/Interpreter/CommandInterpreter.cpp (original)
+++ lldb/trunk/source/Interpreter/CommandInterpreter.cpp Tue Jul  6 22:36:20 2010
@@ -38,7 +38,7 @@
 #include "../Commands/CommandObjectSettings.h"
 #include "../Commands/CommandObjectShow.h"
 #include "../Commands/CommandObjectSource.h"
-#include "../Commands/CommandObjectSourceFile.h"
+#include "../Commands/CommandObjectCommands.h"
 #include "../Commands/CommandObjectSyntax.h"
 #include "../Commands/CommandObjectTarget.h"
 #include "../Commands/CommandObjectThread.h"
@@ -84,24 +84,24 @@
     InitializeVariables ();
 
     // Set up some initial aliases.
-    result.Clear(); HandleCommand ("alias q        quit", false, result);
-    result.Clear(); HandleCommand ("alias run      process launch", false, result);
-    result.Clear(); HandleCommand ("alias r        process launch", false, result);
-    result.Clear(); HandleCommand ("alias c        process continue", false, result);
-    result.Clear(); HandleCommand ("alias continue process continue", false, result);
-    result.Clear(); HandleCommand ("alias expr     expression", false, result);
-    result.Clear(); HandleCommand ("alias exit     quit", false, result);
-    result.Clear(); HandleCommand ("alias b        breakpoint", false, result);
-    result.Clear(); HandleCommand ("alias bt       thread backtrace", false, result);
-    result.Clear(); HandleCommand ("alias si       thread step-inst", false, result);
-    result.Clear(); HandleCommand ("alias step     thread step-in", false, result);
-    result.Clear(); HandleCommand ("alias s        thread step-in", false, result);
-    result.Clear(); HandleCommand ("alias next     thread step-over", false, result);
-    result.Clear(); HandleCommand ("alias n        thread step-over", false, result);
-    result.Clear(); HandleCommand ("alias finish   thread step-out", false, result);
-    result.Clear(); HandleCommand ("alias x        memory read", false, result);
-    result.Clear(); HandleCommand ("alias l        source-file", false, result);
-    result.Clear(); HandleCommand ("alias list     source-file", false, result);
+    result.Clear(); HandleCommand ("command alias q        quit", false, result);
+    result.Clear(); HandleCommand ("command alias run      process launch", false, result);
+    result.Clear(); HandleCommand ("command alias r        process launch", false, result);
+    result.Clear(); HandleCommand ("command alias c        process continue", false, result);
+    result.Clear(); HandleCommand ("command alias continue process continue", false, result);
+    result.Clear(); HandleCommand ("command alias expr     expression", false, result);
+    result.Clear(); HandleCommand ("command alias exit     quit", false, result);
+    result.Clear(); HandleCommand ("command alias b        breakpoint", false, result);
+    result.Clear(); HandleCommand ("command alias bt       thread backtrace", false, result);
+    result.Clear(); HandleCommand ("command alias si       thread step-inst", false, result);
+    result.Clear(); HandleCommand ("command alias step     thread step-in", false, result);
+    result.Clear(); HandleCommand ("command alias s        thread step-in", false, result);
+    result.Clear(); HandleCommand ("command alias next     thread step-over", false, result);
+    result.Clear(); HandleCommand ("command alias n        thread step-over", false, result);
+    result.Clear(); HandleCommand ("command alias finish   thread step-out", false, result);
+    result.Clear(); HandleCommand ("command alias x        memory read", false, result);
+    result.Clear(); HandleCommand ("command alias l        source list", false, result);
+    result.Clear(); HandleCommand ("command alias list     source list", false, result);
 }
 
 void
@@ -206,11 +206,11 @@
 
     // Non-CommandObjectCrossref commands can now be created.
 
-    m_command_dict["alias"]     = CommandObjectSP (new CommandObjectAlias ());
     m_command_dict["append"]    = CommandObjectSP (new CommandObjectAppend ());
     m_command_dict["apropos"]   = CommandObjectSP (new CommandObjectApropos ());
     m_command_dict["breakpoint"]= CommandObjectSP (new CommandObjectMultiwordBreakpoint (*this));
     m_command_dict["call"]      = CommandObjectSP (new CommandObjectCall ());
+    m_command_dict["commands"]  = CommandObjectSP (new CommandObjectMultiwordCommands (*this));
     m_command_dict["disassemble"] = CommandObjectSP (new CommandObjectDisassemble ());
     m_command_dict["expression"]= CommandObjectSP (new CommandObjectExpression ());
     m_command_dict["file"]      = CommandObjectSP (new CommandObjectFile ());
@@ -226,11 +226,9 @@
     m_command_dict["set"]       = CommandObjectSP (new CommandObjectSet ());
     m_command_dict["settings"]  = CommandObjectSP (new CommandObjectSettings ());
     m_command_dict["show"]      = CommandObjectSP (new CommandObjectShow ());
-    m_command_dict["source"]    = CommandObjectSP (new CommandObjectSource ());
-    m_command_dict["source-file"] = CommandObjectSP (new CommandObjectSourceFile ());
+    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["unalias"]   = CommandObjectSP (new CommandObjectUnalias ());
     m_command_dict["variable"]  = CommandObjectSP (new CommandObjectVariable (*this));
 
     std::auto_ptr<CommandObjectRegexCommand>
@@ -630,7 +628,7 @@
             command_line = m_repeat_command.c_str();
             if (m_repeat_command.empty())
             {
-                result.AppendError("");
+                result.AppendErrorWithFormat("No auto repeat.\n");
                 result.SetStatus (eReturnStatusFailed);
                 return false;
             }
@@ -661,11 +659,11 @@
 
                 if (add_to_history)
                 {
-                    const char *repeat_command = command_obj->GetRepeatCommand(command_line);
-                    if (repeat_command)
+                    const char *repeat_command = command_obj->GetRepeatCommand(command_args, 0);
+                    if (repeat_command != NULL)
                         m_repeat_command.assign(repeat_command);
                     else
-                        m_repeat_command.clear();
+                        m_repeat_command.assign(command_line);
                         
                     m_command_history.push_back (command_line);
                 }





More information about the lldb-commits mailing list